Skip to content

Commit

Permalink
ci: Parallelize
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Oct 3, 2023
1 parent f2a9455 commit 1463669
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 62 deletions.
129 changes: 99 additions & 30 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
30 changes: 22 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
17 changes: 4 additions & 13 deletions hacking/ci/github-actions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 12 additions & 11 deletions hacking/nix/top-level/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1463669

Please sign in to comment.