Skip to content

Commit

Permalink
Merge branch 'main' into allow_redirect_from_configuration_hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevinrob authored Aug 24, 2023
2 parents f2ed371 + a6f8624 commit 5280793
Show file tree
Hide file tree
Showing 1,575 changed files with 36,876 additions and 23,594 deletions.
11 changes: 5 additions & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby/.devcontainer/base.Dockerfile

# [Choice] Ruby version: 3, 3.0, 2, 2.7, 2.6
ARG VARIANT="3.0"
FROM mcr.microsoft.com/devcontainers/ruby:0-${VARIANT}
ARG VARIANT="3"
FROM mcr.microsoft.com/devcontainers/ruby:${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
ARG NODE_VERSION="lts/*"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
mariadb-server libmariadb-dev \
postgresql postgresql-client postgresql-contrib libpq-dev \
redis-server memcached \
mariadb-client libmariadb-dev \
postgresql-client postgresql-contrib libpq-dev \
ffmpeg mupdf mupdf-tools libvips poppler-utils


Expand Down
16 changes: 5 additions & 11 deletions .devcontainer/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ yarn install

sudo chown -R vscode:vscode /usr/local/bundle

sudo service postgresql start
sudo service mariadb start
sudo service redis-server start
sudo service memcached start
cd activerecord

# Create PostgreSQL users and databases
sudo su postgres -c "createuser --superuser vscode"
sudo su postgres -c "createdb -O vscode -E UTF8 -T template0 activerecord_unittest"
sudo su postgres -c "createdb -O vscode -E UTF8 -T template0 activerecord_unittest2"
# Create PostgreSQL databases
bundle exec rake db:postgresql:rebuild

# Create MySQL database and databases
cd activerecord
MYSQL_CODESPACES=1 bundle exec rake db:mysql:build
# Create MySQL databases
MYSQL_CODESPACES=1 bundle exec rake db:mysql:rebuild
51 changes: 28 additions & 23 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "Ruby",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6
"VARIANT": "3",
// Options
"NODE_VERSION": "lts/*"
}
},
"name": "Rails project development",
"dockerComposeFile": "docker-compose.yml",
"service": "rails",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
}
},

// Set *default* container specific settings.json values on container create.
"settings": {},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"rebornix.Ruby"
],
"containerEnv": {
"PGHOST": "postgres",
"PGUSER": "postgres",
"PGPASSWORD": "postgres",
"MYSQL_HOST": "mariadb",
"REDIS_URL": "redis://redis/0",
"MEMCACHE_SERVERS": "memcached:11211"
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// This can be used to network with other containers or the host.
// "forwardPorts": [3000, 5432],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": ".devcontainer/boot.sh",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
// Configure tool-specific properties.
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"Shopify.ruby-lsp"
]
}
},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
71 changes: 71 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
version: '3'

services:
rails:
build:
context: ..
dockerfile: .devcontainer/Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
networks:
- default

depends_on:
- postgres
- mariadb
- redis
- memcached

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

postgres:
image: postgres:latest
restart: unless-stopped
networks:
- default
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres

mariadb:
image: mariadb:latest
restart: unless-stopped
networks:
- default
volumes:
- mariadb-data:/var/lib/mysql
environment:
MARIADB_ROOT_PASSWORD: root

redis:
image: redis:latest
restart: unless-stopped
networks:
- default
volumes:
- redis-data:/data

memcached:
image: memcached:latest
restart: unless-stopped
command: ["-m", "1024"]
networks:
- default

networks:
default:

volumes:
postgres-data:
mariadb-data:
redis-data:
60 changes: 37 additions & 23 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,56 @@
name: Lint

on: [pull_request]
on: [push, pull_request]

permissions:
contents: read

jobs:
changelog-formatting:
name: Check CHANGELOGs formatting
lint:
runs-on: ubuntu-latest
env:
BUNDLE_WITHOUT: db:job:cable:storage:ujs

steps:
- uses: actions/checkout@v3

- name: Set up Ruby 3.2
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true

- name: mdl
run: bundle exec rake -f guides/Rakefile guides:lint

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install codespell==2.1.0
- name: Check spelling with codespell
run: codespell --ignore-words=codespell.txt --skip="./vendor/bundle,./actionview/test/ujs/public/vendor/qunit.js,./actiontext/app/assets/javascripts/trix.js,./yarn.lock" || exit 1

- uses: actions/checkout@v3
with:
repository: skipkayhil/rails-bin
ref: ba349066e1ce0c6e8d5b2c5e92dc71802237adbd
ref: 748f4673a5fe5686b5859e89f814166280e51781
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
ruby-version: 3.2
bundler-cache: true
- uses: actions/checkout@v3
with:
path: rails
- run: bin/check-changelogs ./rails
codespell:
name: Check spelling all files with codespell
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install codespell==2.1.0
- name: Check spelling with codespell
run: codespell --ignore-words=codespell.txt --skip="./actionview/test/ujs/public/vendor/qunit.js" || exit 1
- run: bin/check-config-docs ./rails

- uses: zzak/action-discord@v8
continue-on-error: true
if: failure() && github.ref_name == 'main'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
webhook: ${{ secrets.DISCORD_WEBHOOK }}
42 changes: 42 additions & 0 deletions .github/workflows/rails-new-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: rails-new-docker

on: [push, pull_request]

env:
APP_NAME: devrails
APP_PATH: dev/devrails
BUNDLE_WITHOUT: db:job:cable:storage:ujs

jobs:
rails-new-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Generate --dev app
run: |
bundle exec railties/exe/rails new $APP_PATH --dev
- name: Build image
run: |
podman build -t $APP_NAME \
-v $(pwd):$(pwd) \
-f ./$APP_PATH/Dockerfile \
./$APP_PATH
- name: Run container
run: |
podman run --name $APP_NAME \
-v $(pwd):$(pwd) \
-e SECRET_KEY_BASE_DUMMY=1 \
-p 3000:3000 $APP_NAME &
- name: Test container
run: ruby -r ./.github/workflows/scripts/test-container.rb

- uses: zzak/action-discord@v8
continue-on-error: true
if: failure() && github.ref_name == 'main'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
webhook: ${{ secrets.DISCORD_WEBHOOK }}
9 changes: 9 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ jobs:

- name: Run RuboCop
run: bundle exec rubocop --parallel

- uses: zzak/action-discord@v8
env:
BUNDLE_ONLY: ""
continue-on-error: true
if: failure() && github.ref_name == 'main'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
webhook: ${{ secrets.DISCORD_WEBHOOK }}
29 changes: 29 additions & 0 deletions .github/workflows/scripts/test-container.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# Based on Sam Ruby's system test from dockerfile-rails:
# https://github.com/rubys/dockerfile-rails/pull/21

require "net/http"
require "socket"

LOCALHOST = Socket.gethostname
PORT = 3000

60.times do |i|
sleep 0.5
begin
response = Net::HTTP.get_response(LOCALHOST, "/up", PORT)

if %w(404 500).include? response.code
status = response.code.to_i
end

puts response.body
exit status || 0
rescue SystemCallError, IOError
puts "#{i}/60 Connection to #{LOCALHOST}:#{PORT} refused or timed out, retrying..."
end
end

exit 999
1 change: 1 addition & 0 deletions .mdlrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style "#{File.dirname(__FILE__)}/.mdlrc.rb"
23 changes: 23 additions & 0 deletions .mdlrc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

all

exclude_rule "MD003"
exclude_rule "MD004"
exclude_rule "MD005"
exclude_rule "MD006"
exclude_rule "MD007"
exclude_rule "MD012"
exclude_rule "MD014"
exclude_rule "MD024"
exclude_rule "MD026"
exclude_rule "MD033"
exclude_rule "MD034"
exclude_rule "MD036"
exclude_rule "MD040"
exclude_rule "MD041"

rule "MD013", line_length: 2000, ignore_code_blocks: true
# rule "MD024", allow_different_nesting: true # This did not work as intended, see action_cable_overview.md
rule "MD029", style: :ordered
# rule "MD046", style: :consistent # default (:fenced)
Loading

0 comments on commit 5280793

Please sign in to comment.