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..cc1d27d4 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,11 @@ +#!/bin/sh +# Validate GitHub Actions workflow files before commit. +# 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: scoop install actionlint (or: 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..9178d1a5 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,11 @@ +#!/bin/sh +# Validate GitHub Actions workflow files before push. +# 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: scoop install actionlint (or: 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" } }