Skip to content

Commit 1fb0155

Browse files
committed
Run RSpec as part of Rails builds
Extract repetitive path to variable
1 parent f7f17db commit 1fb0155

3 files changed

+75
-16
lines changed

.github/workflows/rails_graphql_federation_books_ci.yml

+34-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
paths: [ rails_graphql_federation/books/** ]
88
workflow_dispatch:
99

10+
env:
11+
rails_app_root: rails_graphql_federation/books
12+
1013
jobs:
1114
scan_ruby:
1215
runs-on: ubuntu-latest
@@ -18,13 +21,12 @@ jobs:
1821
- name: Set up Ruby
1922
uses: ruby/setup-ruby@v1
2023
with:
21-
working-directory: rails_graphql_federation/books
22-
ruby-version: .ruby-version
24+
working-directory: ${{ env.rails_app_root }}
2325
bundler-cache: true
2426

2527
- name: Scan for common Rails security vulnerabilities using static analysis
2628
run: |
27-
cd rails_graphql_federation/books
29+
cd ${{ env.rails_app_root }}
2830
./bin/brakeman --no-pager
2931
3032
lint:
@@ -37,11 +39,37 @@ jobs:
3739
- name: Set up Ruby
3840
uses: ruby/setup-ruby@v1
3941
with:
40-
working-directory: rails_graphql_federation/books
41-
ruby-version: .ruby-version
42+
working-directory: ${{ env.rails_app_root }}
4243
bundler-cache: true
4344

4445
- name: Lint code for consistent style
4546
run: |
46-
cd rails_graphql_federation/books
47+
cd ${{ env.rails_app_root }}
4748
./bin/rubocop -f github
49+
50+
build:
51+
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: read
55+
56+
steps:
57+
- name: Checkout the repo
58+
uses: actions/checkout@v4
59+
60+
- name: Set up Ruby
61+
uses: ruby/setup-ruby@v1
62+
with:
63+
working-directory: ${{ env.rails_app_root }}
64+
bundler-cache: true
65+
66+
- name: Run RSpec
67+
run: |
68+
cd ${{ env.rails_app_root }}
69+
./bin/rspec --format json --out tmp/rspec_results.json
70+
71+
- name: Generate RSpec report
72+
uses: SonicGarden/rspec-report-action@v5
73+
with:
74+
json-path: ${{ env.rails_app_root }}/tmp/rspec_results.json
75+
if: always()

.github/workflows/rails_graphql_federation_users_ci.yml

+34-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
paths: [ rails_graphql_federation/users/** ]
88
workflow_dispatch:
99

10+
env:
11+
rails_app_root: rails_graphql_federation/users
12+
1013
jobs:
1114
scan_ruby:
1215
runs-on: ubuntu-latest
@@ -18,13 +21,12 @@ jobs:
1821
- name: Set up Ruby
1922
uses: ruby/setup-ruby@v1
2023
with:
21-
working-directory: rails_graphql_federation/users
22-
ruby-version: .ruby-version
24+
working-directory: ${{ env.rails_app_root }}
2325
bundler-cache: true
2426

2527
- name: Scan for common Rails security vulnerabilities using static analysis
2628
run: |
27-
cd rails_graphql_federation/users
29+
cd ${{ env.rails_app_root }}
2830
./bin/brakeman --no-pager
2931
3032
lint:
@@ -37,11 +39,37 @@ jobs:
3739
- name: Set up Ruby
3840
uses: ruby/setup-ruby@v1
3941
with:
40-
working-directory: rails_graphql_federation/users
41-
ruby-version: .ruby-version
42+
working-directory: ${{ env.rails_app_root }}
4243
bundler-cache: true
4344

4445
- name: Lint code for consistent style
4546
run: |
46-
cd rails_graphql_federation/users
47+
cd ${{ env.rails_app_root }}
4748
./bin/rubocop -f github
49+
50+
build:
51+
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: read
55+
56+
steps:
57+
- name: Checkout the repo
58+
uses: actions/checkout@v4
59+
60+
- name: Set up Ruby
61+
uses: ruby/setup-ruby@v1
62+
with:
63+
working-directory: ${{ env.rails_app_root }}
64+
bundler-cache: true
65+
66+
- name: Run RSpec
67+
run: |
68+
cd ${{ env.rails_app_root }}
69+
./bin/rspec --format json --out tmp/rspec_results.json
70+
71+
- name: Generate RSpec report
72+
uses: SonicGarden/rspec-report-action@v5
73+
with:
74+
json-path: ${{ env.rails_app_root }}/tmp/rspec_results.json
75+
if: always()

.github/workflows/rails_mysql_ci.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
paths: [ rails_mysql/** ]
88
workflow_dispatch:
99

10+
env:
11+
rails_app_root: rails_mysql
12+
1013
jobs:
1114
scan_ruby:
1215
runs-on: ubuntu-latest
@@ -18,13 +21,13 @@ jobs:
1821
- name: Set up Ruby
1922
uses: ruby/setup-ruby@v1
2023
with:
21-
working-directory: rails_mysql
24+
working-directory: ${{ env.rails_app_root }}
2225
ruby-version: .ruby-version
2326
bundler-cache: true
2427

2528
- name: Scan for common Rails security vulnerabilities using static analysis
2629
run: |
27-
cd rails_mysql
30+
cd ${{ env.rails_app_root }}
2831
./bin/brakeman --no-pager
2932
3033
lint:
@@ -37,11 +40,11 @@ jobs:
3740
- name: Set up Ruby
3841
uses: ruby/setup-ruby@v1
3942
with:
40-
working-directory: rails_mysql
43+
working-directory: ${{ env.rails_app_root }}
4144
ruby-version: .ruby-version
4245
bundler-cache: true
4346

4447
- name: Lint code for consistent style
4548
run: |
46-
cd rails_mysql
49+
cd ${{ env.rails_app_root }}
4750
./bin/rubocop -f github

0 commit comments

Comments
 (0)