Run CI on a matrix of OSes and platforms
Diff
flake.lock | 21 +++++++++++++++++++++
flake.nix | 23 +++++++++++++++++++----
.github/workflows/ci.yml | 91 +++++++++++++++++++++++++++++++++++++++++++-------------------------------------
3 files changed, 66 insertions(+), 69 deletions(-)
@@ -47,6 +47,26 @@
"type": "github"
}
},
"nix-github-actions": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1731952509,
"narHash": "sha256-p4gB3Rhw8R6Ak4eMl8pqjCPOLCZRqaehZxdZ/mbFClM=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "7b5f051df789b6b20d259924d349a9ba3319b226",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-github-actions",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1727731257,
@@ -84,6 +104,7 @@
"advisory-db": "advisory-db",
"crane": "crane",
"helix": "helix",
"nix-github-actions": "nix-github-actions",
"nixpkgs": "nixpkgs",
"treefmt-nix": "treefmt-nix",
"utils": "utils"
@@ -15,9 +15,20 @@
url = "github:JordanForks/helix";
flake = false;
};
nix-github-actions = {
url = "github:nix-community/nix-github-actions";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, utils, crane, advisory-db, treefmt-nix, helix }:
outputs = { self, nixpkgs, utils, crane, advisory-db, treefmt-nix, helix, nix-github-actions }:
{
githubActions = nix-github-actions.lib.mkGithubMatrix {
checks = { inherit (self.checks) x86_64-linux x86_64-darwin aarch64-darwin; };
};
}
//
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
@@ -57,11 +68,11 @@
in
{
checks = {
inherit rgit;
rgit-clippy = craneLib.cargoClippy buildArgs;
rgit-doc = craneLib.cargoDoc buildArgs;
rgit-audit = craneLib.cargoAudit { inherit advisory-db; src = cargoOnlySrc; };
rgit-test = craneLib.cargoNextest (buildArgs // {
build = rgit;
clippy = craneLib.cargoClippy buildArgs;
doc = craneLib.cargoDoc buildArgs;
audit = craneLib.cargoAudit { inherit advisory-db; src = cargoOnlySrc; };
test = craneLib.cargoNextest (buildArgs // {
partitions = 1;
partitionType = "count";
});
@@ -1,69 +1,34 @@
on: [push, pull_request]
name: CI
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
cargo-deny:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
check:
name: ${{ matrix.name }} (${{ matrix.system }})
needs: nix-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- name: Authenticate with Cachix
uses: cachix/cachix-action@v15
with:
name: rgit
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: nix build -L '.#${{ matrix.attr }}'