Skip to content

Commit

Permalink
[ ci ] Only ask Stack to install Agda if it has not been installed
Browse files Browse the repository at this point in the history
  • Loading branch information
banacorn committed Nov 20, 2024
1 parent 10df67f commit 58a31a3
Showing 1 changed file with 48 additions and 38 deletions.
86 changes: 48 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,38 @@ jobs:

# actions:

- name: ⏬ Setup Haskell environment
id: haskell-setup
uses: haskell-actions/setup@v2
with:
ghc-version: '9.2.8'
stack-version: latest
cabal-update: false
enable-stack: true
# - name: ⏬ Setup Haskell environment
# id: haskell-setup
# uses: haskell-actions/setup@v2
# with:
# ghc-version: '9.2.8'
# stack-version: latest
# cabal-update: false
# enable-stack: true

- name: 🛠️ Setting variables
run: |
echo "STACK_LOCAL_BIN=$(stack path --local-bin)" >> "$GITHUB_ENV"
# - name: 🛠️ Setting variables
# run: |
# echo "STACK_LOCAL_BIN=$(stack path --local-bin)" >> "$GITHUB_ENV"

- name: 🔍 Reviewing variables
run: |
echo "runner.os = ${{ runner.os }}"
echo "ghc-path = ${{ steps.haskell-setup.outputs.ghc-path }}"
echo "ghc-exe = ${{ steps.haskell-setup.outputs.ghc-exe }}"
echo "stack-path = ${{ steps.haskell-setup.outputs.stack-path }}"
echo "stack-exe = ${{ steps.haskell-setup.outputs.stack-exe }}"
echo "stack-root = ${{ steps.haskell-setup.outputs.stack-root }}"
echo "STACK_LOCAL_BIN = $STACK_LOCAL_BIN"
# - name: 🔍 Reviewing variables
# run: |
# echo "runner.os = ${{ runner.os }}"
# echo "ghc-path = ${{ steps.haskell-setup.outputs.ghc-path }}"
# echo "ghc-exe = ${{ steps.haskell-setup.outputs.ghc-exe }}"
# echo "stack-path = ${{ steps.haskell-setup.outputs.stack-path }}"
# echo "stack-exe = ${{ steps.haskell-setup.outputs.stack-exe }}"
# echo "stack-root = ${{ steps.haskell-setup.outputs.stack-root }}"
# echo "STACK_LOCAL_BIN = $STACK_LOCAL_BIN"

# cached stuff to be restored:
- name: 💾 Restore cached stack global package db
id: stack-global
uses: actions/cache/restore@v4
with:
path: ${{ steps.haskell-setup.outputs.stack-root }}
key: ${{ runner.os }}-stack-global-${{ matrix.agda }}
restore-keys: |
${{ runner.os }}-stack-global
# # cached stuff to be restored:
# - name: 💾 Restore cached stack global package db
# id: stack-global
# uses: actions/cache/restore@v4
# with:
# path: ${{ steps.haskell-setup.outputs.stack-root }}
# key: ${{ runner.os }}-stack-global-${{ matrix.agda }}
# restore-keys: |
# ${{ runner.os }}-stack-global

- name: 💾 Restore stack-installed binaries in ~/.local/bin
id: stack-binaries
Expand All @@ -82,23 +82,33 @@ 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: which agda

# - name: ✅ Verify Agda is ready
# if: ${{ steps.check-agda.outcome == 'success'}}
# run: echo "Agda already installed, skipping installation"

- name: ⏬ Install Agda because it has not been installed
if: ${{ steps.check-agda.outcome == 'failure'}}
run: |
stack install --resolver=lts-20.26 ${{ matrix.agda }}
which agda
agda --version
# things to be cached
# # things to be cached

- name: 💾 Cache stack global package db
if: always() && 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 global package db
# 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 }}
Expand Down

0 comments on commit 58a31a3

Please sign in to comment.