Skip to content

Commit 90f5032

Browse files
committed
Fix workflows to run RSpec with Kafka in a container
1 parent ff9ba6e commit 90f5032

16 files changed

+1055
-30
lines changed

.github/workflows/rails_graphql_federation_jwts_ci.yml

+56-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
paths: [ rails_graphql_federation/jwts/** ]
88
workflow_dispatch:
99

10+
env:
11+
rails_app_root: rails_graphql_federation/jwts
12+
CI: true
13+
1014
jobs:
1115
scan_ruby:
1216
runs-on: ubuntu-latest
@@ -18,13 +22,12 @@ jobs:
1822
- name: Set up Ruby
1923
uses: ruby/setup-ruby@v1
2024
with:
21-
working-directory: rails_graphql_federation/jwts
22-
ruby-version: .ruby-version
25+
working-directory: ${{ env.rails_app_root }}
2326
bundler-cache: true
2427

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

4446
- name: Lint code for consistent style
4547
run: |
46-
cd rails_graphql_federation/jwts
48+
cd ${{ env.rails_app_root }}
4749
./bin/rubocop -f github
50+
51+
build:
52+
53+
runs-on: ubuntu-latest
54+
permissions:
55+
contents: read
56+
57+
services:
58+
kafka:
59+
image: bitnami/kafka:latest
60+
env:
61+
KAFKA_ENABLE_KRAFT: yes
62+
KAFKA_CFG_PROCESS_ROLES: broker,controller
63+
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
64+
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
65+
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
66+
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
67+
KAFKA_CFG_NODE_ID: 1
68+
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: [email protected]:9093
69+
ALLOW_PLAINTEXT_LISTENER: yes
70+
KAFKA_CFG_NUM_PARTITIONS: 4
71+
KAFKA_CFG_OFFSETS_TOPIC_NUM_PARTITIONS: 1
72+
KAFKA_CFG_TRANSACTION_STATE_LOG_NUM_PARTITIONS: 1
73+
KAFKA_CFG_LOG_RETENTION_BYTES: -1
74+
KAFKA_CFG_LOG_RETENTION_HOURS: -1
75+
ports:
76+
- "9092:9092"
77+
78+
steps:
79+
- name: Checkout the repo
80+
uses: actions/checkout@v4
81+
82+
- name: Set up Ruby
83+
uses: ruby/setup-ruby@v1
84+
with:
85+
working-directory: ${{ env.rails_app_root }}
86+
bundler-cache: true
87+
88+
- name: Run RSpec
89+
run: |
90+
cd ${{ env.rails_app_root }}
91+
./bin/rspec --format json --out tmp/rspec_results.json
92+
93+
- name: Generate RSpec report
94+
uses: SonicGarden/rspec-report-action@v5
95+
with:
96+
json-path: ${{ env.rails_app_root }}/tmp/rspec_results.json
97+
if: always()

.github/workflows/rails_graphql_federation_reviews_ci.yml

+56-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
paths: [ rails_graphql_federation/reviews/** ]
88
workflow_dispatch:
99

10+
env:
11+
rails_app_root: rails_graphql_federation/reviews
12+
CI: true
13+
1014
jobs:
1115
scan_ruby:
1216
runs-on: ubuntu-latest
@@ -18,13 +22,12 @@ jobs:
1822
- name: Set up Ruby
1923
uses: ruby/setup-ruby@v1
2024
with:
21-
working-directory: rails_graphql_federation/reviews
22-
ruby-version: .ruby-version
25+
working-directory: ${{ env.rails_app_root }}
2326
bundler-cache: true
2427

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

4446
- name: Lint code for consistent style
4547
run: |
46-
cd rails_graphql_federation/reviews
48+
cd ${{ env.rails_app_root }}
4749
./bin/rubocop -f github
50+
51+
build:
52+
53+
runs-on: ubuntu-latest
54+
permissions:
55+
contents: read
56+
57+
services:
58+
kafka:
59+
image: bitnami/kafka:latest
60+
env:
61+
KAFKA_ENABLE_KRAFT: yes
62+
KAFKA_CFG_PROCESS_ROLES: broker,controller
63+
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
64+
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
65+
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
66+
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
67+
KAFKA_CFG_NODE_ID: 1
68+
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: [email protected]:9093
69+
ALLOW_PLAINTEXT_LISTENER: yes
70+
KAFKA_CFG_NUM_PARTITIONS: 4
71+
KAFKA_CFG_OFFSETS_TOPIC_NUM_PARTITIONS: 1
72+
KAFKA_CFG_TRANSACTION_STATE_LOG_NUM_PARTITIONS: 1
73+
KAFKA_CFG_LOG_RETENTION_BYTES: -1
74+
KAFKA_CFG_LOG_RETENTION_HOURS: -1
75+
ports:
76+
- "9092:9092"
77+
78+
steps:
79+
- name: Checkout the repo
80+
uses: actions/checkout@v4
81+
82+
- name: Set up Ruby
83+
uses: ruby/setup-ruby@v1
84+
with:
85+
working-directory: ${{ env.rails_app_root }}
86+
bundler-cache: true
87+
88+
- name: Run RSpec
89+
run: |
90+
cd ${{ env.rails_app_root }}
91+
./bin/rspec --format json --out tmp/rspec_results.json
92+
93+
- name: Generate RSpec report
94+
uses: SonicGarden/rspec-report-action@v5
95+
with:
96+
json-path: ${{ env.rails_app_root }}/tmp/rspec_results.json
97+
if: always()

.github/workflows/rails_graphql_federation_search_ci.yml

+56-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
paths: [ rails_graphql_federation/search/** ]
88
workflow_dispatch:
99

10+
env:
11+
rails_app_root: rails_graphql_federation/search
12+
CI: true
13+
1014
jobs:
1115
scan_ruby:
1216
runs-on: ubuntu-latest
@@ -18,13 +22,12 @@ jobs:
1822
- name: Set up Ruby
1923
uses: ruby/setup-ruby@v1
2024
with:
21-
working-directory: rails_graphql_federation/search
22-
ruby-version: .ruby-version
25+
working-directory: ${{ env.rails_app_root }}
2326
bundler-cache: true
2427

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

4446
- name: Lint code for consistent style
4547
run: |
46-
cd rails_graphql_federation/search
48+
cd ${{ env.rails_app_root }}
4749
./bin/rubocop -f github
50+
51+
build:
52+
53+
runs-on: ubuntu-latest
54+
permissions:
55+
contents: read
56+
57+
services:
58+
kafka:
59+
image: bitnami/kafka:latest
60+
env:
61+
KAFKA_ENABLE_KRAFT: yes
62+
KAFKA_CFG_PROCESS_ROLES: broker,controller
63+
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
64+
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
65+
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
66+
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
67+
KAFKA_CFG_NODE_ID: 1
68+
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: [email protected]:9093
69+
ALLOW_PLAINTEXT_LISTENER: yes
70+
KAFKA_CFG_NUM_PARTITIONS: 4
71+
KAFKA_CFG_OFFSETS_TOPIC_NUM_PARTITIONS: 1
72+
KAFKA_CFG_TRANSACTION_STATE_LOG_NUM_PARTITIONS: 1
73+
KAFKA_CFG_LOG_RETENTION_BYTES: -1
74+
KAFKA_CFG_LOG_RETENTION_HOURS: -1
75+
ports:
76+
- "9092:9092"
77+
78+
steps:
79+
- name: Checkout the repo
80+
uses: actions/checkout@v4
81+
82+
- name: Set up Ruby
83+
uses: ruby/setup-ruby@v1
84+
with:
85+
working-directory: ${{ env.rails_app_root }}
86+
bundler-cache: true
87+
88+
- name: Run RSpec
89+
run: |
90+
cd ${{ env.rails_app_root }}
91+
./bin/rspec --format json --out tmp/rspec_results.json
92+
93+
- name: Generate RSpec report
94+
uses: SonicGarden/rspec-report-action@v5
95+
with:
96+
json-path: ${{ env.rails_app_root }}/tmp/rspec_results.json
97+
if: always()

.github/workflows/rails_graphql_federation_signatures_ci.yml

+35-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
paths: [ rails_graphql_federation/signatures/** ]
88
workflow_dispatch:
99

10+
env:
11+
rails_app_root: rails_graphql_federation/signatures
12+
CI: true
13+
1014
jobs:
1115
scan_ruby:
1216
runs-on: ubuntu-latest
@@ -18,13 +22,12 @@ jobs:
1822
- name: Set up Ruby
1923
uses: ruby/setup-ruby@v1
2024
with:
21-
working-directory: rails_graphql_federation/signatures
22-
ruby-version: .ruby-version
25+
working-directory: ${{ env.rails_app_root }}
2326
bundler-cache: true
2427

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

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

rails_graphql_federation/jwts/config/initializers/phobos.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Rails.application.configure do
2-
Phobos.configure("config/phobos.yml")
2+
if ENV["CI"].present?
3+
Phobos.configure("config/phobos.ci.yml")
4+
else
5+
Phobos.configure("config/phobos.yml")
6+
end
37

48
group_id = SecureRandom.uuid
59

0 commit comments

Comments
 (0)