From 117579cae0c98cf80b68f2d670d12a72bc48da2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignas=20Vy=C5=A1niauskas?= Date: Thu, 28 Nov 2024 15:44:29 +0000 Subject: [PATCH 1/4] Fix manual kiosk-dual-screen test --- testing/manual/kiosk-dual-screen.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/testing/manual/kiosk-dual-screen.nix b/testing/manual/kiosk-dual-screen.nix index de839b20..f44c0887 100644 --- a/testing/manual/kiosk-dual-screen.nix +++ b/testing/manual/kiosk-dual-screen.nix @@ -5,14 +5,15 @@ # Run using: # $(nix-build -A driverInteractive kiosk-dual-screen.nix)/bin/nixos-test-driver --no-interactive let - pkgs = import ../pkgs { }; + pkgs = import ../../pkgs { }; serverPort = 8080; kioskUrl = "http://localhost:${toString serverPort}/"; - kiosk = import ../kiosk { + kiosk = import ../../kiosk { pkgs = pkgs; system_name = "PlayOS"; system_version = "1.0.0"; }; + sessionName = "kiosk-browser"; inherit (builtins) toString; in pkgs.nixosTest { @@ -84,7 +85,7 @@ pkgs.nixosTest { #enableOCR = true; testScript = '' - ${builtins.readFile ./helpers/nixos-test-script-helpers.py} + ${builtins.readFile ../helpers/nixos-test-script-helpers.py} import time import tempfile import diffimg # type: ignore From 1dce72358a52327401ed4fb7669bf4800e87089d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignas=20Vy=C5=A1niauskas?= Date: Fri, 29 Nov 2024 07:54:40 +0000 Subject: [PATCH 2/4] Run manual integration tests as part of ./testing/run --- testing/run | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/testing/run b/testing/run index fab96559..61be6fd4 100755 --- a/testing/run +++ b/testing/run @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -euxo pipefail +SKIP_MANUAL=${SKIP_MANUAL:-} + # Integration tests INTEGRATION_TEST_DIR="$(dirname "$(realpath "$0")")/integration" @@ -9,6 +11,19 @@ for TEST_DEF in $(ls "$INTEGRATION_TEST_DIR"/*.nix); do NIXPKGS_ALLOW_UNFREE=1 nix-build "$TEST_DEF" done +# Manual integration tests + +MANUAL_TEST_DIR="$(dirname "$(realpath "$0")")/manual" + +if [ -z "$SKIP_MANUAL" ]; then + for TEST_DEF in $(ls "$MANUAL_TEST_DIR"/*.nix); do + outDir=$(nix-build -A driverInteractive "$TEST_DEF") + "${outDir}/bin/nixos-test-driver" --no-interactive + done +else + echo "Skipping manual tests" +fi + # Kiosk browser pushd "$(dirname "$(realpath "$0")")/../kiosk" From ff56ab1ee4d4a1280d68179cd69cab303bd67769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignas=20Vy=C5=A1niauskas?= Date: Fri, 29 Nov 2024 08:02:57 +0000 Subject: [PATCH 3/4] Add manual test _builds_ to the CI workflow --- .github/workflows/test.yml | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 428b47f0..e90847f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,14 +6,20 @@ jobs: prepare-matrix: runs-on: ubuntu-latest outputs: - integration_tests: ${{ steps.set-matrix.outputs.integration_tests }} + integration_tests: ${{ steps.set-matrix-integration.outputs.integration_tests }} + manual_tests: ${{ steps.set-matrix-manual.outputs.manual_tests }} steps: - uses: actions/checkout@v4 - - id: set-matrix + - id: set-matrix-integration run: | FILES=$(find testing/integration -name '*.nix' -printf '"%p",') FILES_JSON="[${FILES%,}]" echo "integration_tests=${FILES_JSON}" >> $GITHUB_OUTPUT + - id: set-matrix-manual + run: | + FILES=$(find testing/manual -name '*.nix' -printf '"%p",') + FILES_JSON="[${FILES%,}]" + echo "manual_tests=${FILES_JSON}" >> $GITHUB_OUTPUT integration-tests: needs: prepare-matrix @@ -34,6 +40,27 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v8 - run: NIXPKGS_ALLOW_UNFREE=1 nix-build ${{ matrix.file }} + + manual-tests-build-only: + needs: prepare-matrix + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + file: ${{fromJson(needs.prepare-matrix.outputs.manual_tests)}} + steps: + - name: Ensure KVM is usable by nix-build + run: sudo chmod a+rwx /dev/kvm + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v18 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + system-features = nixos-test benchmark big-parallel kvm + - uses: DeterminateSystems/magic-nix-cache-action@v8 + - run: NIXPKGS_ALLOW_UNFREE=1 nix-build -A driverInteractive ${{ matrix.file }} + + kiosk-tests: runs-on: ubuntu-latest steps: From dc330979d60798e2ed0d17cf40b41c5f723afbf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignas=20Vy=C5=A1niauskas?= Date: Fri, 29 Nov 2024 08:15:20 +0000 Subject: [PATCH 4/4] Move out common steps CI to a composite action --- .github/actions/prep-build-env/action.yml | 13 +++++ .github/workflows/test.yml | 59 +++-------------------- 2 files changed, 21 insertions(+), 51 deletions(-) create mode 100644 .github/actions/prep-build-env/action.yml diff --git a/.github/actions/prep-build-env/action.yml b/.github/actions/prep-build-env/action.yml new file mode 100644 index 00000000..8edaf3b4 --- /dev/null +++ b/.github/actions/prep-build-env/action.yml @@ -0,0 +1,13 @@ +name: "Prepare nix build environment" +runs: + using: "composite" + steps: + - name: Ensure KVM is usable by nix-build + run: sudo chmod a+rwx /dev/kvm + shell: bash + - uses: cachix/install-nix-action@v18 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + system-features = nixos-test benchmark big-parallel kvm + - uses: DeterminateSystems/magic-nix-cache-action@v8 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e90847f3..3597f03c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,15 +29,8 @@ jobs: matrix: file: ${{fromJson(needs.prepare-matrix.outputs.integration_tests)}} steps: - - name: Ensure KVM is usable by nix-build - run: sudo chmod a+rwx /dev/kvm - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v18 - with: - nix_path: nixpkgs=channel:nixos-unstable - extra_nix_config: | - system-features = nixos-test benchmark big-parallel kvm - - uses: DeterminateSystems/magic-nix-cache-action@v8 + - uses: ./.github/actions/prep-build-env - run: NIXPKGS_ALLOW_UNFREE=1 nix-build ${{ matrix.file }} @@ -49,15 +42,8 @@ jobs: matrix: file: ${{fromJson(needs.prepare-matrix.outputs.manual_tests)}} steps: - - name: Ensure KVM is usable by nix-build - run: sudo chmod a+rwx /dev/kvm - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v18 - with: - nix_path: nixpkgs=channel:nixos-unstable - extra_nix_config: | - system-features = nixos-test benchmark big-parallel kvm - - uses: DeterminateSystems/magic-nix-cache-action@v8 + - uses: ./.github/actions/prep-build-env - run: NIXPKGS_ALLOW_UNFREE=1 nix-build -A driverInteractive ${{ matrix.file }} @@ -65,46 +51,27 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v18 - with: - nix_path: nixpkgs=channel:nixos-unstable - extra_nix_config: | - system-features = nixos-test benchmark big-parallel kvm - - uses: DeterminateSystems/magic-nix-cache-action@v8 + - uses: ./.github/actions/prep-build-env - run: cd kiosk && nix-shell --run bin/test build-vm: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v18 - with: - nix_path: nixpkgs=channel:nixos-unstable - extra_nix_config: | - system-features = nixos-test benchmark big-parallel kvm - - uses: DeterminateSystems/magic-nix-cache-action@v8 + - uses: ./.github/actions/prep-build-env - run: NIXPKGS_ALLOW_UNFREE=1 ./build vm e2e-tests: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/prep-build-env - name: Make more space available on the runner run: | sudo rm -rf /usr/share/dotnet \ /usr/local/lib/android \ /opt/ghc \ /opt/hostedtoolcache/CodeQL - - - name: Ensure KVM is usable by nix-build - run: sudo chmod a+rwx /dev/kvm - - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v18 - with: - nix_path: nixpkgs=channel:nixos-unstable - extra_nix_config: | - system-features = nixos-test benchmark big-parallel kvm - - uses: DeterminateSystems/magic-nix-cache-action@v8 - name: Make magic-nix-cache read-only by removing post-build-hook run: sed -i '/post-build-hook = magic-nix-cache-build-hook/d' $HOME/.config/nix/nix.conf - run: ./build test-e2e @@ -116,22 +83,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v18 - with: - nix_path: nixpkgs=channel:nixos-unstable - extra_nix_config: | - system-features = nixos-test benchmark big-parallel kvm - - uses: DeterminateSystems/magic-nix-cache-action@v8 + - uses: ./.github/actions/prep-build-env - run: cd controller && nix-shell --run 'bin/test --force --no-buffer' ocaml-formatting: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v18 - with: - nix_path: nixpkgs=channel:nixos-unstable - extra_nix_config: | - system-features = nixos-test benchmark big-parallel kvm - - uses: DeterminateSystems/magic-nix-cache-action@v8 + - uses: ./.github/actions/prep-build-env - run: cd controller && nix-shell --run 'dune build @fmt'