From 17ffcef0450ed44f6a3451849f0adf8266253241 Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Sat, 17 May 2025 17:44:14 +0100 Subject: [PATCH 1/2] test: initial `pre-commit` config --- .pre-commit-config.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1940f73 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +--- +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-yaml + name: Check YAML files with check-yaml + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.33.0 + hooks: + - id: check-github-workflows + name: Check GitHub workflows with check-jsonschema + args: ["--verbose"] + - repo: https://github.com/renovatebot/pre-commit-hooks + rev: 40.10.4 + hooks: + - id: renovate-config-validator + name: Check Renovate config with renovate-config-validator From c45183055aec0c945113343102da3515f79b409d Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Sat, 17 May 2025 17:47:00 +0100 Subject: [PATCH 2/2] ci: initial `pre-commit` workflow --- .github/workflows/main.yml | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..222b52e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,54 @@ +--- +name: Test & release + +on: + - pull_request + - push + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} + +jobs: + should-run: + name: Prep / Should run + runs-on: ubuntu-latest + timeout-minutes: 5 + outputs: + should-run: ${{ steps.action.outputs.should-run }} + steps: + - id: action + uses: + techneg-it/should-workflow-run@dcbb88600d59ec2842778ef1e2d41f680f876329 # v1.0.0 + pre-commit: + name: Lint / `pre-commit` + needs: should-run + if: fromJSON(needs.should-run.outputs.should-run) + container: techneg/ci-pre-commit:v2.3.3 + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Export `CI_CACHE_ID` from container + run: echo "CI_CACHE_ID=$(cat /.ci_cache_id)" >> $GITHUB_ENV + - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: ~/.cache/pre-commit + key: "${{ env.CI_CACHE_ID }}|\ + ${{ hashFiles('.pre-commit-config.yaml') }}" + - name: Run `pre-commit` + run: | + git config --global --add safe.directory $(pwd) + pre-commit run --all-files --color always --verbose + results: + name: Release / Collect results + permissions: + checks: read + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: poseidon/wait-for-status-checks@899c768d191b56eef585c18f8558da19e1f3e707 # v0.6.0 + with: + ignore: Release / Collect results + token: ${{ secrets.GITHUB_TOKEN }} + - run: echo "::notice ::Workflow success!"