Skip to content

Commit ff9b0df

Browse files
committed
GHA: upload golden files as artefacts
This helps troubleshoot golden test failures that can't be reproduced locally. For example, if a golden test fails on a Windows machine, then I can not reproduce it locally on an Ubuntu machine.
1 parent 348f7b0 commit ff9b0df

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ jobs:
122122
--project-file="${{ matrix.cabal-project-file || env.DEFAULT_CABAL_PROJECT_FILE }}"
123123
124124
- name: 🧪 Test
125+
id: test
125126
if: ${{ !matrix.cabal-skip-tests }}
126127
run: |
127128
cabal test all \
@@ -131,6 +132,19 @@ jobs:
131132
env:
132133
TASTY_TIMEOUT: "5m"
133134

135+
# Golden test output is not printed to the screen, so if a golden test fails
136+
# then it is not clear from the logs why the test fails. Uploading the
137+
# directory containing the golden files after running the goldens tests
138+
# allows us to diff the expected and actual golden file contents.
139+
- name: 📦 Upload golden files
140+
if: ${{ !matrix.cabal-skip-tests && steps.test.outcome != 'success' && always() }}
141+
uses: actions/upload-artifact@v4
142+
with:
143+
name: golden-files-${{ runner.os }}-ghc-${{ steps.setup-haskell.outputs.ghc-version }}-cabal-${{ steps.setup-haskell.outputs.cabal-version }}-plan-${{ hashFiles('dist-newstyle/cache/plan.json') }}
144+
path: test/golden-file-data
145+
if-no-files-found: error
146+
retention-days: 1
147+
134148
- name: 🛠️ Setup cabal-docspec (Linux)
135149
if: ${{ !matrix.cabal-skip-tests && runner.os == 'Linux' }}
136150
uses: ./.github/actions/setup-cabal-docspec

0 commit comments

Comments
 (0)