Skip to content

Commit cb06ef9

Browse files
committed
Update github action test workflow
1 parent 0d7dc30 commit cb06ef9

File tree

4 files changed

+80
-67
lines changed

4 files changed

+80
-67
lines changed

.github/workflows/rails-ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: "Ruby on Rails CI"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
postgres:
15+
image: postgres:15-alpine
16+
ports:
17+
- "5432:5432"
18+
env:
19+
POSTGRES_DB: rails_test
20+
POSTGRES_USER: rails
21+
POSTGRES_PASSWORD: password
22+
options: >-
23+
--health-cmd pg_isready
24+
--health-interval 10s
25+
--health-timeout 5s
26+
--health-retries 5
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Build Docker image
36+
run: docker build -t money-sleuth:test .
37+
38+
- name: Run tests in Docker
39+
run: |
40+
docker run --rm \
41+
--network host \
42+
-v ${{ github.workspace }}:/myapp \
43+
-e RAILS_ENV=test \
44+
-e DATABASE_URL="postgres://rails:password@localhost:5432/rails_test" \
45+
-e BASIC_AUTH_ADMIN_PASSWORD="password" \
46+
money-sleuth:test \
47+
bash -c "bin/rails db:schema:load && bin/rails assets:precompile && bin/rake"
48+
49+
lint:
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- name: Checkout code
54+
uses: actions/checkout@v4
55+
56+
- name: Set up Docker Buildx
57+
uses: docker/setup-buildx-action@v3
58+
59+
- name: Build Docker image
60+
run: docker build -t money-sleuth:test .
61+
62+
- name: Run linting in Docker
63+
run: |
64+
docker run --rm \
65+
-v ${{ github.workspace }}:/myapp \
66+
money-sleuth:test \
67+
bash -c "
68+
bundle exec bundler-audit --update
69+
bundle exec bundler-audit
70+
bundle exec brakeman -q -w2
71+
bundle exec rubocop --parallel
72+
"

.github/workflows/rubyonrails.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ group :development do
5353
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
5454
gem 'spring'
5555
gem 'spring-watcher-listen', '~> 2.0.0'
56+
57+
# Linting and security tools
58+
gem 'rubocop', require: false
59+
gem 'brakeman', require: false
60+
gem 'bundler-audit', require: false
5661
end
5762

5863
group :test do

Gemfile.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ GEM
169169
net-protocol (0.2.2)
170170
timeout
171171
net-smtp (0.4.0.1)
172-
net-protocol
173172
nio4r (2.7.0)
173+
nokogiri (1.16.2-arm64-darwin)
174+
racc (~> 1.4)
174175
nokogiri (1.16.2-x86_64-linux)
175176
racc (~> 1.4)
176177
pg (1.5.5)
@@ -311,6 +312,7 @@ GEM
311312
zeitwerk (2.6.13)
312313

313314
PLATFORMS
315+
arm64-darwin-24
314316
x86_64-linux
315317

316318
DEPENDENCIES

0 commit comments

Comments
 (0)