From 1bf250402143572d6f22b074d9c8354d389f425c Mon Sep 17 00:00:00 2001 From: Astrid Yu Date: Tue, 14 Mar 2023 21:52:51 -0700 Subject: [PATCH 1/4] Add check derivation --- checks/README.md | 3 +++ checks/default.nix | 10 ++++++++++ checks/smoke-test-simple/default.nix | 7 +++++++ flake.nix | 5 +++++ 4 files changed, 25 insertions(+) create mode 100644 checks/README.md create mode 100644 checks/default.nix create mode 100644 checks/smoke-test-simple/default.nix diff --git a/checks/README.md b/checks/README.md new file mode 100644 index 0000000..0704b37 --- /dev/null +++ b/checks/README.md @@ -0,0 +1,3 @@ +# Integration tests + +This directory contains integration tests and other checks (Nix-based). Unit tests are embedded in `/src`. diff --git a/checks/default.nix b/checks/default.nix new file mode 100644 index 0000000..1a85825 --- /dev/null +++ b/checks/default.nix @@ -0,0 +1,10 @@ +{ self, nixpkgs, ... }: +system: +let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + }; +in { + smoke-test-simple = pkgs.callPackage ./smoke-test-simple { }; +} diff --git a/checks/smoke-test-simple/default.nix b/checks/smoke-test-simple/default.nix new file mode 100644 index 0000000..fac1eab --- /dev/null +++ b/checks/smoke-test-simple/default.nix @@ -0,0 +1,7 @@ +{ lib, caligula, runCommand }: +runCommand "caligula-smoke-test-simple" { + buildInputs = [ caligula ]; + meta.timeout = 10; +} '' + caligula -h > $out +'' diff --git a/flake.nix b/flake.nix index 9dcb0d6..810d9c7 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,9 @@ outputs = { self, nixpkgs, flake-utils, naersk, rust-overlay }@inputs: { lib = import ./nix inputs; + overlays.default = final: prev: { + caligula = self.packages.${prev.system}.caligula; + }; } // (let @@ -25,6 +28,8 @@ crossHelpers = self.lib.crossHelpers system; in { + checks = import ./checks inputs system; + packages = { default = self.packages."${system}".caligula; scripts = { From 860827cb6bab5b8bef0265f2b408c021d05e1cc6 Mon Sep 17 00:00:00 2001 From: Astrid Yu Date: Tue, 14 Mar 2023 21:55:47 -0700 Subject: [PATCH 2/4] Use `nix flake check` --- .github/workflows/ci-unix.yml | 4 ++-- .github/workflows/ci.yml | 4 ++-- flake.nix | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-unix.yml b/.github/workflows/ci-unix.yml index 37f892c..45aa728 100644 --- a/.github/workflows/ci-unix.yml +++ b/.github/workflows/ci-unix.yml @@ -47,9 +47,9 @@ jobs: name: ${{ env.artifact }} path: result/bin/caligula - - name: e2e test + - name: Run checks if: inputs.do_e2e_tests - run: nix run ${{ env.nix_target }} -- --help + run: nix flake check --keep-going e2e-test-fresh: name: e2e test on fresh ${{ inputs.e2e_test_runner }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b36a74e..49f7289 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,10 @@ jobs: extra-platforms = ${{ inputs.target_triple }} - name: Prefetch lint script dependencies - run: nix build .#scripts.lint + run: nix build .#lint-script - name: Run lint script - run: nix run .#scripts.lint + run: nix run .#lint-script ci-x86_64-linux: uses: ./.github/workflows/ci-unix.yml diff --git a/flake.nix b/flake.nix index 810d9c7..7b644d0 100644 --- a/flake.nix +++ b/flake.nix @@ -32,13 +32,13 @@ packages = { default = self.packages."${system}".caligula; - scripts = { - lint = let path = lib.makeBinPath [ crossHelpers.baseToolchain ]; + + lint-script = + let path = lib.makeBinPath [ crossHelpers.baseToolchain ]; in pkgs.writeScriptBin "lint" '' export PATH=${path} ${./scripts/lint.sh} ''; - }; caligula = self.packages."${system}"."caligula-${system}"; } // crossHelpers.caligulaPackages; From 4e135cc8140e37e6a33f284e3b5090ea0a8326bf Mon Sep 17 00:00:00 2001 From: Astrid Yu Date: Tue, 14 Mar 2023 22:02:12 -0700 Subject: [PATCH 3/4] Make a release job that packages all artifacts --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49f7289..ed0b8fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,3 +69,27 @@ jobs: authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - name: Build dev shell run: nix build .#devShells.${{ matrix.platform }}.default --show-trace --log-lines 10000 --fallback + + make-release-group: + runs-on: ubuntu-latest + needs: + - ci-aarch64-linux + - ci-x86_64-darwin + - ci-x86_64-linux + steps: + - name: Download all artifacts + uses: actions/download-artifact@v3 + + - name: Assemble release directory + run: | + mkdir release + for i in caligula-*; do + cp "$i/caligula" "release/$i" + done + + tree + + - uses: actions/upload-artifact@v3 + with: + name: release + path: release From 8d06fac085a4ca9e758ae5afc77b7dbd2e4db8fc Mon Sep 17 00:00:00 2001 From: Astrid Yu Date: Tue, 14 Mar 2023 22:11:46 -0700 Subject: [PATCH 4/4] Remove the PR event trigger on CI --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed0b8fc..964445a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,6 @@ name: "CI" on: push: - pull_request: jobs: lint: