From 738d14f3c033e8dc26b8d374872e5bd515e7a1fc Mon Sep 17 00:00:00 2001 From: Chen Chengjun Date: Mon, 12 Jan 2026 03:10:11 +0000 Subject: [PATCH] Modify the CI workflows --- .github/workflows/publish_aster_nixos.yml | 8 +-- .github/workflows/push_cachix_dev.yml | 8 +-- .github/workflows/test_iso_image.yml | 6 +- .github/workflows/test_nixos_full.yml | 57 +++++-------------- .github/workflows/test_nixos_minimal.yml | 11 ++-- .../config_for_publish_cachix.nix | 12 ++++ 6 files changed, 37 insertions(+), 65 deletions(-) create mode 100644 tools/github_workflows/config_for_publish_cachix.nix diff --git a/.github/workflows/publish_aster_nixos.yml b/.github/workflows/publish_aster_nixos.yml index 111951974..28aaa8e56 100644 --- a/.github/workflows/publish_aster_nixos.yml +++ b/.github/workflows/publish_aster_nixos.yml @@ -20,11 +20,9 @@ jobs: - name: Modify configuration.nix to include xfce and podman run: | - sed -i \ - -e 's/^[[:space:]]*# services\.xserver\.enable = true;/ services.xserver.enable = true;/' \ - -e 's/^[[:space:]]*# services\.xserver\.desktopManager\.xfce\.enable = true;/ services.xserver.desktopManager.xfce.enable = true;/' \ - -e 's/^[[:space:]]*# virtualisation\.podman\.enable = true;/ virtualisation.podman.enable = true;/' \ - distro/etc_nixos/configuration.nix + config_path="distro/etc_nixos/configuration.nix" + extra_config_path="tools/github_workflows/config_for_publish_cachix.nix" + ./test/nixos/common/merge_nixos_config.sh ${config_path} ${extra_config_path} ${config_path} - name: Build Asterinas NixOS patched packages and push to release cache run: | diff --git a/.github/workflows/push_cachix_dev.yml b/.github/workflows/push_cachix_dev.yml index 0e2c9ee7a..2b839b6de 100644 --- a/.github/workflows/push_cachix_dev.yml +++ b/.github/workflows/push_cachix_dev.yml @@ -25,11 +25,9 @@ jobs: - name: Modify configuration.nix to include xfce and podman run: | - sed -i \ - -e 's/^[[:space:]]*# services\.xserver\.enable = true;/ services.xserver.enable = true;/' \ - -e 's/^[[:space:]]*# services\.xserver\.desktopManager\.xfce\.enable = true;/ services.xserver.desktopManager.xfce.enable = true;/' \ - -e 's/^[[:space:]]*# virtualisation\.podman\.enable = true;/ virtualisation.podman.enable = true;/' \ - distro/etc_nixos/configuration.nix + config_path="distro/etc_nixos/configuration.nix" + extra_config_path="tools/github_workflows/config_for_publish_cachix.nix" + ./test/nixos/common/merge_nixos_config.sh ${config_path} ${extra_config_path} ${config_path} - name: Build Asterinas NixOS patched packages (dry run) if: github.event_name == 'pull_request' diff --git a/.github/workflows/test_iso_image.yml b/.github/workflows/test_iso_image.yml index 7b4f020ef..0ec56d17e 100644 --- a/.github/workflows/test_iso_image.yml +++ b/.github/workflows/test_iso_image.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v4 - name: Build Asterinas NixOS ISO installer image run: | - make iso NIXOS_TEST_COMMAND='hello-asterinas' + make iso NIXOS_TEST_SUITE=hello - name: Run ISO image and install Asterinas NixOS run: | make run_iso || true @@ -34,6 +34,4 @@ jobs: echo "Test ISO succeeds!" - name : Run Asterinas NixOS run: | - make run_nixos || true - tail --lines 10 qemu.log | grep -q "^Hello Asterinas!" || (echo "Test NixOS failed" && exit 1) - echo "Test NixOS succeeds!" + make run_nixos NIXOS_TEST_SUITE=hello \ No newline at end of file diff --git a/.github/workflows/test_nixos_full.yml b/.github/workflows/test_nixos_full.yml index d18141078..7a0dfedb1 100644 --- a/.github/workflows/test_nixos_full.yml +++ b/.github/workflows/test_nixos_full.yml @@ -28,52 +28,21 @@ jobs: container: image: asterinas/asterinas:0.17.0-20251228 options: -v /dev:/dev --privileged - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - - name: Modify configuration.nix to include test-asterinas - run: | - sed -i 's/environment.systemPackages = with pkgs; \[ hello-asterinas \];/environment.systemPackages = with pkgs; \[ test-asterinas \];/' \ - distro/etc_nixos/configuration.nix + + strategy: + fail-fast: false + matrix: + test: + - name: nix + disk_size: 6144 + - name: podman + disk_size: 8192 - - name: Test nix commands - run: | - make nixos NIXOS_DISK_SIZE_IN_MB=6144 NIXOS_TEST_COMMAND='test-nix-commands' - make run_nixos - - - name: Check results - run: | - tail --lines 50 qemu.log | awk ' - BEGIN { hello_count=0 } { - if ($0 ~ /^Hello, world!/) hello_count++ - } - END { - if (hello_count == 4) exit 0 - else exit 1 - }' || (echo "Test nix commands failed" && exit 1) - echo "Test nix commands succeeds!" - - podman-test: - runs-on: ubuntu-4-cores-150GB-ssd - container: - image: asterinas/asterinas:0.17.0-20251228 - options: -v /dev:/dev --privileged + name: Test ${{ matrix.test.name }} timeout-minutes: 30 steps: - uses: actions/checkout@v4 - - name: Modify configuration.nix to include test-asterinas and podman + - name: Run the ${{ matrix.test.name }} test on AsterNixOS run: | - sed -i \ - -e 's/environment.systemPackages = with pkgs; \[ hello-asterinas \];/environment.systemPackages = with pkgs; \[ test-asterinas \];/' \ - -e 's/^[[:space:]]*# virtualisation\.podman\.enable = true;/ virtualisation.podman.enable = true;/' \ - distro/etc_nixos/configuration.nix - - - name: Run podman commands - run: | - make nixos NIXOS_DISK_SIZE_IN_MB=8192 NIXOS_TEST_COMMAND='test-podman' - make run_nixos - - - name: Check results - run: | - tail --lines 50 qemu.log | grep -q "^Test podman succeeds" || (echo "Test podman failed" && exit 1) - echo "Test podman succeeds!" + make nixos NIXOS_TEST_SUITE=${{ matrix.test.name }} NIXOS_DISK_SIZE_IN_MB=${{ matrix.test.disk_size }} + make run_nixos NIXOS_TEST_SUITE=${{ matrix.test.name }} \ No newline at end of file diff --git a/.github/workflows/test_nixos_minimal.yml b/.github/workflows/test_nixos_minimal.yml index c852ded16..d9005b106 100644 --- a/.github/workflows/test_nixos_minimal.yml +++ b/.github/workflows/test_nixos_minimal.yml @@ -32,15 +32,12 @@ jobs: remove_haskell: true remove_tool_cache: true - uses: actions/checkout@v4 - - name: Run a Hello World program on AsterNixOS + - name: Run the hello test on AsterNixOS + timeout-minutes: 30 uses: addnab/docker-run-action@v3 with: image: asterinas/asterinas:0.17.0-20251228 options: --privileged -v /dev:/dev -v ${{ github.workspace }}:/root/asterinas run: | - make nixos NIXOS_DISK_SIZE_IN_MB=6144 NIXOS_TEST_COMMAND='hello-asterinas' - make run_nixos - - name: Check results - run: | - tail --lines 10 ${{ github.workspace }}/qemu.log | grep -q "^Hello Asterinas!" || (echo "Test NixOS failed" && exit 1) - echo "Test NixOS succeeds!" \ No newline at end of file + make nixos NIXOS_TEST_SUITE=hello NIXOS_DISK_SIZE_IN_MB=6144 + make run_nixos NIXOS_TEST_SUITE=hello \ No newline at end of file diff --git a/tools/github_workflows/config_for_publish_cachix.nix b/tools/github_workflows/config_for_publish_cachix.nix new file mode 100644 index 000000000..1e3574b7f --- /dev/null +++ b/tools/github_workflows/config_for_publish_cachix.nix @@ -0,0 +1,12 @@ +# This configuration file enables all packages and services that are modified +# by Asterinas NixOS. By enabling them, we ensure they are built during the +# evaluation and can subsequently be uploaded to our Cachix binary cache. + +{ config, lib, pkgs, ... }: + +{ + services.xserver.enable = true; + services.xserver.desktopManager.xfce.enable = true; + + virtualisation.podman.enable = true; +}