Browse Source

ci/nix: don't force Nix shell on everyone + fix CI

Philipp Schuster 1 year ago
parent
commit
f4419fb1ce

+ 9 - 2
.github/workflows/rust.yml

@@ -129,7 +129,7 @@ jobs:
       features: builder,unstable
 
   integrationtest:
-    name: multiboot2 integrationtest
+    name: integrationtest
     needs:
       - build_nightly
       - build_nostd_nightly
@@ -138,4 +138,11 @@ jobs:
       - name: Check out
         uses: actions/checkout@v3
       - uses: cachix/install-nix-action@v20
-      - run: integration-test/run.sh
+        with:
+          # This channel is only required to invoke "nix-shell".
+          # Everything inside that nix-shell will use a pinned version of
+          # nixpkgs.
+          nix_path: nixpkgs=channel:nixos-23.05
+      - run: |
+          cd integration-test
+          nix-shell --run ./run.sh

+ 0 - 35
integration-test/.run.sh

@@ -1,35 +0,0 @@
-#!/usr/bin/env bash
-
-# http://redsymbol.net/articles/unofficial-bash-strict-mode/
-set -euo pipefail
-IFS=$'\n\t'
-
-DIR=$(dirname "$(realpath "$0")")
-cd "$DIR" || exit
-
-function fn_main() {
-    fn_build_rust_bins
-    fn_multiboot2_integrationtest
-    fn_multiboot2_header_integrationtest
-}
-
-function fn_build_rust_bins() {
-    cd "bins"
-    cargo build --release
-    cd "$DIR"
-}
-
-function fn_multiboot2_integrationtest() {
-    cd tests/multiboot2
-    ./build_img.sh
-    ./run_qemu.sh
-    cd "$DIR"
-}
-
-function fn_multiboot2_header_integrationtest() {
-    cd tests/multiboot2-header
-    ./run_qemu.sh
-    cd "$DIR"
-}
-
-fn_main

+ 9 - 3
integration-test/README.md

@@ -10,8 +10,14 @@ directory contains test definitions, run scripts, and other relevant files. The
 main entry to run all tests is `./run.sh` in this directory.
 
 ## TL;DR:
-- `$ ./run.sh` to execute the integration tests
+- `$ nix-shell --run ./run.sh` to execute the integration tests with Nix (recommended)
+- `$ ./run.sh` to execute the integration tests (you have to install dependencies manually)
 
 ## Prerequisites
-The tests rely on [`nix`](https://nixos.org/) being installed / `nix-shell`
-being available to get the relevant tools.
+The tests are executed best when using [`nix`](https://nixos.org/)/`nix-shell`
+to get the relevant tools. Otherwise, please make sure the following packages
+are available:
+- grub helper tools
+- rustup
+- QEMU
+- xorriso

+ 30 - 2
integration-test/run.sh

@@ -1,7 +1,35 @@
 #!/usr/bin/env bash
 
+# http://redsymbol.net/articles/unofficial-bash-strict-mode/
+set -euo pipefail
+IFS=$'\n\t'
+
 DIR=$(dirname "$(realpath "$0")")
 cd "$DIR" || exit
 
-# Helper script that runs the actual script in a Nix shell.
-nix-shell --run ./.run.sh
+function fn_main() {
+    fn_build_rust_bins
+    fn_multiboot2_integrationtest
+    fn_multiboot2_header_integrationtest
+}
+
+function fn_build_rust_bins() {
+    cd "bins"
+    cargo build --release
+    cd "$DIR"
+}
+
+function fn_multiboot2_integrationtest() {
+    cd tests/multiboot2
+    ./build_img.sh
+    ./run_qemu.sh
+    cd "$DIR"
+}
+
+function fn_multiboot2_header_integrationtest() {
+    cd tests/multiboot2-header
+    ./run_qemu.sh
+    cd "$DIR"
+}
+
+fn_main

+ 5 - 0
integration-test/shell.nix

@@ -9,4 +9,9 @@ pkgs.mkShell rec {
     rustup
     xorriso
   ];
+
+  # To invoke "nix-shell" in the CI-runner, we need a global Nix channel.
+  # For better reproducibility inside the Nix shell, we override this channel
+  # with the pinned nixpkgs version.
+  NIX_PATH = "nixpkgs=${sources.nixpkgs}";
 }