Skip to content

Commit cf005af

Browse files
Enhance change detection & workflow triggers (#2020)
Seeing if I can reproduce the CI results for 0b4dd06 Really just running over a lot of [Chesterton's fences](https://fs.blog/chestertons-fence/#:~:text=In%20its%20most%20concise%20version,a%20similar%20point%2C%20detailed%20here:) in order to refamiliarize myself with the codebase, especially CI. <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/2020) <!-- Reviewable:end --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Improved CI caching for faster runs and updated trigger filters to skip docs and Pro-only paths. * Refined change-detection with more granular Pro-specific gating to avoid unnecessary jobs. * Adjusted integration testing matrix and trigger conditions for clearer job selection. * **New Features** * Added a manual "force run" workflow input to trigger full CI when needed. * Introduced a dedicated workflow for linting GitHub Actions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent dca30af commit cf005af

File tree

11 files changed

+226
-138
lines changed

11 files changed

+226
-138
lines changed

.github/workflows/actionlint.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Lint JS and Ruby
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
paths:
8+
- '.github/workflows/**'
9+
pull_request:
10+
paths:
11+
- '.github/workflows/**'
12+
workflow_dispatch:
13+
14+
jobs:
15+
actionlint:
16+
env:
17+
BUNDLE_FROZEN: true
18+
runs-on: ubuntu-22.04
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
# No need for history in lint job
23+
fetch-depth: 1
24+
persist-credentials: false
25+
# We only download and run Actionlint if there is any difference in GitHub Action workflows
26+
# https://github.com/rhysd/actionlint/blob/main/docs/usage.md#on-github-actions
27+
- name: Check GitHub Action changes
28+
id: check-workflows
29+
run: |
30+
BASE_SHA="${{ github.event.pull_request.base.sha || github.event.before }}"
31+
if [ -n "$BASE_SHA" ]; then
32+
git fetch origin "$BASE_SHA" 2>/dev/null || true
33+
fi
34+
35+
# For PRs, diff against base; for pushes, use before commit
36+
if [ -n "${{ github.event.pull_request.base.sha }}" ]; then
37+
DIFF_BASE="${{ github.event.pull_request.base.sha }}"
38+
else
39+
DIFF_BASE="${{ github.event.before }}"
40+
fi
41+
42+
# Handle initial commits where before SHA is all zeros
43+
if [[ "$DIFF_BASE" =~ ^0+$ ]]; then
44+
DIFF_BASE="origin/master"
45+
fi
46+
47+
if git diff --name-only "$DIFF_BASE" ${{ github.sha }} 2>/dev/null | grep -q '^.github/workflows'; then
48+
echo "changed=true" >> "$GITHUB_OUTPUT"
49+
response=$(curl -sf https://api.github.com/repos/rhysd/actionlint/releases/latest)
50+
if [ $? -eq 0 ]; then
51+
actionlint_version=$(echo "$response" | jq -r .tag_name)
52+
if [ -z "$actionlint_version" ]; then
53+
echo "Failed to parse Actionlint version"
54+
exit 1
55+
fi
56+
echo "actionlint_version=\"$actionlint_version\"" >> "$GITHUB_OUTPUT"
57+
fi
58+
fi
59+
- name: Setup Actionlint
60+
if: steps.check-workflows.outputs.changed == 'true'
61+
uses: actions/cache@v4
62+
id: cache-actionlint
63+
with:
64+
path: ./actionlint
65+
key: ${{ runner.os }}-actionlint-${{ steps.check-workflows.outputs.actionlint_version }}
66+
- name: Download Actionlint
67+
if: steps.check-workflows.outputs.changed == 'true' && steps.cache-actionlint.outputs.cache-hit != 'true'
68+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
69+
- name: Lint GitHub Actions
70+
if: steps.check-workflows.outputs.changed == 'true'
71+
run: |
72+
echo "::add-matcher::.github/actionlint-matcher.json"
73+
SHELLCHECK_OPTS="-S warning" ./actionlint -color
74+
shell: bash

.github/workflows/examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Generator tests
1+
name: Generator tests # TODO needs to be duplicated for RoR Pro
22

33
on:
44
push:

.github/workflows/rspec-package-specs.yml renamed to .github/workflows/gem-tests.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ on:
77
paths-ignore:
88
- '**.md'
99
- 'docs/**'
10-
- 'packages/react-on-rails/src/**'
11-
- 'node_package/src/**'
10+
- 'packages/**'
11+
- 'react_on_rails_pro/**'
1212
pull_request:
1313
paths-ignore:
1414
- '**.md'
1515
- 'docs/**'
16-
- 'packages/react-on-rails/src/**'
17-
- 'node_package/src/**'
16+
- 'packages/**'
17+
- 'react_on_rails_pro/**'
1818
workflow_dispatch:
19+
inputs:
20+
force_run:
21+
description: 'Force run all jobs (bypass detect-changes)'
22+
required: false
23+
type: boolean
24+
default: false
1925

2026
jobs:
2127
detect-changes:
@@ -40,8 +46,8 @@ jobs:
4046
- name: Detect relevant changes
4147
id: detect
4248
run: |
43-
# If full-ci label is present, run everything
44-
if [ "${{ steps.check-label.outputs.result }}" = "true" ]; then
49+
# If force_run is true OR full-ci label is present, run everything
50+
if [ "${{ inputs.force_run }}" = "true" ] || [ "${{ steps.check-label.outputs.result }}" = "true" ]; then
4551
echo "run_lint=true" >> "$GITHUB_OUTPUT"
4652
echo "run_js_tests=true" >> "$GITHUB_OUTPUT"
4753
echo "run_ruby_tests=true" >> "$GITHUB_OUTPUT"

.github/workflows/main.yml renamed to .github/workflows/integration-tests.yml

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Main test
1+
name: Integration Tests
22

33
on:
44
push:
@@ -7,10 +7,12 @@ on:
77
paths-ignore:
88
- '**.md'
99
- 'docs/**'
10+
- 'react_on_rails_pro/**'
1011
pull_request:
1112
paths-ignore:
1213
- '**.md'
1314
- 'docs/**'
15+
- 'react_on_rails_pro/**'
1416
workflow_dispatch:
1517
inputs:
1618
force_run:
@@ -50,11 +52,10 @@ jobs:
5052
echo "run_dummy_tests=true" >> "$GITHUB_OUTPUT"
5153
echo "run_generators=true" >> "$GITHUB_OUTPUT"
5254
echo "docs_only=false" >> "$GITHUB_OUTPUT"
53-
exit 0
54-
fi
55-
56-
BASE_REF="${{ github.event.pull_request.base.sha || github.event.before || 'origin/master' }}"
55+
else
56+
BASE_REF="${{ github.event.pull_request.base.sha || github.event.before || 'origin/master' }}"
5757
script/ci-changes-detector "$BASE_REF"
58+
fi
5859
shell: bash
5960

6061
build-dummy-app-webpack-test-bundles:
@@ -64,20 +65,14 @@ jobs:
6465
github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_dummy_tests == 'true'
6566
strategy:
6667
matrix:
68+
ruby-version: ['3.4']
69+
node-version: ['22']
70+
dependency-level: ['latest']
6771
include:
68-
# Always run: Latest versions (fast feedback on PRs)
69-
- ruby-version: '3.4'
70-
node-version: '22'
71-
dependency-level: 'latest'
72-
# Master and workflow_dispatch: Minimum supported versions (full coverage)
73-
- ruby-version: '3.2'
74-
node-version: '20'
75-
dependency-level: 'minimum'
76-
exclude:
7772
# Skip minimum dependency matrix on regular PRs (run only on master/workflow_dispatch/force_run/full-ci label)
78-
- ruby-version: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && inputs.force_run != true && needs.detect-changes.outputs.has_full_ci_label != 'true' && '3.2' || '' }}
79-
node-version: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && inputs.force_run != true && needs.detect-changes.outputs.has_full_ci_label != 'true' && '20' || '' }}
80-
dependency-level: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && inputs.force_run != true && needs.detect-changes.outputs.has_full_ci_label != 'true' && 'minimum' || '' }}
73+
- ruby-version: ${{ (github.ref == 'refs/heads/master' || inputs.force_run == true || needs.detect-changes.outputs.has_full_ci_label == 'true') && '3.2'}}
74+
node-version: ${{ (github.ref == 'refs/heads/master' || inputs.force_run == true || needs.detect-changes.outputs.has_full_ci_label == 'true') && '20'}}
75+
dependency-level: ${{ (github.ref == 'refs/heads/master' || inputs.force_run == true || needs.detect-changes.outputs.has_full_ci_label == 'true') && 'minimum'}}
8176
runs-on: ubuntu-22.04
8277
steps:
8378
- uses: actions/checkout@v4
@@ -152,17 +147,15 @@ jobs:
152147
if: |
153148
github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_dummy_tests == 'true'
154149
strategy:
155-
fail-fast: false
156150
matrix:
151+
ruby-version: ['3.4']
152+
node-version: ['22']
153+
dependency-level: ['latest']
157154
include:
158-
# Always run: Latest versions (fast feedback on PRs)
159-
- ruby-version: '3.4'
160-
node-version: '22'
161-
dependency-level: 'latest'
162-
# Master and workflow_dispatch: Minimum supported versions (full coverage)
163-
- ruby-version: '3.2'
164-
node-version: '20'
165-
dependency-level: 'minimum'
155+
# Skip minimum dependency matrix on regular PRs (run only on master/workflow_dispatch/force_run/full-ci label)
156+
- ruby-version: ${{ (github.ref == 'refs/heads/master' || inputs.force_run == true || needs.detect-changes.outputs.has_full_ci_label == 'true') && '3.2'}}
157+
node-version: ${{ (github.ref == 'refs/heads/master' || inputs.force_run == true || needs.detect-changes.outputs.has_full_ci_label == 'true') && '20'}}
158+
dependency-level: ${{ (github.ref == 'refs/heads/master' || inputs.force_run == true || needs.detect-changes.outputs.has_full_ci_label == 'true') && 'minimum'}}
166159
exclude:
167160
# Skip minimum dependency matrix on regular PRs (run only on master/workflow_dispatch/force_run/full-ci label)
168161
- ruby-version: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && inputs.force_run != true && needs.detect-changes.outputs.has_full_ci_label != 'true' && '3.2' || '' }}

.github/workflows/lint-js-and-ruby.yml

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ on:
77
paths-ignore:
88
- '**.md'
99
- 'docs/**'
10+
- 'react_on_rails_pro/**'
1011
pull_request:
1112
paths-ignore:
1213
- '**.md'
1314
- 'docs/**'
15+
- 'react_on_rails_pro/**'
1416
workflow_dispatch:
17+
inputs:
18+
force_run:
19+
description: 'Force run all jobs (bypass detect-changes)'
20+
required: false
21+
type: boolean
22+
default: false
1523

1624
jobs:
1725
detect-changes:
@@ -35,8 +43,8 @@ jobs:
3543
- name: Detect relevant changes
3644
id: detect
3745
run: |
38-
# If full-ci label is present, run everything
39-
if [ "${{ steps.check-label.outputs.result }}" = "true" ]; then
46+
# If force_run is true OR full-ci label is present, run everything
47+
if [ "${{ inputs.force_run }}" = "true" ] || [ "${{ steps.check-label.outputs.result }}" = "true" ]; then
4048
echo "run_lint=true" >> "$GITHUB_OUTPUT"
4149
echo "run_js_tests=true" >> "$GITHUB_OUTPUT"
4250
echo "run_ruby_tests=true" >> "$GITHUB_OUTPUT"
@@ -71,10 +79,7 @@ jobs:
7179
uses: actions/setup-node@v4
7280
with:
7381
node-version: 22
74-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
75-
# Disable cache for Node 22 due to V8 bug in 22.21.0
76-
# Track: https://github.com/nodejs/node/issues/56010
77-
cache: ''
82+
cache: yarn
7883
cache-dependency-path: '**/yarn.lock'
7984
- name: Print system information
8085
run: |
@@ -144,35 +149,3 @@ jobs:
144149
run: yarn run publint --strict packages/react-on-rails/react-on-rails.tgz
145150
# We only download and run Actionlint if there is any difference in GitHub Action workflows
146151
# https://github.com/rhysd/actionlint/blob/main/docs/usage.md#on-github-actions
147-
- name: Check GitHub Action changes
148-
id: check-workflows
149-
run: |
150-
git fetch origin ${{ github.event.pull_request.base.sha }}
151-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q '^.github/workflows'; then
152-
echo "changed=true" >> "$GITHUB_OUTPUT"
153-
response=$(curl -sf https://api.github.com/repos/rhysd/actionlint/releases/latest)
154-
if [ $? -eq 0 ]; then
155-
actionlint_version=$(echo "$response" | jq -r .tag_name)
156-
if [ -z "$actionlint_version" ]; then
157-
echo "Failed to parse Actionlint version"
158-
exit 1
159-
fi
160-
echo "actionlint_version=\"$actionlint_version\"" >> "$GITHUB_OUTPUT"
161-
fi
162-
fi
163-
- name: Setup Actionlint
164-
if: steps.check-workflows.outputs.changed == 'true'
165-
uses: actions/cache@v4
166-
id: cache-actionlint
167-
with:
168-
path: ./actionlint
169-
key: ${{ runner.os }}-actionlint-${{ steps.check-workflows.outputs.actionlint_version }}
170-
- name: Download Actionlint
171-
if: steps.check-workflows.outputs.changed == 'true' && steps.cache-actionlint.outputs.cache-hit != 'true'
172-
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
173-
- name: Lint GitHub Actions
174-
if: steps.check-workflows.outputs.changed == 'true'
175-
run: |
176-
echo "::add-matcher::.github/actionlint-matcher.json"
177-
SHELLCHECK_OPTS="-S warning" ./actionlint -color
178-
shell: bash

.github/workflows/package-js-tests.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ on:
99
- 'docs/**'
1010
- 'lib/**'
1111
- 'spec/react_on_rails/**'
12+
- 'react_on_rails_pro/**'
1213
pull_request:
1314
paths-ignore:
1415
- '**.md'
1516
- 'docs/**'
1617
- 'lib/**'
1718
- 'spec/react_on_rails/**'
19+
- 'react_on_rails_pro/**'
1820
workflow_dispatch:
21+
inputs:
22+
force_run:
23+
description: 'Force run all jobs (bypass detect-changes)'
24+
required: false
25+
type: boolean
26+
default: false
1927

2028
jobs:
2129
detect-changes:
@@ -40,8 +48,8 @@ jobs:
4048
- name: Detect relevant changes
4149
id: detect
4250
run: |
43-
# If full-ci label is present, run everything
44-
if [ "${{ steps.check-label.outputs.result }}" = "true" ]; then
51+
# If force_run is true OR full-ci label is present, run everything
52+
if [ "${{ inputs.force_run }}" = "true" ] || [ "${{ steps.check-label.outputs.result }}" = "true" ]; then
4553
echo "run_lint=true" >> "$GITHUB_OUTPUT"
4654
echo "run_js_tests=true" >> "$GITHUB_OUTPUT"
4755
echo "run_ruby_tests=true" >> "$GITHUB_OUTPUT"

.github/workflows/playwright.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Playwright E2E Tests
33
on:
44
push:
55
branches: [master]
6+
paths-ignore:
7+
- '**.md'
8+
- 'docs/**'
69
workflow_dispatch:
710

811
jobs:

.github/workflows/pro-integration-tests.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ on:
44
push:
55
branches:
66
- 'master'
7+
paths-ignore:
8+
- '**.md'
9+
- 'docs/**'
10+
- 'lib/**'
11+
- 'spec/**'
12+
- 'packages/react_on_rails/**'
713
pull_request:
14+
paths-ignore:
15+
- '**.md'
16+
- 'docs/**'
17+
- 'lib/**'
18+
- 'spec/**'
19+
- 'packages/react_on_rails/**'
820
workflow_dispatch:
921
inputs:
1022
force_run:
@@ -71,10 +83,7 @@ jobs:
7183
uses: actions/setup-node@v4
7284
with:
7385
node-version: 22
74-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
75-
# Disable cache for Node 22 due to V8 bug in 22.21.0
76-
# Track: https://github.com/nodejs/node/issues/56010
77-
cache: ''
86+
cache: yarn
7887
cache-dependency-path: 'react_on_rails_pro/**/yarn.lock'
7988

8089
- name: Print system information
@@ -161,10 +170,7 @@ jobs:
161170
uses: actions/setup-node@v4
162171
with:
163172
node-version: 22
164-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
165-
# Disable cache for Node 22 due to V8 bug in 22.21.0
166-
# Track: https://github.com/nodejs/node/issues/56010
167-
cache: ''
173+
cache: yarn
168174
cache-dependency-path: 'react_on_rails_pro/**/yarn.lock'
169175

170176
- name: Print system information
@@ -352,10 +358,7 @@ jobs:
352358
uses: actions/setup-node@v4
353359
with:
354360
node-version: 22
355-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
356-
# Disable cache for Node 22 due to V8 bug in 22.21.0
357-
# Track: https://github.com/nodejs/node/issues/56010
358-
cache: ''
361+
cache: yarn
359362
cache-dependency-path: 'react_on_rails_pro/**/yarn.lock'
360363

361364
- name: Print system information

0 commit comments

Comments
 (0)