diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 154aa3e74d..9172cfd427 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -129,11 +129,6 @@ jobs: - name: Build all run: cabal build all --enable-tests - # This step is temporary. We'll soon remove it and check instead - # that golden files have not been modified when creating them below. - - name: Test all - run: cabal test all --enable-tests --test-show-details=direct -j1 - - # Delete golden files and regenerate them in the next step to ensure # files that tests designate as golden files are actually golden files # and can be generated. @@ -141,7 +136,7 @@ jobs: run: | rm -rf cardano-cli/test/cardano-cli-golden/files/golden - - name: Run tests regenerate golden files + - name: Run tests, generating golden files on the fly env: TMPDIR: ${{ runner.temp }} TMP: ${{ runner.temp }} @@ -149,6 +144,36 @@ jobs: CREATE_GOLDEN_FILES: 1 run: cabal test all --enable-tests --test-show-details=direct -j1 + # We want this check to run first because $(git ls-files -m) (see below) returns both + # modified files *and* deleted files. So we want to fail on deleted files first. + # This makes sure we only report modified files (and not deleted ones) in the next step, + # which is more intuitive. + - name: Check golden files are all being used + # We don't run this step on Windows, because some tests do not run on Windows, + # and so some golden files don't get regenerated. See + # https://github.com/IntersectMBO/cardano-cli/blob/0048f119036ffb9eab357b25dcaf7d320362f071/cardano-cli/test/cardano-cli-golden/Test/Golden/Help.hs#L54 + if: ${{ matrix.sys.os != 'windows-latest' }} + run: | + NB_UNUSED_GOLDEN_FILES=$(git ls-files -d | wc -l) + if [[ "$NB_UNUSED_GOLDEN_FILES" != "0" ]]; then + echo -e "⚠️ The following golden files are not used anymore:\n" + git ls-files -d + echo -e "\nPlease delete them." + exit 1 + fi + + - name: Check golden files are up-to-date + # We don't run this step on Windows, as explained in the previous step. + if: ${{ matrix.sys.os != 'windows-latest' }} + run: | + NB_MODIFIED_GOLDEN_FILES=$(git ls-files -m | wc -l) + if [[ "$NB_MODIFIED_GOLDEN_FILES" != "0" ]]; then + echo -e "💣 The following golden files are not up-to-date:\n" + git ls-files -m + echo -e "\nPlease run the tests locally and update the golden files, or fix your changes." + exit 1 + fi + - name: "Tar artifacts" run: | mkdir -p artifacts diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/byron/transaction-view-json.out b/cardano-cli/test/cardano-cli-golden/files/golden/byron/transaction-view-json.out deleted file mode 100644 index e75eefbac3..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/byron/transaction-view-json.out +++ /dev/null @@ -1,26 +0,0 @@ -{ - "auxiliary scripts": null, - "certificates": null, - "collateral inputs": null, - "era": "Byron", - "fee": "implicit", - "inputs": [ - "f8ec302d19e3c8251c30b1434349bf2e949a1dbf14a4ebc3d512918d2d4d5c56#88" - ], - "metadata": null, - "mint": null, - "outputs": [ - { - "address": "5oP9ib6ym3XfwXuy3ksXZzgtBzXSArXAACQVXKqcPhiLnHVYjXJNu2T6Zomh8LAWLV", - "address era": "Byron", - "amount": "68 Lovelace" - } - ], - "reference inputs": null, - "required signers (payment key hashes needed for scripts)": null, - "return collateral": null, - "total collateral": null, - "update proposal": null, - "validity range": null, - "withdrawals": null -} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/byron/transaction-view.out b/cardano-cli/test/cardano-cli-golden/files/golden/byron/transaction-view.out deleted file mode 100644 index 5cae721d26..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/byron/transaction-view.out +++ /dev/null @@ -1,20 +0,0 @@ -auxiliary scripts: null -certificates: null -collateral inputs: null -era: Byron -fee: implicit -inputs: -- f8ec302d19e3c8251c30b1434349bf2e949a1dbf14a4ebc3d512918d2d4d5c56#88 -metadata: null -mint: null -outputs: -- address: 5oP9ib6ym3XfwXuy3ksXZzgtBzXSArXAACQVXKqcPhiLnHVYjXJNu2T6Zomh8LAWLV - address era: Byron - amount: 68 Lovelace -reference inputs: null -required signers (payment key hashes needed for scripts): null -return collateral: null -total collateral: null -update proposal: null -validity range: null -withdrawals: null