From 3a4ce809895e25bdec6f057945eb6a859c9d8083 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Tue, 3 Oct 2023 05:45:33 +0000 Subject: [PATCH] ci: Parallelize Signed-off-by: Nick Spinale --- .github/workflows/push.yaml | 129 ++++++++++++++++++++++------- Makefile | 30 +++++-- hacking/ci/github-actions/Makefile | 17 +--- hacking/nix/top-level/default.nix | 23 ++--- 4 files changed, 137 insertions(+), 62 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index ce74edcd0..ea59eae65 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -6,22 +6,42 @@ on: pull_request: workflow_dispatch: jobs: - build-and-check: - name: Build and check + check-source: + name: Check dependencies runs-on: ubuntu-latest steps: - - name: Prepare to maximize build space - run: sudo mkdir /nix - - name: Maximize build space - uses: easimon/maximize-build-space@master + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: cachix/cachix-action@v12 + with: + name: coliasgroup + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Check dependencies + run: make check-source + check-dependencies: + name: Check dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: cachix/cachix-action@v12 with: - build-mount-path: /nix - root-reserve-mb: 8192 - remove-dotnet: 'true' - remove-android: 'true' - remove-haskell: 'true' - remove-codeql: 'true' - remove-docker-images: 'true' + name: coliasgroup + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Check dependencies + run: make check-dependencies + run-sel4test: + name: Run sel4test + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + arch: [aarch64, aarch32, riscv64, riscv32, x86_64, ia32] + steps: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v22 with: @@ -31,9 +51,52 @@ jobs: name: coliasgroup authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - name: Build and check - run: make -C hacking/ci/github-actions check J=$(nproc) + run: make run-sel4test-for SEL4TEST_ARCH=${{ matrix.arch }} + run-other-tests: + name: Run other tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: cachix/cachix-action@v12 + with: + name: coliasgroup + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Run tests + run: make run-fast-tests + build-docs: + name: Build docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: cachix/cachix-action@v12 + with: + name: coliasgroup + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Build docs + run: make html-links + build-everything: + name: Build everything + runs-on: ubuntu-latest + needs: [check-source, run-sel4test, run-other-tests, build-docs] + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: cachix/cachix-action@v12 + with: + name: coliasgroup + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Build everything + run: make everything - name: Expose docs - run: make -C hacking/ci/github-actions docs + run: make html - name: Upload Pages artifact if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) uses: actions/upload-pages-artifact@v2 @@ -42,7 +105,7 @@ jobs: deploy-docs: name: Deploy docs if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) - needs: build-and-check + needs: [check-dependencies, build-everything] permissions: pages: write id-token: write @@ -54,17 +117,23 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v2 - check-dependencies: - name: Check dependencies - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v22 - with: - nix_path: nixpkgs=channel:nixos-unstable - - uses: cachix/cachix-action@v12 - with: - name: coliasgroup - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: Check dependencies - run: make -C hacking/ci/github-actions check-dependencies + +# NOTE +# +# May be necessary in the future: +# +# - name: Prepare to maximize build space +# run: sudo mkdir /nix +# - name: Maximize build space +# uses: easimon/maximize-build-space@master +# with: +# build-mount-path: /nix +# root-reserve-mb: 8192 +# remove-dotnet: 'true' +# remove-android: 'true' +# remove-haskell: 'true' +# remove-codeql: 'true' +# remove-docker-images: 'true' +# +# For debugging and monitoring disk usage: +# (make foo && df -h) || (df -h && false) diff --git a/Makefile b/Makefile index 3083506e1..05873b2c6 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,20 @@ ifeq ($(K),1) endif ifneq ($(J),) - jobs := -j$(J) + jobs_arg := -j$(J) +else + jobs_arg := -j$$(nproc) +endif + +ifneq ($(CORES),) + cores_arg := --cores $(CORES) +else + cores_arg := endif out := out -nix_build := nix-build $(keep_going) $(jobs) +nix_build := nix-build $(keep_going) $(jobs_arg) $(cores_arg) .PHONY: none none: @@ -73,6 +81,12 @@ run-tests: script=$$($(nix_build) -A runTests --no-out-link) && $$script $(try_restore_terminal) +.PHONY: run-sel4test-for +run-sel4test-for: + # use trailing period to catch empty variable + script=$$($(nix_build) -A sel4testInstances.$(SEL4TEST_ARCH). --no-out-link) && $$script + $(try_restore_terminal) + .PHONY: run-fast-tests run-fast-tests: script=$$($(nix_build) -A runFastTests --no-out-link) && $$script @@ -120,16 +134,16 @@ example-rpi4-b-4gb: $(nix_build) -A $@ -o $(out)/$@ .PHONY: check-fast -check-fast: check-source +check-fast: check-source check-dependencies $(MAKE) witness-fast-tests - $(MAKE) everything-fast + $(MAKE) everything-except-non-incremental .PHONY: check-exhaustively -check-exhaustively: check-source +check-exhaustively: check-source check-dependencies $(MAKE) witness-tests - $(MAKE) everything + $(MAKE) everything-with-excess .PHONY: check-oneshot -check-oneshot: check-source +check-oneshot: check-source check-dependencies $(MAKE) run-tests - $(MAKE) everything + $(MAKE) everything-with-excess diff --git a/hacking/ci/github-actions/Makefile b/hacking/ci/github-actions/Makefile index 24ea82ca3..dc3e74ca1 100644 --- a/hacking/ci/github-actions/Makefile +++ b/hacking/ci/github-actions/Makefile @@ -3,17 +3,8 @@ root_dir := ../../.. .PHONY: none none: -.PHONY: check -check: - $(MAKE) -C $(root_dir) check-oneshot +# TODO - # For debugging and monitoring disk usage - # ($(MAKE) -C $(root_dir) check-oneshot && df -h) || (df -h && false) - -.PHONY: docs -docs: - $(MAKE) -C $(root_dir) html - -.PHONY: check-dependencies -check-dependencies: - $(MAKE) -C $(root_dir) check-dependencies +.PHONY: foo +foo: + $(MAKE) -C $(root_dir) foo diff --git a/hacking/nix/top-level/default.nix b/hacking/nix/top-level/default.nix index b72bc2175..5e69580ce 100644 --- a/hacking/nix/top-level/default.nix +++ b/hacking/nix/top-level/default.nix @@ -18,15 +18,17 @@ in { pkgs.host.x86_64.none.this.worlds.default ]; - sel4testInstances = (map (x: x.this.sel4test) [ - pkgs.host.aarch64.none - pkgs.host.aarch32.none - pkgs.host.riscv64.none - pkgs.host.riscv32.none + sel4testInstances = (lib.mapAttrs (k: v: v.this.sel4test.automate) { + aarch64 = pkgs.host.aarch64.none; + aarch32 = pkgs.host.aarch32.none; + riscv64 = pkgs.host.riscv64.none; + riscv32 = pkgs.host.riscv32.none; # TODO figure out why none doesn't build - pkgs.host.x86_64.linux - pkgs.host.ia32.linux - ]); + x86_64 = pkgs.host.x86_64.linux; + ia32 = pkgs.host.ia32.linux; # no rust support yet + }); + + sel4testInstancesList = lib.attrValues sel4testInstances; prerequisites = aggregate "prerequisites" [ pkgs.host.riscv64.none.gccMultiStdenvGeneric @@ -48,10 +50,9 @@ in { map (instance: instance.links) world.instances.all )) - sel4testInstances + sel4testInstancesList pkgs.host.aarch32.none.this.worlds.default.seL4 - pkgs.host.riscv32.none.this.worlds.default.seL4 pkgs.host.ia32.none.this.worlds.default.seL4 example @@ -84,7 +85,7 @@ in { lib.forEach worldsForEverythingInstances (world: world.instances.allAutomationScripts); - slowTests = map (x: x.automate) sel4testInstances; + slowTests = sel4testInstancesList; runFastTests = mkRunTests (lib.flatten [ fastTests