Skip to content

Commit 7e86c50

Browse files
committed
fix(cache): Add tests for caching debugging
1 parent 4b5ebca commit 7e86c50

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

.github/workflows/main.yml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
name: CI
77

8-
on:
9-
pull_request:
8+
on:
9+
pull_request:
1010
branches:
1111
- main
1212
push:
@@ -20,7 +20,7 @@ concurrency:
2020
jobs:
2121
generate-matrix:
2222
name: "Generate matrix from cabal"
23-
outputs:
23+
outputs:
2424
matrix: ${{ steps.set-matrix.outputs.matrix }}
2525
runs-on: ubuntu-latest
2626
steps:
@@ -46,21 +46,50 @@ jobs:
4646
id: setup
4747
with:
4848
ghc-version: ${{ matrix.ghc }}
49-
cabal-version: 'latest'
49+
cabal-version: "latest"
5050
cabal-update: true
51-
- name: Configure the build
51+
52+
# TODO: Delete these outputs after testing
53+
#- name: Debug Setup Outputs
54+
# run: |
55+
# echo "GHC Version: ${{ steps.setup.outputs.ghc-version }}"
56+
# echo "Cabal Version: ${{ steps.setup.outputs.cabal-version }}"
57+
# echo "Cabal Store: ${{ steps.setup.outputs.cabal-store }}"
58+
# echo "Runner OS: ${{ runner.os }}"
59+
60+
# TODO: Refine this plan.json configuration
61+
- name: Generate plan.json
5262
run: |
53-
cabal configure --enable-tests --disable-documentation
54-
cabal build all --dry-run
63+
cabal update
64+
cabal build --dry-run --enable-benchmarks --enable-tests all > /dev/null
65+
mkdir -p ${{ github.workspace }}/cache-info
66+
cp dist-newstyle/cache/plan.json ${{ github.workspace }}/cache-info/
67+
echo "Plan JSON Hash: $(sha256sum ${{ github.workspace }}/cache-info/plan.json | cut -d ' ' -f 1)"
68+
69+
# TODO: Configure options is needed???
70+
#- name: Configure the build
71+
# run: |
72+
# cabal configure --enable-tests --disable-documentation
73+
# cabal build all --dry-run
74+
75+
# TODO: delete /cache-info/ path
5576
- name: Restore cached dependencies
5677
uses: actions/cache/restore@v4
5778
id: cache
5879
env:
5980
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
6081
with:
6182
path: ${{ steps.setup.outputs.cabal-store }}
62-
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
83+
key: ${{ env.key }}-plan-${{ hashFiles('**/cache-info/plan.json') }}
6384
restore-keys: ${{ env.key }}-
85+
86+
# Debug the cache hit/miss
87+
- name: Debug Cache Results
88+
run: |
89+
echo "Cache Hit: ${{ steps.cache.outputs.cache-hit }}"
90+
echo "Cache Primary Key: ${{ steps.cache.outputs.cache-primary-key }}"
91+
echo "Cache Matched Key: ${{ steps.cache.outputs.cache-matched-key }}"
92+
6493
- name: Install dependencies
6594
if: steps.cache.outputs.cache-hit != 'true'
6695
run: cabal build all --only-dependencies
@@ -76,3 +105,4 @@ jobs:
76105
run: cabal test all
77106
env:
78107
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
108+

0 commit comments

Comments
 (0)