From ff2804564026ab38abfae184a6b8e99ad124a4a2 Mon Sep 17 00:00:00 2001 From: Jack Xu Date: Tue, 3 Mar 2026 12:11:22 +0800 Subject: [PATCH] fix: always write -latest.json even when no new deployments occur MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a CI run is interrupted after contracts are deployed on-chain but before deployment JSON files are written, a retry run detects the existing contracts and skips redeployment. However, _hasNewDeployments remains false, causing _afterAll() to skip writing all JSON files — including the cumulative -latest.json that already has the correct data in memory. Decouple -latest.json persistence from the _hasNewDeployments flag so the cumulative file is always written when it has content. The timestamped diff file remains gated by _hasNewDeployments. --- src/DeployHelper.sol | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/DeployHelper.sol b/src/DeployHelper.sol index 93b5d9a..5284463 100644 --- a/src/DeployHelper.sol +++ b/src/DeployHelper.sol @@ -232,11 +232,16 @@ abstract contract DeployHelper is CreateXHelper { return; } + // Always persist the cumulative -latest.json when it has content. + // This ensures the file is created after interrupted runs where + // contracts exist on-chain but the JSON was never written to disk. + if (bytes(finalJsonLatest).length > 0) { + vm.writeJson(finalJsonLatest, jsonPathLatest); + } + + // Only write the timestamped diff file for actual new deployments if (_hasNewDeployments) { vm.writeJson(finalJson, jsonPath); - if (bytes(finalJsonLatest).length > 0) { - vm.writeJson(finalJsonLatest, jsonPathLatest); - } } }