[ fix ] Provide the CI with stack.yaml for building Agda #1079
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a basic workflow to help you get started with Actions | |
| name: Test | |
| defaults: | |
| run: | |
| shell: bash | |
| # Controls when the action will run. | |
| on: | |
| # Triggers the workflow on push or pull request events but only for the master branch | |
| push: | |
| branches: [ master, dev, web, ci, ci-* ] | |
| pull_request: | |
| branches: [ master, dev, ci, ci-* ] | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| build-and-test: | |
| # Runs on all major platforms | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| agda: ["Agda-2.6.4", "Agda-2.7.0", "Agda-2.8.0"] | |
| include: | |
| - agda: "Agda-2.6.4" | |
| agda-version: "Agda-2.6.4.3" | |
| stack-config: ".github/stack/stack-Agda-2.6.4.3.yaml" | |
| - agda: "Agda-2.7.0" | |
| agda-version: "Agda-2.7.0.1" | |
| stack-config: ".github/stack/stack-Agda-2.7.0.1.yaml" | |
| - agda: "Agda-2.8.0" | |
| agda-version: "Agda-2.8.0" | |
| stack-config: ".github/stack/stack-Agda-2.8.0.yaml" | |
| fail-fast: false | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| - name: π₯ Checkout repository | |
| uses: actions/checkout@v4 | |
| # actions: | |
| # $DIST is where the binary & its dependencies is placed | |
| - name: π οΈ Setting variables | |
| run: | | |
| echo "DIST=${{ matrix.agda }}-${{ matrix.os }}" >> "$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 "DIST = $DIST" | |
| # 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 | |
| # uses: actions/cache/restore@v4 | |
| # with: | |
| # path: ${{ env.STACK_LOCAL_BIN }} | |
| # key: ${{ runner.os }}-stack-binaries-${{ matrix.agda }} | |
| # restore-keys: | | |
| # ${{ runner.os }}-stack-binaries | |
| - name: πΎ Restore NPM dependencies | |
| id: npm-cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| node_modules | |
| ~/.npm | |
| key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json', 'package.json') }} | |
| restore-keys: | | |
| npm-${{ runner.os }}- | |
| - name: πΎ Restore Agda from ${{ env.DIST }} | |
| id: agda-artefacts | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ${{ env.DIST }} | |
| key: ${{ env.DIST }}-${{ matrix.stack-config }} | |
| restore-keys: | | |
| ${{ env.DIST }}-${{ matrix.stack-config }} | |
| - name: πΎ Restore VSCode from .vscode-test | |
| id: vscode | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: .vscode-test | |
| key: vscode-${{ runner.os }}-${{ runner.arch }} | |
| restore-keys: | | |
| vscode-${{ runner.os }}- | |
| - name: β¬ Setup Node.js environment | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| - name: π οΈ Add ${{ env.DIST }}/bin to PATH | |
| run: echo $(pwd)/$DIST/bin >> $GITHUB_PATH | |
| # - name: π οΈ Add ${{ env.STACK_LOCAL_BIN }} to PATH | |
| # run: echo $STACK_LOCAL_BIN >> $GITHUB_PATH | |
| - name: π Check if Agda has been installed | |
| id: check-agda | |
| continue-on-error: true | |
| run: which agda | |
| - name: π¦ Setup ${{ env.DIST }} | |
| if: ${{ steps.check-agda.outcome == 'failure'}} | |
| run: | | |
| mkdir -p $DIST | |
| mkdir -p $DIST/bin | |
| - name: β¬ Setup Haskell environment | |
| if: ${{ steps.check-agda.outcome == 'failure'}} | |
| id: haskell-setup | |
| uses: haskell-actions/setup@v2 | |
| with: | |
| ghc-version: '9.10.2' | |
| stack-version: latest | |
| cabal-update: false | |
| enable-stack: true | |
| - name: β¬ Install Agda | |
| if: ${{ steps.check-agda.outcome == 'failure'}} | |
| run: | | |
| stack install --stack-yaml=${{ matrix.stack-config }} --allow-different-user ${{ matrix.agda-version }} | |
| echo "STACK_LOCAL_BIN=$(stack path --stack-yaml=${{ matrix.stack-config }} --local-bin)" >> "$GITHUB_ENV" | |
| - name: π¦ Move artefacts to ${{ env.DIST }} | |
| if: ${{ steps.check-agda.outcome == 'failure'}} | |
| run: | | |
| # Copy the binary: | |
| cp $STACK_LOCAL_BIN/agda $DIST/bin | |
| # Strip the binary: | |
| if [[ ${{ runner.os }} == "Windows" ]]; then | |
| strip $DIST/bin/agda.exe | |
| file $DIST/bin/agda.exe | |
| else | |
| strip $DIST/bin/agda | |
| file $DIST/bin/agda | |
| fi | |
| # Copy the rest of the artefacts: | |
| cp -a $($STACK_LOCAL_BIN/agda --print-agda-dir)/. $DIST | |
| - name: π Setting the $Agda_datadir environment variable | |
| run: echo "Agda_datadir=$(pwd)/$DIST" >> "$GITHUB_ENV" | |
| - name: π Check if Agda has been installed again | |
| if: ${{ steps.check-agda.outcome == 'failure'}} | |
| run: | | |
| echo "Agda_datadir = $Agda_datadir" | |
| echo "Path of Agda = $(which agda)" | |
| echo "Version of Agda = $(agda -V)" | |
| # 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-installed binaries | |
| # if: always() && steps.stack-binaries.outputs.cache-hit != 'true' | |
| # uses: actions/cache/save@v4 | |
| # with: | |
| # path: ${{ env.STACK_LOCAL_BIN }} | |
| # key: ${{ steps.stack-binaries.outputs.cache-primary-key }} | |
| - name: πΎ Cache Agda in ${{ env.DIST }} | |
| if: always() && (steps.agda-artefacts.outputs.cache-hit != 'true' || steps.check-agda.outcome == 'failure') | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ${{ env.DIST }} | |
| key: ${{ steps.agda-artefacts.outputs.cache-primary-key }} | |
| - name: β¬ Install NPM Dependencies | |
| run: npm ci --cache .npm | |
| - name: π¨ Build stuff | |
| run: npm run build | |
| - name: π Run tests | |
| run: | | |
| if [[ ${{ runner.os }} == "Linux" ]]; then | |
| xvfb-run -a npm test 2>&1 | tee test-output.log | |
| else | |
| npm test 2>&1 | tee test-output.log | |
| fi | |
| - name: π Check if VS Code was downloaded | |
| id: check-vscode-download | |
| run: | | |
| if grep -q "Downloading.*MB" test-output.log; then | |
| echo "downloaded=true" >> $GITHUB_OUTPUT | |
| echo "β¨ Newer VS Code version detected and downloaded" | |
| else | |
| echo "downloaded=false" >> $GITHUB_OUTPUT | |
| echo "π¦ Using cached VS Code version (no newer version available)" | |
| fi | |
| - name: πΎ Cache VSCode in .vscode-test | |
| if: always() && (steps.vscode.outputs.cache-hit != 'true' || steps.check-vscode-download.outputs.downloaded == 'true') | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: .vscode-test | |
| key: vscode-${{ runner.os }}-${{ runner.arch }} | |
| - name: πΎ Cache NPM dependencies | |
| if: always() && steps.npm-cache.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: | | |
| node_modules | |
| ~/.npm | |
| key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json', 'package.json') }} |