From 53a8f96edd6ab2e919e9e816339fc31272634893 Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Wed, 20 Nov 2024 15:51:14 +0800 Subject: [PATCH] [ ci ] Only ask Stack to install Agda if it has not been installed --- .github/workflows/test.yml | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0c5ea412..d9cf95fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -82,7 +82,36 @@ jobs: - name: 🛠️ Add Stack install directory to PATH run: echo $STACK_LOCAL_BIN >> $GITHUB_PATH - - name: ⏬ Install Agda + - name: 🔍 Check if Agda has been installed + id: check-agda + continue-on-error: true + run: | + stack exec ${{ matrix.agda }} -- --version + + - name: 🔍 FAILED + if: ${{ failure() }} + run: | + echo "FAILED" + + - name: 🔍 SUCCEED + if: ${{ success() }} + run: | + echo "SUCCEED" + + - name: 🔍 Display if Agda has been installed 2 + if: ${{ steps.check-agda.outcome == 'failure'}} + run: | + echo $? + echo "AGDA_INSTALLED = $AGDA_INSTALLED" + echo "AGDA_INSTALLED = $?" + echo "AGDA_INSTALLED=$?" >> "$GITHUB_ENV" + + - name: ✅ Verify Agda is ready + if: ${{ success() && steps.check-agda.outcome == 'success'}} + run: echo "Agda already installed, skipping installation" + + - name: ⏬ Install Agda because it has not been installed + if: ${{ failure() && steps.check-agda.outcome == 'failure'}} run: | stack install --resolver=lts-20.26 ${{ matrix.agda }} which agda @@ -91,14 +120,14 @@ jobs: # things to be cached - name: 💾 Cache stack global package db - if: always() && steps.stack-global.outputs.cache-hit != 'true' + if: always() && env.AGDA_INSTALLED != '0' && steps.stack-global.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: ${{ steps.haskell-setup.outputs.stack-root }} key: ${{ steps.stack-global.outputs.cache-primary-key }} - name: 💾 Cache stack-installed binaries - if: always() && steps.stack-binaries.outputs.cache-hit != 'true' + if: always() && env.AGDA_INSTALLED != '0' && steps.stack-binaries.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: ${{ env.STACK_LOCAL_BIN }}