From 76062dde4e5e42bd651992a7a2a44354956ffd7c Mon Sep 17 00:00:00 2001 From: Minijackson Date: Tue, 12 Dec 2023 09:57:00 +0100 Subject: [PATCH 1/5] feat(ci): add Nix build as GitHub action --- .github/workflows/nix-build.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/nix-build.yml diff --git a/.github/workflows/nix-build.yml b/.github/workflows/nix-build.yml new file mode 100644 index 0000000..88f4306 --- /dev/null +++ b/.github/workflows/nix-build.yml @@ -0,0 +1,22 @@ +name: "Nix build" + +permissions: read-all + +on: + # Allows running this workflow manually + workflow_dispatch: + push: + branches: [master] + pull_request: + +jobs: + nix-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v24 + - uses: DeterminateSystems/magic-nix-cache-action@v2 + with: + diagnostic-endpoint: "" + - name: Run `nix build` + run: nix build -L . From 98cbb493d429a8392b876fb56a979e85707fc2ba Mon Sep 17 00:00:00 2001 From: Minijackson Date: Tue, 12 Dec 2023 10:00:27 +0100 Subject: [PATCH 2/5] fix(ci): don't run CI on every push else we get double the amount of emails on pull requests --- .github/workflows/editorconfig.yml | 1 + .github/workflows/ruff.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/editorconfig.yml b/.github/workflows/editorconfig.yml index 9fe857e..beaecc7 100644 --- a/.github/workflows/editorconfig.yml +++ b/.github/workflows/editorconfig.yml @@ -4,6 +4,7 @@ permissions: read-all on: push: + branches: [master] pull_request: jobs: diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index c92426a..aa69b42 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -4,6 +4,7 @@ permissions: read-all on: push: + branches: [master] pull_request: jobs: From 3dfd0e711344c23007512d4fc725bda94bc5f24a Mon Sep 17 00:00:00 2001 From: Minijackson Date: Tue, 12 Dec 2023 10:01:57 +0100 Subject: [PATCH 3/5] chore(ci): rename Ruff lint action workflow, make it clearer --- .github/workflows/ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index aa69b42..c486952 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -1,4 +1,4 @@ -name: "Check Formatting" +name: "Ruff lints" permissions: read-all From abe50ad8cbaec7a9d61f3bf81502e5c8d319ebd6 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Tue, 12 Dec 2023 14:17:24 +0100 Subject: [PATCH 4/5] fix(ci): only run Ruff GitHub Action on changed Python files --- .github/workflows/ruff.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index c486952..7bd2c06 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -12,6 +12,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v40 + with: + files: | + **.py - uses: cachix/install-nix-action@v20 - name: "Check Ruff lints" - run: nix run 'nixpkgs#ruff' -- check . --output-format=github + if: steps.changed-files.outputs.any_changed == 'true' + run: nix run 'nixpkgs#ruff' -- check . --output-format=github ${{ steps.changed-files.outputs.all_changed_files }} From 72f8bd6f302fd4797958748a1a61b766470a5ea4 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Tue, 12 Dec 2023 14:27:04 +0100 Subject: [PATCH 5/5] chore(ci): update install-nix-action in CI --- .github/workflows/editorconfig.yml | 2 +- .github/workflows/ruff.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/editorconfig.yml b/.github/workflows/editorconfig.yml index beaecc7..57a0177 100644 --- a/.github/workflows/editorconfig.yml +++ b/.github/workflows/editorconfig.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v20 + - uses: cachix/install-nix-action@v24 - name: "Check EditorConfig" # Python already has Ruff, # and doesn't necessarily have a consistent 4 spaces indent diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 7bd2c06..acbb72a 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -18,7 +18,7 @@ jobs: with: files: | **.py - - uses: cachix/install-nix-action@v20 + - uses: cachix/install-nix-action@v24 - name: "Check Ruff lints" if: steps.changed-files.outputs.any_changed == 'true' run: nix run 'nixpkgs#ruff' -- check . --output-format=github ${{ steps.changed-files.outputs.all_changed_files }}