From 7e86c50a38c77c2403d311ca96e5921a96897a2e Mon Sep 17 00:00:00 2001 From: Davidnbr Date: Fri, 11 Apr 2025 14:38:47 -0500 Subject: [PATCH 1/8] fix(cache): Add tests for caching debugging --- .github/workflows/main.yml | 46 +++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c1e80b..031d9e0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,8 +5,8 @@ name: CI -on: - pull_request: +on: + pull_request: branches: - main push: @@ -20,7 +20,7 @@ concurrency: jobs: generate-matrix: name: "Generate matrix from cabal" - outputs: + outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} runs-on: ubuntu-latest steps: @@ -46,12 +46,33 @@ jobs: id: setup with: ghc-version: ${{ matrix.ghc }} - cabal-version: 'latest' + cabal-version: "latest" cabal-update: true - - name: Configure the build + + # TODO: Delete these outputs after testing + #- name: Debug Setup Outputs + # run: | + # echo "GHC Version: ${{ steps.setup.outputs.ghc-version }}" + # echo "Cabal Version: ${{ steps.setup.outputs.cabal-version }}" + # echo "Cabal Store: ${{ steps.setup.outputs.cabal-store }}" + # echo "Runner OS: ${{ runner.os }}" + + # TODO: Refine this plan.json configuration + - name: Generate plan.json run: | - cabal configure --enable-tests --disable-documentation - cabal build all --dry-run + cabal update + cabal build --dry-run --enable-benchmarks --enable-tests all > /dev/null + mkdir -p ${{ github.workspace }}/cache-info + cp dist-newstyle/cache/plan.json ${{ github.workspace }}/cache-info/ + echo "Plan JSON Hash: $(sha256sum ${{ github.workspace }}/cache-info/plan.json | cut -d ' ' -f 1)" + + # TODO: Configure options is needed??? + #- name: Configure the build + # run: | + # cabal configure --enable-tests --disable-documentation + # cabal build all --dry-run + + # TODO: delete /cache-info/ path - name: Restore cached dependencies uses: actions/cache/restore@v4 id: cache @@ -59,8 +80,16 @@ jobs: key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} with: path: ${{ steps.setup.outputs.cabal-store }} - key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} + key: ${{ env.key }}-plan-${{ hashFiles('**/cache-info/plan.json') }} restore-keys: ${{ env.key }}- + + # Debug the cache hit/miss + - name: Debug Cache Results + run: | + echo "Cache Hit: ${{ steps.cache.outputs.cache-hit }}" + echo "Cache Primary Key: ${{ steps.cache.outputs.cache-primary-key }}" + echo "Cache Matched Key: ${{ steps.cache.outputs.cache-matched-key }}" + - name: Install dependencies if: steps.cache.outputs.cache-hit != 'true' run: cabal build all --only-dependencies @@ -76,3 +105,4 @@ jobs: run: cabal test all env: ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }} + From 89ba6b83316001c18326f7491070af2554dee037 Mon Sep 17 00:00:00 2001 From: Davidnbr Date: Fri, 11 Apr 2025 14:54:49 -0500 Subject: [PATCH 2/8] Trigger CI with additional outputs --- .github/workflows/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 031d9e0..a9b337d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,12 +50,12 @@ jobs: cabal-update: true # TODO: Delete these outputs after testing - #- name: Debug Setup Outputs - # run: | - # echo "GHC Version: ${{ steps.setup.outputs.ghc-version }}" - # echo "Cabal Version: ${{ steps.setup.outputs.cabal-version }}" - # echo "Cabal Store: ${{ steps.setup.outputs.cabal-store }}" - # echo "Runner OS: ${{ runner.os }}" + - name: Debug Setup Outputs + run: | + echo "GHC Version: ${{ steps.setup.outputs.ghc-version }}" + echo "Cabal Version: ${{ steps.setup.outputs.cabal-version }}" + echo "Cabal Store: ${{ steps.setup.outputs.cabal-store }}" + echo "Runner OS: ${{ runner.os }}" # TODO: Refine this plan.json configuration - name: Generate plan.json From e3949e126cc305d4823758446f8e3818d0d620cd Mon Sep 17 00:00:00 2001 From: Davidnbr Date: Fri, 11 Apr 2025 15:02:07 -0500 Subject: [PATCH 3/8] chore: Delete unneeded steps for build in dry-run mode --- .github/workflows/main.yml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a9b337d..d2814c9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,14 +49,6 @@ jobs: cabal-version: "latest" cabal-update: true - # TODO: Delete these outputs after testing - - name: Debug Setup Outputs - run: | - echo "GHC Version: ${{ steps.setup.outputs.ghc-version }}" - echo "Cabal Version: ${{ steps.setup.outputs.cabal-version }}" - echo "Cabal Store: ${{ steps.setup.outputs.cabal-store }}" - echo "Runner OS: ${{ runner.os }}" - # TODO: Refine this plan.json configuration - name: Generate plan.json run: | @@ -66,13 +58,7 @@ jobs: cp dist-newstyle/cache/plan.json ${{ github.workspace }}/cache-info/ echo "Plan JSON Hash: $(sha256sum ${{ github.workspace }}/cache-info/plan.json | cut -d ' ' -f 1)" - # TODO: Configure options is needed??? - #- name: Configure the build - # run: | - # cabal configure --enable-tests --disable-documentation - # cabal build all --dry-run - - # TODO: delete /cache-info/ path + # TODO: delete /cache-info/ path ? - name: Restore cached dependencies uses: actions/cache/restore@v4 id: cache From 5acfda72560e5c5da1b046d2a2d2b1a5f69545d1 Mon Sep 17 00:00:00 2001 From: Davidnbr Date: Fri, 11 Apr 2025 15:41:44 -0500 Subject: [PATCH 4/8] chore: Add build dry-run debug outputs --- .github/workflows/main.yml | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d2814c9..1571475 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,17 +48,15 @@ jobs: ghc-version: ${{ matrix.ghc }} cabal-version: "latest" cabal-update: true - - # TODO: Refine this plan.json configuration - - name: Generate plan.json + - name: Configure the build run: | - cabal update - cabal build --dry-run --enable-benchmarks --enable-tests all > /dev/null - mkdir -p ${{ github.workspace }}/cache-info - cp dist-newstyle/cache/plan.json ${{ github.workspace }}/cache-info/ - echo "Plan JSON Hash: $(sha256sum ${{ github.workspace }}/cache-info/plan.json | cut -d ' ' -f 1)" + cabal configure --enable-tests --disable-documentation + cabal build all --dry-run + pwd + echo ${{ github.workspace }} + find . -type f -name "*plan.json" + cat dist-newstyle/cache/plan.json - # TODO: delete /cache-info/ path ? - name: Restore cached dependencies uses: actions/cache/restore@v4 id: cache @@ -66,16 +64,9 @@ jobs: key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} with: path: ${{ steps.setup.outputs.cabal-store }} - key: ${{ env.key }}-plan-${{ hashFiles('**/cache-info/plan.json') }} + key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} restore-keys: ${{ env.key }}- - # Debug the cache hit/miss - - name: Debug Cache Results - run: | - echo "Cache Hit: ${{ steps.cache.outputs.cache-hit }}" - echo "Cache Primary Key: ${{ steps.cache.outputs.cache-primary-key }}" - echo "Cache Matched Key: ${{ steps.cache.outputs.cache-matched-key }}" - - name: Install dependencies if: steps.cache.outputs.cache-hit != 'true' run: cabal build all --only-dependencies @@ -91,4 +82,3 @@ jobs: run: cabal test all env: ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }} - From d9aca6aff4ac080a3fb2f03ce4d2346e4270eb65 Mon Sep 17 00:00:00 2001 From: Davidnbr Date: Fri, 11 Apr 2025 15:52:45 -0500 Subject: [PATCH 5/8] chore: add cabal enable-benchmarks based on documentation chore: add complete path for caching hitting --- .github/workflows/main.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1571475..dcacae0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,12 +50,8 @@ jobs: cabal-update: true - name: Configure the build run: | - cabal configure --enable-tests --disable-documentation + cabal configure --enable-tests --enable-benchmarks --disable-documentation cabal build all --dry-run - pwd - echo ${{ github.workspace }} - find . -type f -name "*plan.json" - cat dist-newstyle/cache/plan.json - name: Restore cached dependencies uses: actions/cache/restore@v4 @@ -64,7 +60,7 @@ jobs: key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} with: path: ${{ steps.setup.outputs.cabal-store }} - key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} + key: ${{ env.key }}-plan-${{ hashFiles('${{ github.workspace }}/dist-newstyle/cache/plan.json') }} restore-keys: ${{ env.key }}- - name: Install dependencies From 2e80693d8fc4bbab110a5e2ad9094f8f322d721a Mon Sep 17 00:00:00 2001 From: Davidnbr Date: Fri, 11 Apr 2025 16:24:24 -0500 Subject: [PATCH 6/8] feat(cache): adds cache manual invalidation with prefix --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dcacae0..409b14e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,8 +60,8 @@ jobs: key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} with: path: ${{ steps.setup.outputs.cabal-store }} - key: ${{ env.key }}-plan-${{ hashFiles('${{ github.workspace }}/dist-newstyle/cache/plan.json') }} - restore-keys: ${{ env.key }}- + key: v1-ghc-deps-${{ env.key }}-plan-${{ hashFiles('${{ github.workspace }}/dist-newstyle/cache/plan.json') }} + restore-keys: v1-ghc-deps-${{ env.key }}- - name: Install dependencies if: steps.cache.outputs.cache-hit != 'true' From 056810baf1dde61e18d7f61bc1467d97fc0cd1ed Mon Sep 17 00:00:00 2001 From: Davidnbr Date: Fri, 11 Apr 2025 16:52:33 -0500 Subject: [PATCH 7/8] chore: cache key search usage with relative path --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 409b14e..46cd517 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,7 +60,7 @@ jobs: key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} with: path: ${{ steps.setup.outputs.cabal-store }} - key: v1-ghc-deps-${{ env.key }}-plan-${{ hashFiles('${{ github.workspace }}/dist-newstyle/cache/plan.json') }} + key: v1-ghc-deps-${{ env.key }}-plan-${{ hashFiles('**/dist-newstyle/cache/plan.json') }} restore-keys: v1-ghc-deps-${{ env.key }}- - name: Install dependencies From bf262f24040116ca6e083a4bc54a59135dddf0a2 Mon Sep 17 00:00:00 2001 From: Davidnbr Date: Mon, 14 Apr 2025 08:03:26 -0500 Subject: [PATCH 8/8] chore: change cache key name. Delete (ghc-deps-) --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46cd517..e491939 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,7 +60,7 @@ jobs: key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} with: path: ${{ steps.setup.outputs.cabal-store }} - key: v1-ghc-deps-${{ env.key }}-plan-${{ hashFiles('**/dist-newstyle/cache/plan.json') }} + key: v1-${{ env.key }}-plan-${{ hashFiles('**/dist-newstyle/cache/plan.json') }} restore-keys: v1-ghc-deps-${{ env.key }}- - name: Install dependencies