add output diffs

Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
ahuston-0 2024-07-04 00:33:54 -04:00 committed by Alice Huston
parent 6d41203f89
commit 042732b15d
4 changed files with 77 additions and 0 deletions

View File

@ -10,18 +10,45 @@ jobs:
if: github.ref == 'refs/heads/main' # ensure workflow_dispatch only runs on main if: github.ref == 'refs/heads/main' # ensure workflow_dispatch only runs on main
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v24 uses: cachix/install-nix-action@v24
with: with:
extra_nix_config: | extra_nix_config: |
experimental-features = nix-command flakes experimental-features = nix-command flakes
install_url: https://releases.nixos.org/nix/nix-2.19.0/install install_url: https://releases.nixos.org/nix/nix-2.19.0/install
- name: Calculate pre-drv
run: nix ./utils/eval-to-drv.sh pre
- name: Pull latest docker images - name: Pull latest docker images
run: nix ./utils/fetch-docker.sh run: nix ./utils/fetch-docker.sh
- name: Update flake.lock (part 1)
run: nix flake update
- name: Calculate post-drv
run: nix ./utils/eval-to-drv.sh post
- name: Calculate diff
run: nix ./utils/diff-evals
- name: Read diff into environment
uses: andstor/file-reader-action@v1
id: post_diff
with:
path: "post-diff"
- name: Restore flake.lock for next step
run: git restore flake.lock
- name: Update flake.lock - name: Update flake.lock
id: update id: update
uses: DeterminateSystems/update-flake-lock@main uses: DeterminateSystems/update-flake-lock@main
with: with:
# token: ${{ secrets.GH_TOKEN_FOR_UPDATES }}
pr-body: |
Automated changes by the [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) GitHub Action.
```
{{ env.GIT_COMMIT_MESSAGE }}
```
```
{{ env.steps.post_diff.outputs.contents }}
```
pr-labels: | # Labels to be set on the PR pr-labels: | # Labels to be set on the PR
dependencies dependencies
automated automated

5
.gitignore vendored
View File

@ -17,3 +17,8 @@ result-*
# allows test file in reopsitory # allows test file in reopsitory
test.* test.*
# flake update artifacts
pre-drv
post-drv
post-diff

24
utils/diff-evals.sh Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env nix
#! nix shell nixpkgs#bash nixpkgs#gnugrep nixpkgs#nvd --command bash
# diffs each derivation
set -x
set -v
set -e
script_path=$(dirname "$(readlink -f $0)")
parent_path=$(dirname "$script_path")
readarray -t pre_drv < "$parent_path/pre-drv"
readarray -t post_drv < "$parent_path/post-drv"
post_drv_path="$parent_path/post-diff"
# cleanup any files with the same name
rm "$post_drv_path" || true
touch "$post_drv_path"
for i in $(seq 0 $(( "${#pre_drv[@]}" -1 ))); do
echo "Diffing updates to $(echo "${pre_drv[$i]}" | cut -f 2- -d '-')" >> "$post_drv_path"
nvd diff "${pre_drv[$i]}" "${post_drv[$i]}" >> "$post_drv_path"
done

21
utils/eval-to-drv.sh Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env nix
#! nix shell nixpkgs#bash nixpkgs#gnugrep --command bash
# diffs each derivation
set -x
set -v
set -e
if [ "$#" -ne 2 ]; then
echo "$0 (pre|post)"
fi
script_path=$(dirname "$(readlink -f $0)")
parent_path=$(dirname "$script_path")
out_path="$parent_path/$1-drv"
drv=$(nix flake check --verbose 2> >(grep -P -o "derivation evaluated to (/nix/store/.*\.drv)" | grep -P -o "/nix/store/.*\.drv"))
echo "$drv" > "$out_path"