Skip to content

Commit

Permalink
Devcontainers (#103)
Browse files Browse the repository at this point in the history
* initial commit for Devcontainers

* switch to devcontainers

* update bundler

* update dependencies

* switch to vite rails

* externalize solid queue for debugging

* rubocop

* adapt CI

* switch cuprite to playwright

* fix leave spec

* fix playwright step
  • Loading branch information
JensRavens authored Jun 26, 2024
1 parent af6483c commit 86c75c4
Show file tree
Hide file tree
Showing 47 changed files with 997 additions and 596 deletions.
42 changes: 42 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "nerdgeschoss",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"postCreateCommand": "bin/setup",
"remoteUser": "root",
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"GitHub.copilot",
"esbenp.prettier-vscode",
"sianglim.slim",
"Shopify.ruby-lsp",
"EditorConfig.EditorConfig",
"eamodio.gitlens",
"GraphQL.vscode-graphql",
"bierner.markdown-mermaid"
],
"settings": {
"typescript.tsdk": "node_modules/typescript/lib",
"rubyLsp.rubyVersionManager": "none",
"[ruby]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "Shopify.ruby-lsp"
}
}
}
},
"features": {
"ghcr.io/devcontainers/features/desktop-lite:1": {}
},
"forwardPorts": [
6080
],
"portsAttributes": {
"6080": {
"label": "playwright"
}
}
}
36 changes: 36 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3'

services:
app:
image: ghcr.io/nerdgeschoss/nerdgeschoss/development-environment:3.3-18
volumes:
- ../..:/workspaces:cached
- nerdgeschoss_app-node_modules:/workspaces/nerdgeschoss_app/node_modules

# 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.
network_mode: service:db

environment:
REDIS_URL: redis://redis:6379
TZ: Europe/Berlin

db:
image: postgres:15.1
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_HOST_AUTH_METHOD: trust
redis:
image: redis
restart: unless-stopped
volumes:
- redis-data:/data

volumes:
postgres-data:
redis-data:
nerdgeschoss_app-node_modules:
27 changes: 11 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ on: [push]

env:
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
RAILS_ENV: test
DATABASE_URL: postgres://postgres:[email protected]:5432/app
RSPEC_RETRY_RETRY_COUNT: 3
SCREENSHOTS: '1'

jobs:
ruby:
runs-on: ubuntu-20.04

services:
postgres:
image: postgres:12
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -25,7 +29,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
node-version: '18.x'
cache: yarn
- name: Install yarn
run: yarn install
Expand All @@ -39,25 +43,16 @@ jobs:
run: bundle exec i18n-tasks health
- name: Check Model Annotations
run: bundle exec annotate --models && bin/git_tracked_are_unmodified
env:
DATABASE_URL: postgres://postgres:[email protected]:5432/app
RAILS_ENV: test
- name: JS Lint
run: yarn lint
- name: Build Assets
run: yarn build
- name: Install Playwright Browsers
run: npx --yes playwright install --with-deps chromium
- name: Build
run: bundle exec rails assets:precompile
- name: Create PG Database
run: bundle exec rake db:create db:migrate
env:
DATABASE_URL: postgres://postgres:[email protected]:5432/app
RAILS_ENV: test
- name: Build and test with Rake
- name: Build and test with RSpec
run: bundle exec rspec --format documentation
env:
DATABASE_URL: postgres://postgres:[email protected]:5432/app
RAILS_ENV: test
RSPEC_RETRY_RETRY_COUNT: 3
SCREENSHOTS: '1'
- name: Upload Screenshots
if: always()
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ node_modules
.DS_Store

*.env
/public/vite-dev
/public/vite-test
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 3.1
SuggestExtensions: false

inherit_gem:
shimmer: config/rubocop_base.yml
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.4
3.3.1
47 changes: 40 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,47 @@
"version": "0.2.0",
"configurations": [
{
"type": "rdbg",
"name": "Rails Server",
"name": "UI",
"type": "chrome",
"request": "launch",
"command": "bin/rails",
"script": "server",
"args": [],
"askParameters": false,
"useBundler": true
"url": "http://localhost:3000/",
"webRoot": "${workspaceFolder}",
"preLaunchTask": "Sleepdelay"
},
{
"name": "Rails",
"type": "ruby_lsp",
"request": "launch",
"program": "bin/rails server"
},
{
"name": "Solid Queue",
"type": "ruby_lsp",
"request": "launch",
"program": "bin/rails solid_queue:start",
"preLaunchTask": "Sleepdelay"
},
{
"name": "Vite",
"type": "node-terminal",
"request": "launch",
"command": "yarn build --watch"
}
],
"compounds": [
{
"name": "Run App",
"configurations": [
"Vite",
"Rails",
"UI",
"Solid Queue"
],
"stopAll": true,
"presentation": {
"group": "1_dev",
"order": 1
}
}
]
}
6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

21 changes: 21 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Sleepdelay",
"type": "shell",
"command": "sleep 4",
"windows": {
"command": "ping 127.0.0.1 -n 4 > nul"
},
"group": "none",
"presentation": {
"reveal": "silent",
"panel": "new",
"close": true
}
}
]
}
16 changes: 6 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

source "https://rubygems.org"
ruby File.read(File.join(__dir__, ".ruby-version")).strip
ruby "~> #{File.read(File.join(__dir__, ".ruby-version")).strip}"

# Core
gem "puma"
gem "rails", "7.1.3"
gem "rails", "~> 7.1.3"

# Database
gem "pg"
Expand Down Expand Up @@ -41,11 +41,8 @@ gem "yael"
gem "faker"

# Assets
gem "autoprefixer-rails"
gem "jsbundling-rails"
gem "sassc-rails"
gem "serviceworker-rails"
gem "sprockets"
gem "sprockets-rails"
gem "vite_rails"
gem "stimulus-rails"
gem "turbo-rails"

Expand All @@ -59,7 +56,7 @@ gem "sentry-ruby"
group :development, :test do
gem "capybara"
gem "capybara-screenshot-diff"
gem "cuprite"
gem "capybara-playwright-driver"
gem "i18n-tasks"
gem "rack_session_access"
gem "rspec-rails"
Expand All @@ -76,10 +73,9 @@ end
group :development do
gem "annotate"
gem "debug"
gem "guard"
gem "guard-rspec"
gem "letter_opener"
gem "listen"
gem "rb-fsevent"
gem "web-console"
gem "ruby-lsp-rspec", require: false
end
Loading

0 comments on commit 86c75c4

Please sign in to comment.