From 69b6503388e073b2655b95448024c0364f4df98f Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Fri, 7 Mar 2025 13:25:49 -0800 Subject: [PATCH 01/12] feat: run lint only on affected packages --- .../{ci-dev.yaml => custard-ci-dev.yaml} | 0 .../{ci-prod.yaml => custard-ci.yaml} | 38 ++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) rename .github/workflows/{ci-dev.yaml => custard-ci-dev.yaml} (100%) rename .github/workflows/{ci-prod.yaml => custard-ci.yaml} (82%) diff --git a/.github/workflows/ci-dev.yaml b/.github/workflows/custard-ci-dev.yaml similarity index 100% rename from .github/workflows/ci-dev.yaml rename to .github/workflows/custard-ci-dev.yaml diff --git a/.github/workflows/ci-prod.yaml b/.github/workflows/custard-ci.yaml similarity index 82% rename from .github/workflows/ci-prod.yaml rename to .github/workflows/custard-ci.yaml index 73b38ea62b..9ce438f5cf 100644 --- a/.github/workflows/ci-prod.yaml +++ b/.github/workflows/custard-ci.yaml @@ -60,16 +60,44 @@ jobs: cat paths.txt echo "setups=$(./cloud-samples-tools/bin/custard setup-files .github/config/nodejs-prod.jsonc paths.txt)" >> $GITHUB_OUTPUT - nodejs-lint: - name: lint + lint: + needs: affected runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - - uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4 + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Setup Node + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4 with: node-version: 20 - - run: make lint + - run: npm install + - name: Run lint + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 + with: + script: | + const { execSync } = await import("node:child_process"); + + const cmd = 'npx gts lint'; + const affected = ${{ needs.affected.outputs.nodejs-paths }}; + + let failed = false; + for (const path of affected) { + try { + execSync(cmd, {cwd: path}); + console.log(`✅ [${path}]: ${cmd}`); + } catch (e) { + failed = true; + console.log(`❌ [${path}]: ${cmd} (status ${e.status})`); + console.log('--- stdout ---'); + console.log(e.stdout.toString("utf8")); + console.log('--- stderr ---'); + console.log(e.stderr.toString("utf8")); + } + } + if (failed) { + process.exit(1) + } region-tags: name: region tags From ecdd0e33e62075d9ca05eb445eaa30fba2308049 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Mon, 10 Mar 2025 12:43:38 -0700 Subject: [PATCH 02/12] add note when nothing got run --- .github/workflows/custard-ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index 9ce438f5cf..00747f6366 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -80,6 +80,9 @@ jobs: const cmd = 'npx gts lint'; const affected = ${{ needs.affected.outputs.nodejs-paths }}; + if (affected.length === 0) { + console.log("No packages were affected, nothing to lint.") + } let failed = false; for (const path of affected) { From 6a606b5bf828bd0dc1be393c9190794fba5a4161 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Mon, 10 Mar 2025 12:49:38 -0700 Subject: [PATCH 03/12] change package to trigger lint --- tpu/stopVM.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tpu/stopVM.js b/tpu/stopVM.js index 34d86cdb09..ea2677f929 100644 --- a/tpu/stopVM.js +++ b/tpu/stopVM.js @@ -16,6 +16,8 @@ 'use strict'; +// TODO: revert this change, done to trigger lint job + async function main(tpuClient) { // [START tpu_vm_stop] // Import the TPUClient From 25dbc31f9d51901f5e9c5f133ed02dca093fd89f Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Mon, 10 Mar 2025 12:55:40 -0700 Subject: [PATCH 04/12] insert lint issue --- tpu/stopVM.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tpu/stopVM.js b/tpu/stopVM.js index ea2677f929..5b504ff187 100644 --- a/tpu/stopVM.js +++ b/tpu/stopVM.js @@ -18,6 +18,8 @@ // TODO: revert this change, done to trigger lint job +const x = 'lint error without semicolon' + async function main(tpuClient) { // [START tpu_vm_stop] // Import the TPUClient From 2fdbe5c03d4f5a0dfc0e66a9f77f997996c53c07 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Mon, 10 Mar 2025 12:57:51 -0700 Subject: [PATCH 05/12] revert changes to package --- tpu/stopVM.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tpu/stopVM.js b/tpu/stopVM.js index 5b504ff187..34d86cdb09 100644 --- a/tpu/stopVM.js +++ b/tpu/stopVM.js @@ -16,10 +16,6 @@ 'use strict'; -// TODO: revert this change, done to trigger lint job - -const x = 'lint error without semicolon' - async function main(tpuClient) { // [START tpu_vm_stop] // Import the TPUClient From 405be4265a1d098417441bb4b62f8768172ee2c4 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Mon, 10 Mar 2025 13:01:27 -0700 Subject: [PATCH 06/12] remove nodejs prefix for consistency --- .github/workflows/custard-ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index 00747f6366..afbbb4b73d 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -113,8 +113,7 @@ jobs: node-version: 20 - run: ./.github/workflows/utils/region-tags-tests.sh - nodejs-test: - name: test + test: needs: affected runs-on: ubuntu-latest timeout-minutes: 120 # 2 hours hard limit From 1a9b7a7fa83526740b63ad1a2f0d67d14adac8f5 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Tue, 11 Mar 2025 11:31:55 -0700 Subject: [PATCH 07/12] use core.error --- .github/workflows/custard-ci.yaml | 12 +++++++++--- tpu/createVM.js | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index afbbb4b73d..2b08b214d4 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -84,21 +84,27 @@ jobs: console.log("No packages were affected, nothing to lint.") } - let failed = false; + let failed = []; for (const path of affected) { try { execSync(cmd, {cwd: path}); console.log(`✅ [${path}]: ${cmd}`); } catch (e) { - failed = true; + failed.push(path) console.log(`❌ [${path}]: ${cmd} (status ${e.status})`); console.log('--- stdout ---'); console.log(e.stdout.toString("utf8")); console.log('--- stderr ---'); console.log(e.stderr.toString("utf8")); + core.error(`Linting failed in ${path}: ${e.message}`); } } - if (failed) { + console.log(`Passed: ${affected.length - failed.length}`) + console.log(`Failed: ${failed.length}`) + if (failed.length > 0) { + for (const path of failed) { + console.log(`- ❌ ${path}`) + } process.exit(1) } diff --git a/tpu/createVM.js b/tpu/createVM.js index a80905d87e..02502579b9 100644 --- a/tpu/createVM.js +++ b/tpu/createVM.js @@ -16,6 +16,8 @@ 'use strict'; +const x = 'TODO: DELETE THIS' + async function main(tpuClient) { // [START tpu_vm_create] // Import the TPUClient From 982c62b652d62324fbbb1258ed6a913ca008c907 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Tue, 11 Mar 2025 11:44:49 -0700 Subject: [PATCH 08/12] check core.notice, core.info, and core.setFailed --- .github/workflows/custard-ci.yaml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index 2b08b214d4..c7c9aaaa47 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -91,21 +91,23 @@ jobs: console.log(`✅ [${path}]: ${cmd}`); } catch (e) { failed.push(path) - console.log(`❌ [${path}]: ${cmd} (status ${e.status})`); + console.log(`❌ [${path}]: ${cmd} (exit code ${e.status})`); + core.error(e.message); console.log('--- stdout ---'); console.log(e.stdout.toString("utf8")); console.log('--- stderr ---'); console.log(e.stderr.toString("utf8")); - core.error(`Linting failed in ${path}: ${e.message}`); } } - console.log(`Passed: ${affected.length - failed.length}`) - console.log(`Failed: ${failed.length}`) + core.notice("Summary:") + core.info("Summary:") + console.log(` Passed: ${affected.length - failed.length}`) + console.log(` Failed: ${failed.length}`) if (failed.length > 0) { for (const path of failed) { - console.log(`- ❌ ${path}`) + console.log(` - ❌ ${path}`) } - process.exit(1) + core.setFailed(`Failed '${cmd}' on ${JSON.stringify(failed)}`) } region-tags: From 0c6493cdf10456be63da94dee56b1540efe03611 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Tue, 11 Mar 2025 11:47:42 -0700 Subject: [PATCH 09/12] clean up logs --- .github/workflows/custard-ci.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index c7c9aaaa47..4c983e3cbe 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -99,15 +99,11 @@ jobs: console.log(e.stderr.toString("utf8")); } } - core.notice("Summary:") - core.info("Summary:") + console.log("\n\n=== Summary ===") console.log(` Passed: ${affected.length - failed.length}`) console.log(` Failed: ${failed.length}`) if (failed.length > 0) { - for (const path of failed) { - console.log(` - ❌ ${path}`) - } - core.setFailed(`Failed '${cmd}' on ${JSON.stringify(failed)}`) + core.setFailed(`Failed '${cmd}' on ${failed.join(', ')}`) } region-tags: From a93ef718f2a201f6a3309b95293c0a60632bd700 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Tue, 11 Mar 2025 11:49:16 -0700 Subject: [PATCH 10/12] clean up spaces --- .github/workflows/custard-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index 4c983e3cbe..7be0c3ba56 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -99,7 +99,7 @@ jobs: console.log(e.stderr.toString("utf8")); } } - console.log("\n\n=== Summary ===") + console.log("=== Summary ===") console.log(` Passed: ${affected.length - failed.length}`) console.log(` Failed: ${failed.length}`) if (failed.length > 0) { From 8ce10648d6409b17b09987da4b6d9772c806d168 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Tue, 11 Mar 2025 11:53:18 -0700 Subject: [PATCH 11/12] add colon to summary --- .github/workflows/custard-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index 7be0c3ba56..2e85d1218c 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -103,7 +103,7 @@ jobs: console.log(` Passed: ${affected.length - failed.length}`) console.log(` Failed: ${failed.length}`) if (failed.length > 0) { - core.setFailed(`Failed '${cmd}' on ${failed.join(', ')}`) + core.setFailed(`Failed '${cmd}' on: ${failed.join(', ')}`) } region-tags: From c8523d530fa4f39173375fe0805e9f46193d4594 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Tue, 11 Mar 2025 11:56:52 -0700 Subject: [PATCH 12/12] revert lint issue --- tpu/createVM.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/tpu/createVM.js b/tpu/createVM.js index 02502579b9..a80905d87e 100644 --- a/tpu/createVM.js +++ b/tpu/createVM.js @@ -16,8 +16,6 @@ 'use strict'; -const x = 'TODO: DELETE THIS' - async function main(tpuClient) { // [START tpu_vm_create] // Import the TPUClient