diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e490921..2c93b8d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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" @@ -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 @@ -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 diff --git a/flake.lock b/flake.lock index 5e7eb21..6a35de4 100644 --- a/flake.lock +++ b/flake.lock @@ -105,6 +105,26 @@ "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1720066371, + "narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "622f829f5fe69310a866c8a6cd07e747c44ef820", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1725103162, @@ -127,6 +147,7 @@ "crane": "crane", "flake-utils": "flake-utils", "mnn-overlay": "mnn-overlay", + "nix-github-actions": "nix-github-actions", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" } diff --git a/flake.nix b/flake.nix index 1f164e5..8346048 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; @@ -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; @@ -151,4 +156,9 @@ }; } ); + in + out + // { + githubActions = nix-github-actions.lib.mkGithubMatrix {checks = out.x86_64-linux.packages;}; + }; }