Skip to content

Commit

Permalink
feat: Added nix-flake-matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
uttarayan21 committed Sep 7, 2024
1 parent e6d918f commit d67d4d6
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 20 deletions.
64 changes: 46 additions & 18 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,53 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
checks-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
checks-build:
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@v27
- run: nix build -L '.#${{ matrix.attr }}'

docs:
- name: Exit if not on master branch
if: github.ref == 'refs/heads/master'
run: exit 0

- name: Generate docs
run: nix build .#checks.x86_64-linux.mnn-docs

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: result/share/doc/mnn

- name: Deploy to gh-pages
id: deployment
uses: actions/deploy-pages@v4

codecov:
runs-on: ubuntu-latest
permissions:
id-token: "write"
Expand All @@ -23,9 +68,6 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main

- name: Run `nix flake check`
run: nix flake check

- name: Run codecov
run: nix build .#mnn-llvm-cov

Expand All @@ -39,17 +81,3 @@ jobs:
files: ./result
verbose: true

- name: Generate docs
run: nix build .#x86_64-linux.mnn-docs

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: result/share/doc/mnn

- name: Deploy to gh-pages
id: deployment
uses: actions/deploy-pages@v4
21 changes: 21 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
nix-github-actions = {
url = "github:nix-community/nix-github-actions";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -26,9 +30,10 @@
rust-overlay,
mnn-overlay,
advisory-db,
nix-github-actions,
...
}:
flake-utils.lib.eachDefaultSystem (
}: let
out = flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system;
Expand Down Expand Up @@ -151,4 +156,9 @@
};
}
);
in
out
// {
githubActions = nix-github-actions.lib.mkGithubMatrix {checks = out.x86_64-linux.packages;};
};
}

0 comments on commit d67d4d6

Please sign in to comment.