Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions .github/workflows/custard-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# limitations under the License.

# IMPORTANT: DO NOT CHANGE THE NAME OF THIS WORKFLOW!
# The workflow named "Custard CI" triggers both custard-run.yaml and custard-run-dev.yaml.
# The `lint` job is a required status check on main.
# custard-run.yaml and custard-run-dev.yaml no longer trigger from this workflow.
# TODO: To sunset old tests remove `affected`, `lint`, and `test` jobs (only keep `region-tags`).
name: Custard CI
on:
Expand All @@ -25,6 +26,9 @@
# # https://crontab.guru/#0_12_*_*_0
# - cron: 0 12 * * 0 # At 12:00 on Sunday

permissions:
contents: read

env:
GO_VERSION: ^1.22.0

Expand All @@ -38,18 +42,18 @@
nodejs-paths: ${{ steps.nodejs.outputs.paths }}
nodejs-setups: ${{ steps.nodejs.outputs.setups }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

Check warning on line 45 in .github/workflows/custard-ci.yaml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

custard-ci.yaml:45: action's hash pin has mismatched or missing version comment: points to commit fbc6f3992d24
with:
fetch-depth: 0
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

Check warning on line 48 in .github/workflows/custard-ci.yaml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

custard-ci.yaml:48: action's hash pin has mismatched or missing version comment: points to commit fbc6f3992d24
with:
repository: GoogleCloudPlatform/cloud-samples-tools
ref: v0.3.2
ref: 9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
path: cloud-samples-tools
- name: Create `bin` directory for cloud-samples-tools binaries
run: mkdir bin
working-directory: cloud-samples-tools
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5

Check warning on line 56 in .github/workflows/custard-ci.yaml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

custard-ci.yaml:56: action's hash pin has mismatched or missing version comment: points to commit 40f1582b2485
with:
go-version: ${{ env.GO_VERSION }}
- name: Build Custard (from cloud-samples-tools)
Expand All @@ -70,20 +74,22 @@
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

Check warning on line 77 in .github/workflows/custard-ci.yaml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

custard-ci.yaml:77: action's hash pin has mismatched or missing version comment: points to commit fbc6f3992d24
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
- run: npm install
- name: Run lint
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7

Check warning on line 84 in .github/workflows/custard-ci.yaml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

custard-ci.yaml:84: action's hash pin has mismatched or missing version comment: points to commit f28e40c7f34b
env:
AFFECTED_PATHS: ${{ needs.affected.outputs.nodejs-paths }}
with:
script: |
const { execSync } = await import("node:child_process");

const cmd = 'npx gts lint';
const affected = ${{ needs.affected.outputs.nodejs-paths }};
const affected = JSON.parse(process.env.AFFECTED_PATHS);
if (affected.length === 0) {
console.log("No packages were affected, nothing to lint.")
}
Expand Down Expand Up @@ -115,7 +121,7 @@
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

Check warning on line 124 in .github/workflows/custard-ci.yaml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

custard-ci.yaml:124: action's hash pin has mismatched or missing version comment: points to commit fbc6f3992d24
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
Expand All @@ -139,8 +145,8 @@
CI_SETUP: ${{ toJson(fromJson(needs.affected.outputs.nodejs-setups)[matrix.path])}}
steps:
- name: CI Setup
run: echo "${{ env.CI_SETUP }}"
run: echo "${CI_SETUP}"
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

Check warning on line 149 in .github/workflows/custard-ci.yaml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

custard-ci.yaml:149: action's hash pin has mismatched or missing version comment: points to commit fbc6f3992d24
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
Expand All @@ -157,22 +163,27 @@
id_token_audience: 'https://action.test/' # service must have this custom audience
id_token_include_email: true
- name: Export environment variables
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7

Check warning on line 166 in .github/workflows/custard-ci.yaml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

custard-ci.yaml:166: action's hash pin has mismatched or missing version comment: points to commit f28e40c7f34b
id: vars
env:
ID_TOKEN: ${{ steps.auth.outputs.id_token }}
with:
script: |
const { default: setupVars } = await import('${{ github.workspace }}/.github/scripts/setup-vars.js');
const projectId = '${{ env.GOOGLE_SAMPLES_PROJECT }}';
const { default: setupVars } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/setup-vars.js`);
const projectId = process.env.GOOGLE_SAMPLES_PROJECT;
const setup = JSON.parse(process.env.CI_SETUP);
const serviceAccount = '${{ env.GOOGLE_SERVICE_ACCOUNT }}';
const idToken = '${{ steps.auth.outputs.id_token }}';
const serviceAccount = process.env.GOOGLE_SERVICE_ACCOUNT;
const idToken = process.env.ID_TOKEN;
return await setupVars({projectId, core, setup, serviceAccount, idToken})
- uses: google-github-actions/get-secretmanager-secrets@e5bb06c2ca53b244f978d33348d18317a7f263ce # v2

Check warning on line 178 in .github/workflows/custard-ci.yaml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

custard-ci.yaml:178: action's hash pin has mismatched or missing version comment: points to commit 2b5f97c5a4b9
if: ${{ fromJson(steps.vars.outputs.result).secrets }}
with:
secrets: ${{ fromJson(steps.vars.outputs.result).secrets }}
export_to_environment: true
- name: Run tests for ${{ matrix.path }}
env:
TIMEOUT_MINUTES: ${{ fromJson(env.CI_SETUP).timeout-minutes }}
MATRIX_PATH: ${{ matrix.path }}
run: |
timeout ${{ fromJson(env.CI_SETUP).timeout-minutes }}m \
make test dir=${{ matrix.path }}
timeout "${TIMEOUT_MINUTES}m" \
make test dir="${MATRIX_PATH}"
11 changes: 4 additions & 7 deletions .github/workflows/custard-run-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
name: (dev) Custard run

on:
# Run tests when a pull request is created or updated.
# This allows to run tests from forked repos (after reviewer's approval).
workflow_run:
workflows:
- Custard CI # .github/workflows/custard-ci.yaml
types:
- in_progress
# Pull requests do not trigger this workflow. Code from a pull request must
# not run here with Google Cloud credentials unless a maintainer starts the
# run through workflow_dispatch after reviewing the commit.

# Run tests again as validation when a PR merge into main.
push:
Expand Down Expand Up @@ -84,6 +80,7 @@ jobs:
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
ref: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
persist-credentials: false
- name: Authenticate
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
id: auth
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/custard-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
name: Custard run

on:
# Run tests when a pull request is created or updated.
# This allows to run tests from forked repos (after reviewer's approval).
workflow_run:
workflows:
- Custard CI # .github/workflows/custard-ci.yaml
types:
- in_progress
# Pull requests do not trigger this workflow. Code from a pull request must
# not run here with Google Cloud credentials unless a maintainer starts the
# run through workflow_dispatch after reviewing the commit.

# Run tests again as validation when a PR merge into main.
push:
Expand Down Expand Up @@ -76,9 +72,10 @@
name: Custard CI / ${{ github.job }}
if: ${{ !!github.event.workflow_run }}
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

Check warning on line 75 in .github/workflows/custard-run.yaml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

custard-run.yaml:75: action's hash pin has mismatched or missing version comment: points to commit fbc6f3992d24
with:
ref: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
persist-credentials: false
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
Expand Down Expand Up @@ -130,6 +127,7 @@
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
ref: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
persist-credentials: false
- name: Authenticate
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
id: auth
Expand All @@ -154,12 +152,14 @@
check: ${{ steps.queued.outputs.check }}
status: in_progress
- name: Run tests for ${{ matrix.path }}
run: |
timeout ${{ fromJson(needs.affected.outputs.ci-setups)[matrix.path].timeout-minutes }}m \
make test dir=${{ matrix.path }}
env:
TIMEOUT_MINUTES: ${{ fromJson(needs.affected.outputs.ci-setups)[matrix.path].timeout-minutes }}
MATRIX_PATH: ${{ matrix.path }}
# TODO: remove this when the self-contained runner lands.
SERVICE_ACCOUNT: kokoro-system-test@long-door-651.iam.gserviceaccount.com
run: |
timeout "${TIMEOUT_MINUTES}m" \
make test dir="${MATRIX_PATH}"
- name: Check success
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
with:
Expand Down
Loading