|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - 'master' |
| 7 | + paths-ignore: |
| 8 | + - '**.md' |
| 9 | + - 'docs/**' |
7 | 10 | pull_request: |
| 11 | + paths-ignore: |
| 12 | + - '**.md' |
| 13 | + - 'docs/**' |
8 | 14 |
|
9 | 15 | jobs: |
| 16 | + detect-changes: |
| 17 | + runs-on: ubuntu-22.04 |
| 18 | + outputs: |
| 19 | + docs_only: ${{ steps.detect.outputs.docs_only }} |
| 20 | + run_lint: ${{ steps.detect.outputs.run_lint }} |
| 21 | + run_js_tests: ${{ steps.detect.outputs.run_js_tests }} |
| 22 | + run_ruby_tests: ${{ steps.detect.outputs.run_ruby_tests }} |
| 23 | + run_dummy_tests: ${{ steps.detect.outputs.run_dummy_tests }} |
| 24 | + run_generators: ${{ steps.detect.outputs.run_generators }} |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + persist-credentials: false |
| 30 | + - name: Detect relevant changes |
| 31 | + id: detect |
| 32 | + run: | |
| 33 | + BASE_REF="${{ github.event.pull_request.base.sha || github.event.before || 'origin/master' }}" |
| 34 | + script/ci-changes-detector "$BASE_REF" |
| 35 | + shell: bash |
| 36 | + |
10 | 37 | examples: |
| 38 | + needs: detect-changes |
| 39 | + if: github.ref == 'refs/heads/master' || needs.detect-changes.outputs.run_generators == 'true' |
11 | 40 | strategy: |
12 | 41 | fail-fast: false |
13 | 42 | matrix: |
14 | | - ruby-version: ['3.2', '3.4'] |
15 | | - dependency-level: ['minimum', 'latest'] |
| 43 | + # On master: test both minimum and latest. On PRs: test only latest for speed |
| 44 | + ruby-version: ${{ github.ref == 'refs/heads/master' && fromJSON('["3.2", "3.4"]') || fromJSON('["3.4"]') }} |
| 45 | + dependency-level: ${{ github.ref == 'refs/heads/master' && fromJSON('["minimum", "latest"]') || fromJSON('["latest"]') }} |
16 | 46 | include: |
17 | 47 | - ruby-version: '3.2' |
18 | 48 | dependency-level: 'minimum' |
|
23 | 53 | dependency-level: 'latest' |
24 | 54 | - ruby-version: '3.4' |
25 | 55 | dependency-level: 'minimum' |
| 56 | + # On PRs, exclude the minimum dependency combination to run faster |
| 57 | + - ruby-version: ${{ github.ref != 'refs/heads/master' && '3.2' || 'none' }} |
| 58 | + dependency-level: 'minimum' |
26 | 59 | env: |
27 | 60 | SKIP_YARN_COREPACK_CHECK: 0 |
28 | 61 | BUNDLE_FROZEN: ${{ matrix.dependency-level == 'minimum' && 'false' || 'true' }} |
|
31 | 64 | - uses: actions/checkout@v4 |
32 | 65 | with: |
33 | 66 | persist-credentials: false |
34 | | - - name: Get changed files |
35 | | - id: changed-files |
36 | | - run: | |
37 | | - BASE_SHA=${{ github.event.pull_request.base.sha || github.event.before }} |
38 | | - git fetch origin $BASE_SHA |
39 | | - CHANGED_FILES=$(git diff --name-only $BASE_SHA ${{ github.sha }} -- \ |
40 | | - lib/generators/ \ |
41 | | - rakelib/example_type.rb \ |
42 | | - rakelib/example_config.yml \ |
43 | | - rakelib/examples.rake \ |
44 | | - rakelib/run_rspec.rake) |
45 | | - if [ -n "$CHANGED_FILES" ]; then |
46 | | - ANY_CHANGED=true |
47 | | - else |
48 | | - ANY_CHANGED=false |
49 | | - fi |
50 | | - echo "any_changed=$ANY_CHANGED" >> "$GITHUB_OUTPUT" |
51 | 67 | - name: Setup Ruby |
52 | 68 | uses: ruby/setup-ruby@v1 |
53 | 69 | with: |
@@ -108,7 +124,6 @@ jobs: |
108 | 124 | run: | |
109 | 125 | echo "CI_DEPENDENCY_LEVEL=${{ matrix.dependency-level }}" >> $GITHUB_ENV |
110 | 126 | - name: Main CI |
111 | | - if: steps.changed-files.outputs.any_changed == 'true' |
112 | 127 | run: bundle exec rake run_rspec:shakapacker_examples |
113 | 128 | - name: Store test results |
114 | 129 | uses: actions/upload-artifact@v4 |
|
0 commit comments