From 4d2f0035bd52bc6ee842a0f5f9849ba40b8ed209 Mon Sep 17 00:00:00 2001 From: Kieron Lanning Date: Sun, 24 May 2026 17:02:03 +0100 Subject: [PATCH 1/2] feat(ci): add actionlint workflow validation to CI and pre-push hook - ci.yml: validate-workflows job calls kjldev/.github reusable workflow which runs actionlint on all .github/workflows/*.yml files - Added to ci-gate so a bad workflow file blocks PR merge - .husky/pre-commit: runs actionlint locally before every commit (gracefully skips if not installed, with install instructions) - .husky/pre-push: same check at push time for extra safety - husky v9 installed and configured via prepare script Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 7 +++++++ .husky/pre-commit | 11 +++++++++++ .husky/pre-push | 11 +++++++++++ bun.lock | 3 +++ package.json | 6 ++++-- 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 .husky/pre-commit create mode 100644 .husky/pre-push diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 732f5add..94fdf44c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,6 +80,10 @@ jobs: - name: Run tests run: dotnet test ${{ env.SOLUTION }} --no-build --verbosity normal --configuration ${{ env.CONFIGURATION }} + validate-workflows: + name: Validate Workflows + uses: kjldev/.github/.github/workflows/validate-workflows.yml@main + changeset-check: name: Changeset Check uses: kjldev/.github/.github/workflows/changeset-check.yml@main @@ -92,6 +96,7 @@ jobs: - format-check - build-and-test - build-and-test-samples + - validate-workflows - changeset-check steps: @@ -100,6 +105,7 @@ jobs: FORMAT_CHECK_RESULT: ${{ needs['format-check'].result }} BUILD_AND_TEST_RESULT: ${{ needs['build-and-test'].result }} BUILD_AND_TEST_SAMPLES_RESULT: ${{ needs['build-and-test-samples'].result }} + VALIDATE_WORKFLOWS_RESULT: ${{ needs['validate-workflows'].result }} CHANGESET_CHECK_RESULT: ${{ needs['changeset-check'].result }} shell: bash run: | @@ -109,6 +115,7 @@ jobs: ["Format Check"]="${FORMAT_CHECK_RESULT}" ["Build and Test"]="${BUILD_AND_TEST_RESULT}" ["Build and Test Samples"]="${BUILD_AND_TEST_SAMPLES_RESULT}" + ["Validate Workflows"]="${VALIDATE_WORKFLOWS_RESULT}" ["Changeset Check"]="${CHANGESET_CHECK_RESULT}" ) diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..46d65c26 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,11 @@ +#!/bin/sh +# Validate GitHub Actions workflow files before commit. +# Install actionlint: go install github.com/rhysd/actionlint/cmd/actionlint@latest + +if command -v actionlint >/dev/null 2>&1; then + echo "Running actionlint..." + actionlint +else + echo "⚠️ actionlint not found — workflow validation skipped." + echo " Install: go install github.com/rhysd/actionlint/cmd/actionlint@latest" +fi diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100644 index 00000000..94123ebe --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,11 @@ +#!/bin/sh +# Validate GitHub Actions workflow files before push. +# Install actionlint: go install github.com/rhysd/actionlint/cmd/actionlint@latest + +if command -v actionlint >/dev/null 2>&1; then + echo "Running actionlint..." + actionlint +else + echo "⚠️ actionlint not found — workflow validation skipped." + echo " Install: go install github.com/rhysd/actionlint/cmd/actionlint@latest" +fi diff --git a/bun.lock b/bun.lock index fdb7d7cd..00273b66 100644 --- a/bun.lock +++ b/bun.lock @@ -7,6 +7,7 @@ "devDependencies": { "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.12", + "husky": "^9.1.7", }, }, }, @@ -113,6 +114,8 @@ "human-id": ["human-id@4.1.3", "", { "bin": { "human-id": "dist/cli.js" } }, "sha512-tsYlhAYpjCKa//8rXZ9DqKEawhPoSytweBC2eNvcaDK+57RZLHGqNs3PZTQO6yekLFSuvA6AlnAfrw1uBvtb+Q=="], + "husky": ["husky@9.1.7", "", { "bin": { "husky": "bin.js" } }, "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA=="], + "iconv-lite": ["iconv-lite@0.7.2", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw=="], "ignore": ["ignore@5.3.2", "", {}, "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g=="], diff --git a/package.json b/package.json index 8110f4bf..341e8e14 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "readme": "README.md", "scripts": { "changeset": "changeset", - "version-packages": "changeset version && bun .build/update-version.ts" + "version-packages": "changeset version && bun .build/update-version.ts", + "prepare": "husky" }, "repository": { "type": "git", @@ -19,6 +20,7 @@ "homepage": "https://github.com/kjldev/purview-telemetry-sourcegenerator#readme", "devDependencies": { "@changesets/changelog-github": "^0.5.0", - "@changesets/cli": "^2.27.12" + "@changesets/cli": "^2.27.12", + "husky": "^9.1.7" } } From 3733ecaafd3670d327f7227bca2908e867e159d2 Mon Sep 17 00:00:00 2001 From: Kieron Lanning Date: Sun, 24 May 2026 17:08:17 +0100 Subject: [PATCH 2/2] chore: update actionlint install hint to prefer scoop Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .husky/pre-commit | 4 ++-- .husky/pre-push | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 46d65c26..cc1d27d4 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,11 +1,11 @@ #!/bin/sh # Validate GitHub Actions workflow files before commit. -# Install actionlint: go install github.com/rhysd/actionlint/cmd/actionlint@latest +# Install actionlint: scoop install actionlint (or: go install github.com/rhysd/actionlint/cmd/actionlint@latest) if command -v actionlint >/dev/null 2>&1; then echo "Running actionlint..." actionlint else echo "⚠️ actionlint not found — workflow validation skipped." - echo " Install: go install github.com/rhysd/actionlint/cmd/actionlint@latest" + echo " Install: scoop install actionlint (or: go install github.com/rhysd/actionlint/cmd/actionlint@latest)" fi diff --git a/.husky/pre-push b/.husky/pre-push index 94123ebe..9178d1a5 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,11 +1,11 @@ #!/bin/sh # Validate GitHub Actions workflow files before push. -# Install actionlint: go install github.com/rhysd/actionlint/cmd/actionlint@latest +# Install actionlint: scoop install actionlint (or: go install github.com/rhysd/actionlint/cmd/actionlint@latest) if command -v actionlint >/dev/null 2>&1; then echo "Running actionlint..." actionlint else echo "⚠️ actionlint not found — workflow validation skipped." - echo " Install: go install github.com/rhysd/actionlint/cmd/actionlint@latest" + echo " Install: scoop install actionlint (or: go install github.com/rhysd/actionlint/cmd/actionlint@latest)" fi