From e17c521c15746e326f800dc67e2fb3e211c9d3bb Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Thu, 7 Nov 2024 15:24:37 -0700 Subject: [PATCH] Run integration tests on GitHub Actions --- .github/workflows/build.yml | 47 +++++++++++++++++++++++++++++++++++++ flake.lock | 21 +++++++++++++++++ flake.nix | 20 +++++++++++++++- 3 files changed, 87 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b5415f..477eeb9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,3 +49,50 @@ jobs: - name: Build manual run: nix build .#manual -L + + nix-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4.1.7 + + - uses: DeterminateSystems/nix-installer-action@v14 + continue-on-error: true # Self-hosted runners already have Nix installed + + - name: Enable Binary Cache + uses: cachix/cachix-action@v12 + with: + name: colmena + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + + - id: set-matrix + name: Generate Nix Matrix + run: | + set -Eeu + matrix="$(nix eval --json '.#githubActions.matrix')" + echo "matrix=$matrix" >> "$GITHUB_OUTPUT" + + nix-matrix-job: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + needs: + - build + - nix-matrix + strategy: + matrix: ${{ fromJSON(needs.nix-matrix.outputs.matrix) }} + steps: + - uses: actions/checkout@v4.1.7 + + - uses: DeterminateSystems/nix-installer-action@v14 + continue-on-error: true # Self-hosted runners already have Nix installed + + - name: Enable Binary Cache + uses: cachix/cachix-action@v12 + with: + name: colmena + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + + - name: Build ${{ matrix.attr }} + run: | + nix build --no-link --print-out-paths -L '.#${{ matrix.attr }}' diff --git a/flake.lock b/flake.lock index 365a9e4..b24e14b 100644 --- a/flake.lock +++ b/flake.lock @@ -31,6 +31,26 @@ "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729742964, + "narHash": "sha256-B4mzTcQ0FZHdpeWcpDYPERtyjJd/NIuaQ9+BV1h+MpA=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "e04df33f62cdcf93d73e9a04142464753a16db67", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1730785428, @@ -51,6 +71,7 @@ "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", + "nix-github-actions": "nix-github-actions", "nixpkgs": "nixpkgs", "stable": "stable" } diff --git a/flake.nix b/flake.nix index c9ba039..a00ae53 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,11 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; stable.url = "github:NixOS/nixpkgs/nixos-24.05"; + nix-github-actions = { + url = "github:nix-community/nix-github-actions"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-utils.url = "github:numtide/flake-utils"; flake-compat = { @@ -13,7 +18,14 @@ }; }; - outputs = { self, nixpkgs, stable, flake-utils, ... } @ inputs: let + outputs = { + self, + nixpkgs, + stable, + flake-utils, + nix-github-actions, + ... + } @ inputs: let supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; colmenaOptions = import ./src/nix/hive/options.nix; colmenaModules = import ./src/nix/hive/modules.nix; @@ -136,6 +148,12 @@ inherit rawHive colmenaOptions colmenaModules; hermetic = true; }; + + githubActions = nix-github-actions.lib.mkGithubMatrix { + checks = { + inherit (self.checks) x86_64-linux; + }; + }; }; nixConfig = {