Skip to content

Commit

Permalink
feat: run lint only on affected packages (#4022)
Browse files Browse the repository at this point in the history
* feat: run lint only on affected packages

* add note when nothing got run

* change package to trigger lint

* insert lint issue

* revert changes to package

* remove nodejs prefix for consistency

* use core.error

* check core.notice, core.info, and core.setFailed

* clean up logs

* clean up spaces

* add colon to summary

* revert lint issue

---------

Co-authored-by: Jennifer Davis <[email protected]>
  • Loading branch information
davidcavazos and iennae authored Mar 11, 2025
1 parent be25b32 commit 8f0eaac
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
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});
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

0 comments on commit 8f0eaac

Please sign in to comment.