Skip to content
Merged
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,51 @@ 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 }};
if (affected.length === 0) {
console.log("No packages were affected, nothing to lint.")
}

let failed = [];
for (const path of affected) {
try {
execSync(cmd, {cwd: path});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is the lint output on a successful pass useful? If so, consider printing stdout/stderr in both cases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question. I guess it depends on the lint tool. From the ones I've used they usually either don't have any output, or they just say something like "No issues found" or something like that. I was trying to keep the logs clean.

We can always add this functionality if we find a case where it's useful. I'm adding this as part of our reusable workflows, so there could be an option to show stdout/stderr from successful commands as well.

console.log(`✅ [${path}]: ${cmd}`);
} catch (e) {
failed.push(path)
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"));
}
}
console.log("=== Summary ===")
console.log(` Passed: ${affected.length - failed.length}`)
console.log(` Failed: ${failed.length}`)
if (failed.length > 0) {
core.setFailed(`Failed '${cmd}' on: ${failed.join(', ')}`)
}

region-tags:
name: region tags
Expand All @@ -82,8 +117,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
Expand Down
Loading