From eca263eb0b9ae456914595854562ff2debad4422 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:47:28 +0100 Subject: [PATCH] ci: add pre-commit workflow (#339) Add a workflow that checks if all pre-commit checks pass or not. This includes pre-commit and conform. --- .conform.yaml | 47 ++++++++++++++++--------------- .github/workflows/pre-commit.yaml | 32 +++++++++++++++++++++ devenv.nix | 2 ++ 3 files changed, 58 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/pre-commit.yaml diff --git a/.conform.yaml b/.conform.yaml index 4dfcded..c3dcdb3 100644 --- a/.conform.yaml +++ b/.conform.yaml @@ -1,24 +1,25 @@ policies: - - type: commit - spec: - header: - length: 89 - imperative: true - case: lower - invalidLastCharacters: . - body: - required: true - dco: false - gpg: - required: true - spellcheck: - locale: US - maximumOfOneCommit: false - conventional: - types: - - feat - - fix - - chore - - deps - - docs - descriptionLength: 72 + - type: commit + spec: + header: + length: 89 + imperative: true + case: lower + invalidLastCharacters: . + body: + required: true + dco: false + gpg: + required: true + spellcheck: + locale: US + maximumOfOneCommit: false + conventional: + types: + - feat + - fix + - chore + - deps + - docs + - ci + descriptionLength: 72 diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 0000000..b25ff1a --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,32 @@ +name: "pre-commit" +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] +jobs: + pre-commit: + runs-on: ubuntu-latest + env: + USER: runner + steps: + - name: install packages + run: sudo apt-get update && sudo apt-get install -y curl xz-utils git + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - uses: cachix/install-nix-action@v26 + - uses: DeterminateSystems/magic-nix-cache-action@v3 + - name: Install devenv.sh + run: nix profile install tarball+https://install.devenv.sh/latest + - name: Pre Commit + shell: devenv shell bash -e {0} + run: pre-commit run -s HEAD~1 -o HEAD + conform: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Conform Action + uses: siderolabs/conform@v0.1.0-alpha.29 diff --git a/devenv.nix b/devenv.nix index c766ece..9a4ac50 100644 --- a/devenv.nix +++ b/devenv.nix @@ -13,6 +13,7 @@ vault nodejs-slim awscli2 + conform ]; languages.javascript = { @@ -23,6 +24,7 @@ pre-commit.hooks = { eslint.enable = true; actionlint.enable = true; + conform.enable = true; }; # https://devenv.sh/scripts/