Skip to content

Commit bc9bfc8

Browse files
committed
add more granular detection of rakelib & workflows
1 parent a8f30e9 commit bc9bfc8

File tree

8 files changed

+124
-100
lines changed

8 files changed

+124
-100
lines changed

.github/workflows/actionlint.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
inputs:
14+
force_run:
15+
description: 'Force run all jobs (bypass detect-changes)'
16+
required: false
17+
type: boolean
18+
default: false
19+
20+
jobs:
21+
actionlint:
22+
env:
23+
BUNDLE_FROZEN: true
24+
runs-on: ubuntu-22.04
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
# No need for history in lint job
29+
fetch-depth: 1
30+
persist-credentials: false
31+
# We only download and run Actionlint if there is any difference in GitHub Action workflows
32+
# https://github.com/rhysd/actionlint/blob/main/docs/usage.md#on-github-actions
33+
- name: Check GitHub Action changes
34+
id: check-workflows
35+
run: |
36+
git fetch origin ${{ github.event.pull_request.base.sha }}
37+
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q '^.github/workflows'; then
38+
echo "changed=true" >> "$GITHUB_OUTPUT"
39+
response=$(curl -sf https://api.github.com/repos/rhysd/actionlint/releases/latest)
40+
if [ $? -eq 0 ]; then
41+
actionlint_version=$(echo "$response" | jq -r .tag_name)
42+
if [ -z "$actionlint_version" ]; then
43+
echo "Failed to parse Actionlint version"
44+
exit 1
45+
fi
46+
echo "actionlint_version=\"$actionlint_version\"" >> "$GITHUB_OUTPUT"
47+
fi
48+
fi
49+
- name: Setup Actionlint
50+
if: steps.check-workflows.outputs.changed == 'true'
51+
uses: actions/cache@v4
52+
id: cache-actionlint
53+
with:
54+
path: ./actionlint
55+
key: ${{ runner.os }}-actionlint-${{ steps.check-workflows.outputs.actionlint_version }}
56+
- name: Download Actionlint
57+
if: steps.check-workflows.outputs.changed == 'true' && steps.cache-actionlint.outputs.cache-hit != 'true'
58+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
59+
- name: Lint GitHub Actions
60+
if: steps.check-workflows.outputs.changed == 'true'
61+
run: |
62+
echo "::add-matcher::.github/actionlint-matcher.json"
63+
SHELLCHECK_OPTS="-S warning" ./actionlint -color
64+
shell: bash
File renamed without changes.

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

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ jobs:
7979
uses: actions/setup-node@v4
8080
with:
8181
node-version: 22
82-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
83-
# Disable cache for Node 22 due to V8 bug in 22.21.0
84-
# Track: https://github.com/nodejs/node/issues/56010
85-
cache: ''
82+
cache: yarn
8683
cache-dependency-path: '**/yarn.lock'
8784
- name: Print system information
8885
run: |
@@ -152,35 +149,3 @@ jobs:
152149
run: yarn run publint --strict packages/react-on-rails/react-on-rails.tgz
153150
# We only download and run Actionlint if there is any difference in GitHub Action workflows
154151
# https://github.com/rhysd/actionlint/blob/main/docs/usage.md#on-github-actions
155-
- name: Check GitHub Action changes
156-
id: check-workflows
157-
run: |
158-
git fetch origin ${{ github.event.pull_request.base.sha }}
159-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q '^.github/workflows'; then
160-
echo "changed=true" >> "$GITHUB_OUTPUT"
161-
response=$(curl -sf https://api.github.com/repos/rhysd/actionlint/releases/latest)
162-
if [ $? -eq 0 ]; then
163-
actionlint_version=$(echo "$response" | jq -r .tag_name)
164-
if [ -z "$actionlint_version" ]; then
165-
echo "Failed to parse Actionlint version"
166-
exit 1
167-
fi
168-
echo "actionlint_version=\"$actionlint_version\"" >> "$GITHUB_OUTPUT"
169-
fi
170-
fi
171-
- name: Setup Actionlint
172-
if: steps.check-workflows.outputs.changed == 'true'
173-
uses: actions/cache@v4
174-
id: cache-actionlint
175-
with:
176-
path: ./actionlint
177-
key: ${{ runner.os }}-actionlint-${{ steps.check-workflows.outputs.actionlint_version }}
178-
- name: Download Actionlint
179-
if: steps.check-workflows.outputs.changed == 'true' && steps.cache-actionlint.outputs.cache-hit != 'true'
180-
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
181-
- name: Lint GitHub Actions
182-
if: steps.check-workflows.outputs.changed == 'true'
183-
run: |
184-
echo "::add-matcher::.github/actionlint-matcher.json"
185-
SHELLCHECK_OPTS="-S warning" ./actionlint -color
186-
shell: bash
File renamed without changes.

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ jobs:
8383
uses: actions/setup-node@v4
8484
with:
8585
node-version: 22
86-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
87-
# Disable cache for Node 22 due to V8 bug in 22.21.0
88-
# Track: https://github.com/nodejs/node/issues/56010
89-
cache: ''
86+
cache: yarn
9087
cache-dependency-path: 'react_on_rails_pro/**/yarn.lock'
9188

9289
- name: Print system information
@@ -173,10 +170,7 @@ jobs:
173170
uses: actions/setup-node@v4
174171
with:
175172
node-version: 22
176-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
177-
# Disable cache for Node 22 due to V8 bug in 22.21.0
178-
# Track: https://github.com/nodejs/node/issues/56010
179-
cache: ''
173+
cache: yarn
180174
cache-dependency-path: 'react_on_rails_pro/**/yarn.lock'
181175

182176
- name: Print system information
@@ -364,10 +358,7 @@ jobs:
364358
uses: actions/setup-node@v4
365359
with:
366360
node-version: 22
367-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
368-
# Disable cache for Node 22 due to V8 bug in 22.21.0
369-
# Track: https://github.com/nodejs/node/issues/56010
370-
cache: ''
361+
cache: yarn
371362
cache-dependency-path: 'react_on_rails_pro/**/yarn.lock'
372363

373364
- name: Print system information

.github/workflows/pro-lint.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ jobs:
8282
uses: actions/setup-node@v4
8383
with:
8484
node-version: 22
85-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
86-
# Disable cache for Node 22 due to V8 bug in 22.21.0
87-
# Track: https://github.com/nodejs/node/issues/56010
88-
cache: ''
85+
cache: yarn
8986
cache-dependency-path: 'react_on_rails_pro/**/yarn.lock'
9087

9188
- name: Print system information

.github/workflows/pro-gem-tests.yml renamed to .github/workflows/pro-test-package-and-gem.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ jobs:
8383
uses: actions/setup-node@v4
8484
with:
8585
node-version: 22
86-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
87-
# Disable cache for Node 22 due to V8 bug in 22.21.0
88-
# Track: https://github.com/nodejs/node/issues/56010
89-
cache: ''
86+
cache: yarn
9087
cache-dependency-path: 'react_on_rails_pro/**/yarn.lock'
9188

9289
- name: Print system information
@@ -178,10 +175,7 @@ jobs:
178175
uses: actions/setup-node@v4
179176
with:
180177
node-version: 22
181-
# TODO: Re-enable cache when Node.js 22 V8 bug is fixed
182-
# Disable cache for Node 22 due to V8 bug in 22.21.0
183-
# Track: https://github.com/nodejs/node/issues/56010
184-
cache: ''
178+
cache: yarn
185179
cache-dependency-path: 'react_on_rails_pro/**/yarn.lock'
186180

187181
- name: Print system information

script/ci-changes-detector

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ fi
5353

5454
# Initialize flags
5555
DOCS_ONLY=true
56-
RUBY_CHANGED=false
57-
JS_CHANGED=false
58-
GENERATORS_CHANGED=false
59-
WORKFLOWS_CHANGED=false
6056
LINT_CONFIG_CHANGED=false
61-
SPEC_DUMMY_CHANGED=false
57+
PRO_LINT_CONFIG_CHANGED=false
58+
RUBY_CHANGED=false
6259
RSPEC_CHANGED=false
63-
PRO_CHANGED=false
60+
SPEC_DUMMY_CHANGED=false
61+
JS_CHANGED=false
62+
GENERATORS_CHANGED=false # needs to be duplicated to pro
63+
PRO_RUBY_CHANGED=false
64+
PRO_RSPEC_CHANGED=false
65+
PRO_JS_CHANGED=false
6466
PRO_DUMMY_CHANGED=false
6567

6668
# Analyze each changed file
@@ -72,69 +74,69 @@ while IFS= read -r file; do
7274
;;
7375

7476
# Ruby source code
75-
lib/*.rb|lib/**/*.rb)
77+
lib/*.rb|lib/**/*.rb|Gemfile|Gemfile.lock|rakelib/run_rspec.rake|rakelib/node_package.rake|rakelib/dummy_apps.rake)
7678
DOCS_ONLY=false
7779
RUBY_CHANGED=true
7880
;;
7981

80-
# Ruby specs (except dummy app)
81-
spec/react_on_rails/*|spec/react_on_rails/**/*)
82+
# Ruby gem-specific specs
83+
spec/react_on_rails/*|spec/react_on_rails/**/*|.github/workflows/gem-tests.yml)
8284
DOCS_ONLY=false
83-
RUBY_CHANGED=true
8485
RSPEC_CHANGED=true
8586
;;
8687

8788
# Generators
88-
lib/generators/*|lib/generators/**/*|rakelib/example_type.rb|rakelib/example_config.yml|rakelib/examples.rake)
89+
lib/generators/*|lib/generators/**/*|rakelib/example_type.rb|rakelib/example_config.yml|rakelib/shakapacker_examples.rake|.github/workflows/examples.yml)
8990
DOCS_ONLY=false
9091
GENERATORS_CHANGED=true
9192
;;
9293

9394
# JavaScript/TypeScript source
94-
packages/react-on-rails/src/*|packages/react-on-rails/src/**/*|node_package/src/*|node_package/src/**/*)
95+
package.json|yarn.lock|packages/react-on-rails/src/*|packages/react-on-rails/src/**/*|.github/workflows/package-js-tests.yml)
9596
DOCS_ONLY=false
9697
JS_CHANGED=true
9798
;;
9899

99100
# Dummy app
100-
spec/dummy/*)
101+
spec/dummy/*|spec/dummy/**/*|.github/workflows/integration-tests.yml)
101102
DOCS_ONLY=false
102103
SPEC_DUMMY_CHANGED=true
103104
;;
104105

105-
# React on Rails Pro package / dummy app
106-
react_on_rails_pro/spec/dummy/*)
106+
# React on Rails Pro source code
107+
react_on_rails_pro/lib/*|react_on_rails_pro/lib/**/*)
107108
DOCS_ONLY=false
108-
PRO_CHANGED=true
109-
PRO_DUMMY_CHANGED=true
109+
PRO_RUBY_CHANGED=true
110110
;;
111-
react_on_rails_pro/*|react_on_rails_pro/**/*)
111+
112+
# JavaScript/TypeScript Pro source
113+
packages/react-on-rails-pro/src/*|packages/react-on-rails-pro/src/**/*)
112114
DOCS_ONLY=false
113-
PRO_CHANGED=true
115+
PRO_JS_CHANGED=true
114116
;;
115117

116-
# GitHub workflows
117-
.github/workflows/*|rakelib/*)
118+
# Ruby Pro gem-specific specs
119+
react_on_rails_pro/spec/react_on_rails/*|react_on_rails_pro/spec/react_on_rails/**/*|.github/workflows/pro-gem-tests.yml)
118120
DOCS_ONLY=false
119-
WORKFLOWS_CHANGED=true
121+
PRO_RSPEC_CHANGED=true
120122
;;
121123

122-
# Lint/format configuration
123-
.rubocop.yml|.eslintrc*|.prettierrc*|tsconfig.json|.editorconfig)
124+
# React on Rails Pro package / dummy app
125+
react_on_rails_pro/spec/dummy/*|react_on_rails_pro/spec/dummy/**/*|.github/workflows/pro-integration-tests.yml)
124126
DOCS_ONLY=false
125-
LINT_CONFIG_CHANGED=true
127+
PRO_DUMMY_CHANGED=true
126128
;;
127129

128-
# Gemfile, package.json, lockfiles
129-
Gemfile|Gemfile.lock|package.json|yarn.lock|spec/dummy/Gemfile|spec/dummy/Gemfile.lock|spec/dummy/package.json|spec/dummy/yarn.lock)
130+
# Lint/format configuration
131+
.rubocop.yml|.eslintrc*|.prettierrc*|tsconfig.json|.editorconfig|.github/workflows/lint-js-and-ruby.yml)
130132
DOCS_ONLY=false
131-
RUBY_CHANGED=true
132-
JS_CHANGED=true
133+
LINT_CONFIG_CHANGED=true
133134
;;
134135

135-
# Anything else is considered a code change
136-
*)
136+
# Lint/format configuration
137+
react_on_rails_pro/.rubocop.yml|react_on_rails_pro/.eslintrc*|react_on_rails_pro/.prettierrc*|react_on_rails_pro/tsconfig.json|react_on_rails_pro/.editorconfig|.github/workflows/pro-lint.yml)
137138
DOCS_ONLY=false
139+
PRO_LINT_CONFIG_CHANGED=true
138140
;;
139141
esac
140142
done <<< "$CHANGED_FILES"
@@ -154,15 +156,19 @@ if [ "$DOCS_ONLY" = true ]; then
154156
exit 0
155157
fi
156158

159+
# TODO: need to add node-renderer tests
157160
echo "Changed file categories:"
158161
[ "$RUBY_CHANGED" = true ] && echo -e "${YELLOW} • Ruby source code${NC}"
159162
[ "$JS_CHANGED" = true ] && echo -e "${YELLOW} • JavaScript/TypeScript code${NC}"
160-
[ "$GENERATORS_CHANGED" = true ] && echo -e "${YELLOW} • Generators${NC}"
161163
[ "$RSPEC_CHANGED" = true ] && echo -e "${YELLOW} • RSpec tests${NC}"
162164
[ "$SPEC_DUMMY_CHANGED" = true ] && echo -e "${YELLOW} • Dummy app${NC}"
163-
[ "$PRO_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro${NC}"
164-
[ "$WORKFLOWS_CHANGED" = true ] && echo -e "${YELLOW} • GitHub workflows${NC}"
165+
[ "$GENERATORS_CHANGED" = true ] && echo -e "${YELLOW} • Generators${NC}"
166+
[ "$PRO_JS_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro JavaScript/TypeScript${NC}"
167+
[ "$PRO_RSPEC_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro RSpec tests${NC}"
168+
[ "$PRO_RUBY_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro Ruby source code${NC}"
169+
[ "$PRO_DUMMY_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro Dummy app${NC}"
165170
[ "$LINT_CONFIG_CHANGED" = true ] && echo -e "${YELLOW} • Lint/format configuration${NC}"
171+
[ "$PRO_LINT_CONFIG_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro lint/format configuration${NC}"
166172

167173
echo ""
168174
echo "Recommended CI jobs:"
@@ -175,8 +181,9 @@ RUN_DUMMY_TESTS=false
175181
RUN_GENERATORS=false
176182
RUN_PRO_LINT=false
177183
RUN_PRO_TESTS=false
184+
RUN_PRO_DUMMY_TESTS=false
178185

179-
if [ "$LINT_CONFIG_CHANGED" = true ] || [ "$RUBY_CHANGED" = true ] || [ "$JS_CHANGED" = true ] || [ "$WORKFLOWS_CHANGED" = true ]; then
186+
if [ "$LINT_CONFIG_CHANGED" = true ] || [ "$RUBY_CHANGED" = true ] || [ "$JS_CHANGED" = true ] || [ "$SPEC_DUMMY_CHANGED" = true ]; then
180187
RUN_LINT=true
181188
fi
182189

@@ -196,22 +203,26 @@ if [ "$GENERATORS_CHANGED" = true ]; then
196203
RUN_GENERATORS=true
197204
fi
198205

199-
if [ "$PRO_CHANGED" = true ]; then
206+
if [ "$PRO_LINT_CONFIG_CHANGED" = true ] || [ "$PRO_RUBY_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ] || [ "$PRO_DUMMY_CHANGED" = true ]; then
200207
RUN_PRO_LINT=true
201-
RUN_PRO_TESTS=true
202208
fi
203209

204-
if [ "$PRO_DUMMY_CHANGED" = true ]; then
210+
if [ "$PRO_RUBY_CHANGED" = true ] || [ "$PRO_RSPEC_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ]; then
205211
RUN_PRO_TESTS=true
206212
fi
207213

214+
if [ "$PRO_DUMMY_CHANGED" = true ] || [ "$PRO_RUBY_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ]; then
215+
RUN_PRO_DUMMY_TESTS=true
216+
fi
217+
208218
[ "$RUN_LINT" = true ] && echo " ✓ Lint (Ruby + JS)"
209219
[ "$RUN_RUBY_TESTS" = true ] && echo " ✓ RSpec gem tests"
210220
[ "$RUN_JS_TESTS" = true ] && echo " ✓ JS unit tests"
211221
[ "$RUN_DUMMY_TESTS" = true ] && echo " ✓ Dummy app integration tests"
212222
[ "$RUN_GENERATORS" = true ] && echo " ✓ Generator tests"
213-
[ "$RUN_PRO_LINT" = true ] && echo " ✓ React on Rails Pro lint"
214-
[ "$RUN_PRO_TESTS" = true ] && echo " ✓ React on Rails Pro tests"
223+
[ "$RUN_PRO_LINT" = true ] && echo " ✓ React on Rails Pro Lint (Ruby + JS)"
224+
[ "$RUN_PRO_TESTS" = true ] && echo " ✓ React on Rails Pro RSpec unit tests (Ruby + JS)"
225+
[ "$RUN_PRO_DUMMY_TESTS" = true ] && echo " ✓ React on Rails Pro Dummy app integration tests"
215226

216227
# Export as GitHub Actions outputs if running in CI
217228
if [ -n "${GITHUB_OUTPUT:-}" ]; then
@@ -224,6 +235,7 @@ if [ -n "${GITHUB_OUTPUT:-}" ]; then
224235
echo "run_generators=$RUN_GENERATORS"
225236
echo "run_pro_lint=$RUN_PRO_LINT"
226237
echo "run_pro_tests=$RUN_PRO_TESTS"
238+
echo "run_pro_dummy_tests=$RUN_PRO_DUMMY_TESTS"
227239
} >> "$GITHUB_OUTPUT"
228240
fi
229241

@@ -239,6 +251,7 @@ if [ "${CI_JSON_OUTPUT:-}" = "1" ]; then
239251
"run_generators": $RUN_GENERATORS,
240252
"run_pro_lint": $RUN_PRO_LINT,
241253
"run_pro_tests": $RUN_PRO_TESTS
254+
"run_pro_dummy_tests": $RUN_PRO_DUMMY_TESTS
242255
}
243256
EOF
244257
fi

0 commit comments

Comments
 (0)