From f5147dec8dc1e71742499671320b6b8dcde7fddf Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 12 Dec 2024 15:01:42 +0100 Subject: [PATCH] feat(workflows/pre-commit): Check multiple stages --- .forgejo/workflows/pre-commit.yaml | 7 +++++-- workflows/pre-commit.nix | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.forgejo/workflows/pre-commit.yaml b/.forgejo/workflows/pre-commit.yaml index 13545ce..25324c1 100644 --- a/.forgejo/workflows/pre-commit.yaml +++ b/.forgejo/workflows/pre-commit.yaml @@ -1,9 +1,12 @@ jobs: - check: + pre-commit: runs-on: nix steps: - uses: actions/checkout@v3 - - name: Run pre-commit on all files + - name: Check stage pre-commit + run: nix-shell -A pre-commit --run 'pre-commit run --all-files --hook-stage + pre-commit --show-diff-on-failure' + - name: Check stage pre-push run: nix-shell -A pre-commit --run 'pre-commit run --all-files --hook-stage pre-push --show-diff-on-failure' name: Run pre-commit on all files diff --git a/workflows/pre-commit.nix b/workflows/pre-commit.nix index b6ea2e1..3c7cb81 100644 --- a/workflows/pre-commit.nix +++ b/workflows/pre-commit.nix @@ -9,14 +9,19 @@ "pull_request" ]; - jobs.check = { + jobs.pre-commit = { runs-on = "nix"; - steps = [ - { uses = "actions/checkout@v3"; } - { - name = "Run pre-commit on all files"; - run = "nix-shell -A pre-commit --run 'pre-commit run --all-files --hook-stage pre-push --show-diff-on-failure'"; - } - ]; + steps = + [ { uses = "actions/checkout@v3"; } ] + ++ (builtins.map + (stage: { + name = "Check stage ${stage}"; + run = "nix-shell -A pre-commit --run 'pre-commit run --all-files --hook-stage ${stage} --show-diff-on-failure'"; + }) + [ + "pre-commit" + "pre-push" + ] + ); }; }