Skip to content

Commit 6da5324

Browse files
committed
Run CI on a matrix of OSes and platforms
1 parent 1d58bbd commit 6da5324

File tree

3 files changed

+62
-65
lines changed

3 files changed

+62
-65
lines changed

Diff for: .github/workflows/ci.yml

+24-59
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,32 @@ on: [push, pull_request]
33
name: CI
44

55
jobs:
6-
check:
7-
name: Check
6+
nix-matrix:
87
runs-on: ubuntu-latest
8+
outputs:
9+
matrix: ${{ steps.set-matrix.outputs.matrix }}
910
steps:
10-
- uses: actions/checkout@v3
11-
- uses: actions-rs/toolchain@v1
12-
with:
13-
profile: minimal
14-
toolchain: stable
15-
override: true
16-
- uses: actions-rs/cargo@v1
17-
with:
18-
command: check
19-
20-
# TODO: the build for this started failing in 1b34a74891423e118c567368c95b7e04f3b9ca63
21-
#test:
22-
# name: Test Suite
23-
# runs-on: ubuntu-latest
24-
# steps:
25-
# - uses: actions/checkout@v2
26-
# - uses: actions-rs/toolchain@v1
27-
# with:
28-
# profile: minimal
29-
# toolchain: stable
30-
# override: true
31-
# - uses: actions-rs/cargo@v1
32-
# with:
33-
# command: test
11+
- uses: actions/checkout@v4
12+
- uses: cachix/install-nix-action@v30
13+
- id: set-matrix
14+
name: Generate Nix Matrix
15+
run: |
16+
set -Eeu
17+
matrix="$(nix eval --json '.#githubActions.matrix')"
18+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
3419
35-
fmt:
36-
name: Rustfmt
37-
runs-on: ubuntu-latest
38-
steps:
39-
- uses: actions/checkout@v3
40-
- uses: actions-rs/toolchain@v1
41-
with:
42-
profile: minimal
43-
toolchain: stable
44-
override: true
45-
- run: rustup component add rustfmt
46-
- uses: actions-rs/cargo@v1
47-
with:
48-
command: fmt
49-
50-
cargo-deny:
51-
runs-on: ubuntu-latest
52-
steps:
53-
- uses: actions/checkout@v3
54-
- uses: EmbarkStudios/cargo-deny-action@v1
55-
56-
clippy:
57-
name: Clippy
58-
runs-on: ubuntu-latest
20+
check:
21+
name: ${{ matrix.name }} (${{ matrix.system }})
22+
needs: nix-matrix
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
5926
steps:
60-
- uses: actions/checkout@v3
61-
- uses: actions-rs/toolchain@v1
62-
with:
63-
profile: minimal
64-
toolchain: stable
65-
override: true
66-
- run: rustup component add clippy
67-
- uses: actions-rs/cargo@v1
27+
- uses: actions/checkout@v4
28+
- uses: cachix/install-nix-action@v30
29+
- name: Authenticate with Cachix
30+
uses: cachix/cachix-action@v15
6831
with:
69-
command: clippy
32+
name: rgit
33+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
34+
- run: nix build -L '.#${{ matrix.attr }}'

Diff for: flake.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: flake.nix

+17-6
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,20 @@
1515
url = "github:JordanForks/helix";
1616
flake = false;
1717
};
18+
19+
nix-github-actions = {
20+
url = "github:nix-community/nix-github-actions";
21+
inputs.nixpkgs.follows = "nixpkgs";
22+
};
1823
};
1924

20-
outputs = { self, nixpkgs, utils, crane, advisory-db, treefmt-nix, helix }:
25+
outputs = { self, nixpkgs, utils, crane, advisory-db, treefmt-nix, helix, nix-github-actions }:
26+
{
27+
githubActions = nix-github-actions.lib.mkGithubMatrix {
28+
checks = { inherit (self.checks) x86_64-linux x86_64-darwin aarch64-darwin; };
29+
};
30+
}
31+
//
2132
utils.lib.eachDefaultSystem (system:
2233
let
2334
pkgs = import nixpkgs { inherit system; };
@@ -57,11 +68,11 @@
5768
in
5869
{
5970
checks = {
60-
inherit rgit;
61-
rgit-clippy = craneLib.cargoClippy buildArgs;
62-
rgit-doc = craneLib.cargoDoc buildArgs;
63-
rgit-audit = craneLib.cargoAudit { inherit advisory-db; src = cargoOnlySrc; };
64-
rgit-test = craneLib.cargoNextest (buildArgs // {
71+
build = rgit;
72+
clippy = craneLib.cargoClippy buildArgs;
73+
doc = craneLib.cargoDoc buildArgs;
74+
audit = craneLib.cargoAudit { inherit advisory-db; src = cargoOnlySrc; };
75+
test = craneLib.cargoNextest (buildArgs // {
6576
partitions = 1;
6677
partitionType = "count";
6778
});

0 commit comments

Comments
 (0)