Skip to content

Commit

Permalink
Merge pull request #213 from yfyf/common-ci-steps
Browse files Browse the repository at this point in the history
Cherry-picked CI additions
  • Loading branch information
guyonvarch authored Dec 10, 2024
2 parents d7a33e9 + dc33097 commit 789e73a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 48 deletions.
13 changes: 13 additions & 0 deletions .github/actions/prep-build-env/action.yml
Original file line number Diff line number Diff line change
@@ -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
74 changes: 29 additions & 45 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,61 +29,49 @@ 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 }}


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:
- uses: actions/checkout@v4
- uses: ./.github/actions/prep-build-env
- run: NIXPKGS_ALLOW_UNFREE=1 nix-build -A driverInteractive ${{ matrix.file }}


kiosk-tests:
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
Expand All @@ -89,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'
7 changes: 4 additions & 3 deletions testing/manual/kiosk-dual-screen.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions testing/run
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -euxo pipefail

SKIP_MANUAL=${SKIP_MANUAL:-}

# Integration tests

INTEGRATION_TEST_DIR="$(dirname "$(realpath "$0")")/integration"
Expand All @@ -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"
Expand Down

0 comments on commit 789e73a

Please sign in to comment.