|
| 1 | +name: Workflow Restarter TEST |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + fail: |
| 7 | + description: > |
| 8 | + For (acceptance, unit) jobs: |
| 9 | + 'true' = (fail, succeed) and |
| 10 | + 'false' = (succeed, fail) |
| 11 | + required: true |
| 12 | + default: 'true' |
| 13 | +env: |
| 14 | + SOURCE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 15 | + |
| 16 | +jobs: |
| 17 | + linux_tests: |
| 18 | + name: Linux, Puppet ${{ matrix.cfg.puppet_version }}, Ruby ${{ matrix.cfg.ruby }} |
| 19 | + runs-on: ubuntu-latest |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + cfg: |
| 23 | + - {puppet_version: '7', ruby: '2.7'} |
| 24 | + - {puppet_version: '7', ruby: 'jruby-9.3.7.0'} |
| 25 | + - {puppet_version: '8', ruby: '3.2'} |
| 26 | + - {puppet_version: '8', ruby: 'jruby-9.4.2.0'} |
| 27 | + env: |
| 28 | + PUPPET_GEM_VERSION: ~> ${{ matrix.cfg.puppet_version }} |
| 29 | + steps: |
| 30 | + - name: Checkout current PR |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + - name: Install Ruby version ${{ matrix.cfg.ruby }} |
| 35 | + uses: ruby/setup-ruby@v1 |
| 36 | + with: |
| 37 | + ruby-version: ${{ matrix.cfg.ruby }} |
| 38 | + - name: Update rubygems and install gems |
| 39 | + run: | |
| 40 | + bundle config set without development |
| 41 | + bundle install --jobs 4 --retry 3 |
| 42 | +
|
| 43 | + - name: Rubocop |
| 44 | + run: | |
| 45 | + bundle exec rake rubocop |
| 46 | +
|
| 47 | + - name: Run tests |
| 48 | + run: | |
| 49 | + bundle exec rake spec |
| 50 | +
|
| 51 | + # Starting with version 3.2, Ruby no longer bundles libffi, which is necessary for tests on Windows. Due to a discrepancy between the C |
| 52 | + # library the Windows Puppet gem is built against and what GitHub runners use (MinGW and ucrt, respectively) we can't install the |
| 53 | + # Windows-specific Puppet gem that includes libffi. To work around these issues, we have a separate "integration" group that we include |
| 54 | + # when testing Puppet 8 / Ruby 3.2 on Windows. See PA-5406 for more. |
| 55 | + windows_tests: |
| 56 | + name: Windows, Puppet ${{ matrix.cfg.puppet_version }}, Ruby ${{ matrix.cfg.ruby }} |
| 57 | + runs-on: windows-latest |
| 58 | + strategy: |
| 59 | + matrix: |
| 60 | + cfg: |
| 61 | + - {puppet_version: '7', ruby: '2.7'} |
| 62 | + - {puppet_version: '8', ruby: '3.2', extra: 'bundle config set with integration'} |
| 63 | + env: |
| 64 | + PUPPET_GEM_VERSION: ~> ${{ matrix.cfg.puppet_version }} |
| 65 | + steps: |
| 66 | + - name: Checkout current PR |
| 67 | + uses: actions/checkout@v4 |
| 68 | + with: |
| 69 | + fetch-depth: 0 |
| 70 | + - name: Install Ruby version ${{ matrix.cfg.ruby }} |
| 71 | + uses: ruby/setup-ruby@v1 |
| 72 | + with: |
| 73 | + ruby-version: ${{ matrix.cfg.ruby }} |
| 74 | + - name: Update rubygems and install gems |
| 75 | + run: | |
| 76 | + bundle config set without development |
| 77 | + ${{ matrix.cfg.extra }} |
| 78 | + bundle install --jobs 4 --retry 3 |
| 79 | +
|
| 80 | + - name: Rubocop |
| 81 | + run: | |
| 82 | + bundle exec rake rubocop |
| 83 | +
|
| 84 | + - name: Run tests |
| 85 | + run: | |
| 86 | + bundle exec rake spec |
| 87 | + |
| 88 | + on-failure-workflow-restarter-proxy: |
| 89 | + # (1) run this job after the "acceptance" job and... |
| 90 | + needs: [linux_tests, windows_tests] |
| 91 | + # (2) continue ONLY IF "acceptance" fails |
| 92 | + if: always() && needs.linux_tests.result == 'failure' || needs.windows_tests.result == 'failure' |
| 93 | + runs-on: ubuntu-latest |
| 94 | + steps: |
| 95 | + # (3) checkout this repository in order to "see" the following custom action |
| 96 | + - name: Checkout repository |
| 97 | + uses: actions/checkout@v4 |
| 98 | + |
| 99 | + # (4) "use" the custom action to retrigger the failed "acceptance job" above |
| 100 | + # NOTE: pass the SOURCE_GITHUB_TOKEN to the custom action because (a) it must have |
| 101 | + # this to trigger the reusable workflow that restarts the failed job; and |
| 102 | + # (b) custom actions do not have access to the calling workflow's secrets |
| 103 | + - name: Trigger reusable workflow |
| 104 | + uses: "puppetlabs/cat-github-actions/.github/actions/workflow-restarter-proxy@main" |
| 105 | + env: |
| 106 | + SOURCE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + with: |
| 108 | + repository: ${{ github.repository }} |
| 109 | + run_id: ${{ github.run_id }} |
0 commit comments