diff --git a/.github/workflows/flake-update.yml b/.github/workflows/flake-update.yml index a4ff4c5..535bcac 100644 --- a/.github/workflows/flake-update.yml +++ b/.github/workflows/flake-update.yml @@ -7,7 +7,6 @@ on: jobs: createPullRequest: runs-on: ubuntu-latest - # if: github.ref == 'refs/heads/main' # ensure workflow_dispatch only runs on main steps: - uses: actions/checkout@v4 # - name: Login to Docker Hub @@ -21,13 +20,6 @@ jobs: extra_nix_config: | experimental-features = nix-command flakes install_url: https://releases.nixos.org/nix/nix-2.19.0/install - - name: Setup Attic cache - uses: ryanccn/attic-action@v0 - with: - endpoint: ${{ secrets.ATTIC_ENDPOINT }} - cache: ${{ secrets.ATTIC_CACHE }} - token: ${{ secrets.ATTIC_TOKEN }} - skip-push: "true" - name: Calculate pre-drv run: nix run git+https://nayeonie.com/ahuston-0/flake-update-diff -- --build . # - name: Pull latest docker images @@ -70,12 +62,21 @@ jobs: # automated update_lockfile: runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' # ensure workflow_dispatch only runs on main steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install nix uses: https://github.com/DeterminateSystems/nix-installer-action@main - + - name: Setup Attic cache + uses: ryanccn/attic-action@v0 + with: + endpoint: ${{ secrets.ATTIC_ENDPOINT }} + cache: ${{ secrets.ATTIC_CACHE }} + token: ${{ secrets.ATTIC_TOKEN }} + skip-push: "true" + - name: Get pre-snapshot of evaluations + run: nix ./utils/eval-to-drv.sh pre - name: Update flake.lock id: update run: | @@ -90,7 +91,18 @@ jobs: echo "EOF" >> $GITHUB_ENV rm update.log - + - name: Get post-snapshot of evaluations + run: nix ./utils/eval-to-drv.sh post + - name: Calculate diff + run: nix ./utils/diff-evals.sh + - name: Read diff into environment + run: | + delimiter="$(openssl rand -hex 8)" + { + echo "POSTDIFF<<${delimiter}" + cat post-diff + echo "${delimiter}" + } >> $GITHUB_ENV - name: Write PR body template uses: https://github.com/DamianReeves/write-file-action@v1.3 with: @@ -102,10 +114,14 @@ jobs: ${{ env.UPDATE_LOG }} ``` + ``` + {{ env.POSTDIFF }} + ``` + Auto-generated by [update.yml][1] with the help of [create-pull-request][2]. - [1]: https://forgejo.stefka.eu/jiriks74/nix.nvim/src/branch/main/.github/workflows/update.yml + [1]: https://nayeonie.com/ahuston-0/nix-dotfiles/src/branch/main/.github/workflows/flake-update.yml [2]: https://forgejo.stefka.eu/jiriks74/create-pull-request - name: Generate PR body @@ -123,6 +139,9 @@ jobs: run: | rm pr_body.template rm pr_body.md + rm pre.json + rm post.json + rm post-diff - name: Create Pull Request id: create-pull-request @@ -140,6 +159,9 @@ jobs: branch: update-flake-lock delete-branch: true + pr-labels: | # Labels to be set on the PR + dependencies + automated - name: Push to Attic run: nix ./utils/attic-push.bash continue-on-error: true diff --git a/utils/diff-evals.sh b/utils/diff-evals.sh index 1ee6cd1..950699d 100755 --- a/utils/diff-evals.sh +++ b/utils/diff-evals.sh @@ -10,15 +10,4 @@ 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 +nix run git+https://nayeonie.com/ahuston-0/flake-update-diff -- --compare-drvs "$parent_path" diff --git a/utils/eval-to-drv.sh b/utils/eval-to-drv.sh index 8841f96..81a06cc 100755 --- a/utils/eval-to-drv.sh +++ b/utils/eval-to-drv.sh @@ -14,9 +14,6 @@ fi script_path=$(dirname "$(readlink -f $0)") parent_path=$(dirname "$script_path") -out_path="$parent_path/$1-drv" +out_path="$parent_path/$1.json" - -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" +nix run git+https://nayeonie.com/ahuston-0/flake-update-diff -- --evaluate --json "$out_path" "$parent_path"