|
| 1 | +# Copyright 2024 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: (experimental / dev) Custard run |
| 16 | + |
| 17 | +on: |
| 18 | + # Run tests when a pull request is created or updated. |
| 19 | + # This allows to run tests from forked repos (after reviewer's approval). |
| 20 | + workflow_run: |
| 21 | + workflows: |
| 22 | + - Custard CI # .github/workflows/custard-ci.yaml |
| 23 | + types: |
| 24 | + - in_progress |
| 25 | + |
| 26 | + # Run tests again as validation when a PR merge into main. |
| 27 | + push: |
| 28 | + branches: |
| 29 | + - main |
| 30 | + |
| 31 | + # To do manual runs through the Actions UI. |
| 32 | + workflow_dispatch: |
| 33 | + inputs: |
| 34 | + run-all: |
| 35 | + description: Run all tests |
| 36 | + type: boolean |
| 37 | + default: false |
| 38 | + paths: |
| 39 | + description: Comma separated packages to test |
| 40 | + type: string |
| 41 | + ref: |
| 42 | + description: Branch, tag, or commit SHA to run tests on |
| 43 | + type: string |
| 44 | + default: main |
| 45 | + |
| 46 | +jobs: |
| 47 | + affected: |
| 48 | + uses: GoogleCloudPlatform/cloud-samples-tools/.github/workflows/affected.yaml@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3 |
| 49 | + permissions: |
| 50 | + statuses: write |
| 51 | + with: |
| 52 | + head-sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }} |
| 53 | + config-file: .github/config/nodejs-dev.jsonc |
| 54 | + paths: ${{ (inputs.run-all && '.') || inputs.paths || '' }} |
| 55 | + check-name: (experimental / dev) Custard CI |
| 56 | + create-check-if: ${{ !!github.event.workflow_run }} |
| 57 | + |
| 58 | + test: |
| 59 | + if: needs.affected.outputs.paths != '[]' |
| 60 | + needs: affected |
| 61 | + runs-on: ubuntu-latest |
| 62 | + timeout-minutes: 120 # 2 hours hard limit |
| 63 | + permissions: |
| 64 | + id-token: write |
| 65 | + statuses: write |
| 66 | + strategy: |
| 67 | + fail-fast: false |
| 68 | + matrix: |
| 69 | + path: ${{ needs.affected.outputs.paths }} |
| 70 | + continue-on-error: true |
| 71 | + env: |
| 72 | + GOOGLE_SAMPLES_PROJECT: long-door-651 |
| 73 | + GOOGLE_SERVICE_ACCOUNT: [email protected] |
| 74 | + steps: |
| 75 | + - name: Check queued |
| 76 | + uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/create-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3 |
| 77 | + id: queued |
| 78 | + with: |
| 79 | + sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }} |
| 80 | + name: (experimental / dev) Custard CI / ${{ github.job }} (${{ matrix.path }}) |
| 81 | + job-name: ${{ github.job }} (${{ matrix.path }}) |
| 82 | + if: ${{ !!github.event.workflow_run }} |
| 83 | + - name: Setup Custard |
| 84 | + uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/setup-custard@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3 |
| 85 | + with: |
| 86 | + path: ${{ matrix.path }} |
| 87 | + ci-setup: ${{ toJson(fromJson(needs.affected.outputs.ci-setups)[matrix.path]) }} |
| 88 | + project-id: ${{ env.GOOGLE_SAMPLES_PROJECT }} |
| 89 | + workload-identity-provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider |
| 90 | + service-account: ${{ env.GOOGLE_SERVICE_ACCOUNT }} |
| 91 | + - name: Check in_progress |
| 92 | + uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3 |
| 93 | + id: in_progress |
| 94 | + with: |
| 95 | + check: ${{ steps.queued.outputs.check }} |
| 96 | + status: in_progress |
| 97 | + - name: Run tests for ${{ matrix.path }} |
| 98 | + run: | |
| 99 | + timeout ${{ fromJson(needs.affected.outputs.ci-setups)[matrix.path].timeout-minutes }}m \ |
| 100 | + make test dir=${{ matrix.path }} |
| 101 | + - name: Check success |
| 102 | + uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3 |
| 103 | + with: |
| 104 | + check: ${{ steps.in_progress.outputs.check }} |
| 105 | + status: success |
| 106 | + - name: Check failure |
| 107 | + uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3 |
| 108 | + if: failure() |
| 109 | + with: |
| 110 | + check: ${{ steps.in_progress.outputs.check }} |
| 111 | + status: failure |
| 112 | + |
| 113 | + done: |
| 114 | + needs: [affected, test] |
| 115 | + if: always() |
| 116 | + runs-on: ubuntu-latest |
| 117 | + permissions: |
| 118 | + statuses: write |
| 119 | + steps: |
| 120 | + - name: Check success |
| 121 | + uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3 |
| 122 | + with: |
| 123 | + check: ${{ needs.affected.outputs.check }} |
| 124 | + status: success |
0 commit comments