From 2b6ac409a7524be1f3c1b0695cf3ce16740e91da Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 17 Mar 2026 15:02:07 +0100 Subject: [PATCH] Fix index-state race condition in bump-plutus-version workflow Derive index-state timestamps from flake.lock lastModified instead of cabal update --dry-run. The live servers can report timestamps newer than what is available in the flake-pinned CHaP/hackage repos, causing Nix builds to fail with "index-state is older than requested". - Move nix flake update before timestamp extraction - Replace cabal update --dry-run with jq on flake.lock - Remove unused Install Cabal step - Subtract 2-hour safety margin from commit timestamps --- .github/workflows/bump-plutus-version.yml | 43 +++++++++++++---------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/workflows/bump-plutus-version.yml b/.github/workflows/bump-plutus-version.yml index 4e327b4..707d867 100644 --- a/.github/workflows/bump-plutus-version.yml +++ b/.github/workflows/bump-plutus-version.yml @@ -17,29 +17,36 @@ jobs: - name: Install Nix uses: DeterminateSystems/nix-installer-action@main - - - name: Install Cabal - run: | - nix profile install nixpkgs#cabal-install - - - name: Change Plutus Versions - run: | - HACKAGE_DATE=$(cabal update --dry-run | grep 'index-state' | awk '{print $6}' | tr -d '.' | sed -n '1p') - CHAP_DATE=$(cabal update --dry-run | grep 'index-state' | awk '{print $6}' | tr -d '.' | sed -n '2p') - - sed -i "s/\(hackage.haskell.org \).*\$/\1$HACKAGE_DATE/" cabal.project - sed -i "s/\(cardano-haskell-packages \).*\$/\1$CHAP_DATE/" cabal.project - - PLUTUS_VERSION=${{ github.event.inputs.version }} - sed -i "s/\(plutus-core \).*\$/\1\^>=$PLUTUS_VERSION/" "plinth-template.cabal" - sed -i "s/\(plutus-ledger-api \).*\$/\1\^>=$PLUTUS_VERSION/" "plinth-template.cabal" - sed -i "s/\(plutus-tx \).*\$/\1\^>=$PLUTUS_VERSION/" "plinth-template.cabal" - sed -i "s/\(plutus-tx-plugin \).*\$/\1\^>=$PLUTUS_VERSION/" "plinth-template.cabal" - name: Update flake.lock run: | nix flake update CHaP hackage --accept-flake-config + - name: Change Plutus Versions + run: | + # Derive index-state timestamps from the flake-pinned sources to avoid + # race conditions where cabal update --dry-run reports a newer timestamp + # than what is available in the pinned CHaP/hackage repos. + HACKAGE_EPOCH=$(jq '.nodes.hackage.locked.lastModified' flake.lock) + CHAP_EPOCH=$(jq '.nodes.CHaP.locked.lastModified' flake.lock) + + # Subtract 2 hours as a safety margin: the git commit timestamp can be + # newer than the latest index entry in the repository. + HACKAGE_EPOCH=$((HACKAGE_EPOCH - 7200)) + CHAP_EPOCH=$((CHAP_EPOCH - 7200)) + + HACKAGE_DATE=$(date -u -d "@$HACKAGE_EPOCH" +"%Y-%m-%dT%H:%M:%SZ") + CHAP_DATE=$(date -u -d "@$CHAP_EPOCH" +"%Y-%m-%dT%H:%M:%SZ") + + sed -i "s/\(hackage.haskell.org \).*$/\1$HACKAGE_DATE/" cabal.project + sed -i "s/\(cardano-haskell-packages \).*$/\1$CHAP_DATE/" cabal.project + + PLUTUS_VERSION=${{ github.event.inputs.version }} + sed -i "s/\(plutus-core \).*$/\1\^>=$PLUTUS_VERSION/" "plinth-template.cabal" + sed -i "s/\(plutus-ledger-api \).*$/\1\^>=$PLUTUS_VERSION/" "plinth-template.cabal" + sed -i "s/\(plutus-tx \).*$/\1\^>=$PLUTUS_VERSION/" "plinth-template.cabal" + sed -i "s/\(plutus-tx-plugin \).*$/\1\^>=$PLUTUS_VERSION/" "plinth-template.cabal" + - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@v6.0.5