2023-02-15 13:46:36 +01:00
|
|
|
name: "Build system config"
|
|
|
|
on:
|
|
|
|
pull_request:
|
2023-07-23 17:48:40 +02:00
|
|
|
workflow_dispatch:
|
2023-02-15 13:46:36 +01:00
|
|
|
push:
|
2023-07-23 17:48:40 +02:00
|
|
|
branches: [ main ]
|
|
|
|
|
2023-02-15 13:46:36 +01:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
2023-07-23 17:48:40 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2023-07-24 18:24:35 +02:00
|
|
|
- name: Install Nix
|
|
|
|
uses: DeterminateSystems/nix-installer-action@v4
|
|
|
|
- name: Run the Magic Nix Cache
|
|
|
|
uses: DeterminateSystems/magic-nix-cache-action@v2
|
2023-02-15 13:46:36 +01:00
|
|
|
- name: nix flake check
|
|
|
|
run: |
|
|
|
|
nix flake check --no-build
|
|
|
|
echo "## \`nix flake check\` succeeded" >> $GITHUB_STEP_SUMMARY
|
|
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Discover nixosConfigurations
|
|
|
|
run: |
|
|
|
|
echo Discovered the following system configs
|
|
|
|
nix flake show . --json | jq ".nixosConfigurations|keys[]" -r
|
|
|
|
- name: Build systems
|
2023-08-05 13:04:52 +02:00
|
|
|
id: build
|
2023-02-15 13:46:36 +01:00
|
|
|
run: |
|
2023-08-05 13:49:10 +02:00
|
|
|
echo "## Building" >> $GITHUB_STEP_SUMMARY
|
2023-02-15 13:46:36 +01:00
|
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
2023-08-05 13:49:10 +02:00
|
|
|
echo "| | Host | Out path |" >> $GITHUB_STEP_SUMMARY
|
|
|
|
echo "| --- | ---- | -------- |" >> $GITHUB_STEP_SUMMARY
|
|
|
|
any_failed=false
|
2023-02-15 13:46:36 +01:00
|
|
|
for host in $(nix flake show . --json | jq ".nixosConfigurations|keys[]" -r); do
|
|
|
|
echo "::group::Building ${host}"
|
|
|
|
drv=".#nixosConfigurations.$host.config.system.build.toplevel"
|
|
|
|
build_cmd="nix build ${drv}"
|
2023-08-05 13:49:10 +02:00
|
|
|
failed=false
|
|
|
|
$build_cmd --show-trace || { failed=true; any_failed=true; }
|
2023-02-15 13:46:36 +01:00
|
|
|
echo "::endgroup::"
|
2023-08-05 13:49:10 +02:00
|
|
|
if ! $failed; then
|
|
|
|
symbol="✅"
|
|
|
|
out_path=$($build_cmd --print-out-paths)
|
|
|
|
out_path="\`${out_path}\`"
|
|
|
|
echo -e "\x1b[32;1mSuccessfully built .#nixosConfigurations.${host}\x1b[0m"
|
|
|
|
else
|
|
|
|
symbol="❌"
|
|
|
|
out_path="_build failed_"
|
|
|
|
echo -e "\x1b[31;1mFailed to build .#nixosConfigurations.${host}\x1b[0m"
|
|
|
|
fi
|
|
|
|
echo "| $symbol | ${host} | ${out_path} |" >> $GITHUB_STEP_SUMMARY
|
2023-02-15 13:46:36 +01:00
|
|
|
done
|
2023-08-05 13:49:10 +02:00
|
|
|
# Set return-code to 1 if any failed
|
|
|
|
! $any_failed
|
2023-07-23 17:48:40 +02:00
|
|
|
- name: Diff closures
|
2023-08-05 13:04:52 +02:00
|
|
|
# Still would like to see the changes for the non-failing hosts
|
|
|
|
if: ${{ success() }} || ${{ failure() }}
|
|
|
|
run: ./.github/scripts/diff-hosts.sh
|