Diff server closures on pull_request
Also updated the triggers, only building on pushes to main since the rest will eventually be a PR to main, so that the we can ditch the avoid duplicates action.
This commit is contained in:
parent
c1eebe17dc
commit
6bdafe2bbe
1 changed files with 32 additions and 18 deletions
50
.github/workflows/build-systems.yaml
vendored
50
.github/workflows/build-systems.yaml
vendored
|
@ -1,33 +1,20 @@
|
||||||
name: "Build system config"
|
name: "Build system config"
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
avoid_duplicates:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
|
||||||
steps:
|
|
||||||
- id: skip_check
|
|
||||||
uses: fkirc/skip-duplicate-actions@v5
|
|
||||||
with:
|
|
||||||
# All of these options are optional, so you can remove them if you are happy with the defaults
|
|
||||||
concurrent_skipping: 'same_content_newer'
|
|
||||||
skip_after_successful_duplicate: 'true'
|
|
||||||
do_not_skip: '["workflow_dispatch", "schedule"]'
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: avoid_duplicates
|
|
||||||
if: needs.avoid_duplicates.outputs.should_skip != 'true'
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
- uses: cachix/install-nix-action@v20
|
- uses: cachix/install-nix-action@v20
|
||||||
with:
|
with:
|
||||||
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
#- uses: cachix/cachix-action@v12
|
|
||||||
# with:
|
|
||||||
# name: chaos-jetzt-nixfiles
|
|
||||||
# authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
|
||||||
- name: nix flake check
|
- name: nix flake check
|
||||||
run: |
|
run: |
|
||||||
nix flake check --no-build
|
nix flake check --no-build
|
||||||
|
@ -54,3 +41,30 @@ jobs:
|
||||||
echo -e "\x1b[32;1mSuccessfully built .#nixosConfigurations.${host}\x1b[0m"
|
echo -e "\x1b[32;1mSuccessfully built .#nixosConfigurations.${host}\x1b[0m"
|
||||||
echo "| ${host} | \`${out_path}\` |" >> $GITHUB_STEP_SUMMARY
|
echo "| ${host} | \`${out_path}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
done
|
done
|
||||||
|
- name: Diff closures
|
||||||
|
# Since this is only triggered by pushes to main, no need to compare to main for pushes
|
||||||
|
if: github.event_name != 'push'
|
||||||
|
run: |
|
||||||
|
# Compare to pull_request_target or, if this has no PR-Target, main
|
||||||
|
target_ref="${GITHUB_BASE_REF-main}"
|
||||||
|
target_ref="origin/${target_ref/#refs\/heads\//}"
|
||||||
|
if [[ $GITHUB_REF == "target/refs/main" ]]; then
|
||||||
|
# If triggered on main, compare with the previous commit
|
||||||
|
target_ref="$(git log HEAD~1 -1 --format=format:"%H")"
|
||||||
|
fi
|
||||||
|
echo -e "## Closure differences\n" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "_Comparing current $(git rev-parse --abbrev-ref HEAD) ($(git rev-parse --verify HEAD)) to ${target_ref} ($(git rev-parse $target_ref))_" | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
for host in $(nix flake show . --json | jq ".nixosConfigurations|keys[]" -r); do
|
||||||
|
echo "::group::Diff-closures for ${host}"
|
||||||
|
drv="nixosConfigurations.$host.config.system.build.toplevel"
|
||||||
|
diff_cmd="nix store diff-closures git+file:.?ref=${target_ref}#${drv} .#${drv}"
|
||||||
|
# Get the nice and colorfull output for the logs, running twice won't (significantly) prolong the runtime
|
||||||
|
$diff_cmd
|
||||||
|
echo -e "<details>\n<summary>Diff for ${host}</summary>\n" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
|
# Strip color codes so that the summary stays readable
|
||||||
|
$diff_cmd | sed -e 's/\x1b\[[0-9;]*m//g' >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo -e "\n</details>" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "::endgroup::"
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in a new issue