|
| 1 | +name: Compile WASM |
| 2 | + |
| 3 | +on: [push, pull_request, workflow_dispatch] |
| 4 | + |
| 5 | +env: |
| 6 | + GHC_WASM_META_FLAVOUR: '9.10' |
| 7 | + GHC_WASM_META_COMMIT_HASH: '7927129e42bcd6a54b9e06e26455803fa4878261' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build |
| 12 | + runs-on: ubuntu-22.04 |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + path: als |
| 18 | + submodules: recursive |
| 19 | + |
| 20 | + - name: Compute cache key |
| 21 | + run: echo "CI_CACHE_KEY=${{ runner.os }}-${{ runner.arch }}-${{ env.GHC_WASM_META_COMMIT_HASH }}-flavor-${{ env.GHC_WASM_META_FLAVOUR }}" >> "$GITHUB_ENV" |
| 22 | + |
| 23 | + - name: Try to restore cached .ghc-wasm |
| 24 | + id: ghc-wasm-cache-restore |
| 25 | + uses: actions/cache/restore@v4 |
| 26 | + with: |
| 27 | + path: ~/.ghc-wasm |
| 28 | + key: ghc-wasm-${{ env.CI_CACHE_KEY }} |
| 29 | + |
| 30 | + - name: Try to restore cached native cabal |
| 31 | + id: native-cabal-cache-restore |
| 32 | + uses: actions/cache/restore@v4 |
| 33 | + with: |
| 34 | + path: | |
| 35 | + ~/.config/cabal |
| 36 | + ~/.cache/cabal |
| 37 | + key: native-cabal-${{ env.CI_CACHE_KEY }} |
| 38 | + |
| 39 | + - name: Try to restore cached dist-newstyle |
| 40 | + id: dist-newstyle-cache-restore |
| 41 | + uses: actions/cache/restore@v4 |
| 42 | + with: |
| 43 | + path: als/dist-newstyle |
| 44 | + key: dist-newstyle-${{ env.CI_CACHE_KEY }}-${{ hashFiles('als/dist-newstyle/**') }} |
| 45 | + restore-keys: | |
| 46 | + dist-newstyle-${{ env.CI_CACHE_KEY }}- |
| 47 | +
|
| 48 | + - name: Clone and setup ghc-wasm-meta |
| 49 | + id: ghc-wasm-setup |
| 50 | + if: steps.ghc-wasm-cache-restore.outputs.cache-matched-key == '' |
| 51 | + run: | |
| 52 | + mkdir ghc-wasm-meta |
| 53 | + cd ghc-wasm-meta |
| 54 | + git config --global init.defaultBranch dontcare |
| 55 | + git config --global advice.detachedHead false |
| 56 | + git init |
| 57 | + git remote add origin https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta.git |
| 58 | + git fetch origin ${{ env.GHC_WASM_META_COMMIT_HASH }} --depth=1 |
| 59 | + git checkout FETCH_HEAD |
| 60 | + FLAVOUR=${{ env.GHC_WASM_META_FLAVOUR }} ./setup.sh |
| 61 | +
|
| 62 | + - name: Add ghc-wasm-meta to PATH |
| 63 | + run: ~/.ghc-wasm/add_to_github_path.sh |
| 64 | + |
| 65 | + # setup script also updates package store near the end |
| 66 | + - name: Update wasm32 cabal |
| 67 | + if: steps.ghc-wasm-setup.outcome == 'success' || steps.ghc-wasm-setup.outcome == 'skipped' |
| 68 | + run: wasm32-wasi-cabal update |
| 69 | + |
| 70 | + - name: Install native utilities |
| 71 | + run: | |
| 72 | + echo ">>> Update cabal" |
| 73 | + ~/.ghc-wasm/cabal/bin/cabal update |
| 74 | + echo ">>> Install alex and happy" |
| 75 | + ~/.ghc-wasm/cabal/bin/cabal install alex-3.5.0.0 happy-1.20.1.1 |
| 76 | +
|
| 77 | + - name: Run cabal configure |
| 78 | + working-directory: './als' |
| 79 | + run: wasm32-wasi-cabal configure --flag=Agda-2-7-0-1 |
| 80 | + |
| 81 | + - name: 'Build dep: lsp-types' |
| 82 | + uses: nick-fields/retry@v3 |
| 83 | + id: build-dep-lsp-types |
| 84 | + with: |
| 85 | + timeout_minutes: 10 |
| 86 | + max_attempts: 2 |
| 87 | + command: cd als && wasm32-wasi-cabal build lib:lsp-types |
| 88 | + |
| 89 | + - name: 'Build dep: agda' |
| 90 | + id: build-dep-agda |
| 91 | + working-directory: './als' |
| 92 | + run: wasm32-wasi-cabal build lib:agda |
| 93 | + |
| 94 | + - name: Cache dist-newstyle |
| 95 | + uses: actions/cache/save@v4 |
| 96 | + if: steps.build-dep-lsp-types.outcome == 'success' && steps.build-dep-agda.outcome == 'success' |
| 97 | + with: |
| 98 | + path: als/dist-newstyle |
| 99 | + key: dist-newstyle-${{ env.CI_CACHE_KEY }}-${{ hashFiles('als/dist-newstyle/**') }} |
| 100 | + |
| 101 | + - name: Build every dependency else |
| 102 | + working-directory: './als' |
| 103 | + run: | |
| 104 | + cd wasm-submodules/network |
| 105 | + autoreconf -i |
| 106 | + cd ../.. |
| 107 | + wasm32-wasi-cabal build --dependencies-only |
| 108 | +
|
| 109 | + - name: Build als |
| 110 | + working-directory: './als' |
| 111 | + run: | |
| 112 | + mkdir ~/out |
| 113 | + wasm32-wasi-cabal build |
| 114 | + cp $(wasm32-wasi-cabal list-bin als) ~/out |
| 115 | +
|
| 116 | + - name: Clean up native/wasm cabal logs |
| 117 | + run: rm -rf ~/.cache/cabal/logs ~/.ghc-wasm/.cabal/logs |
| 118 | + |
| 119 | + - name: Cache native cabal |
| 120 | + uses: actions/cache/save@v4 |
| 121 | + if: steps.ghc-wasm-setup.outcome == 'success' |
| 122 | + with: |
| 123 | + path: | |
| 124 | + ~/.config/cabal |
| 125 | + ~/.cache/cabal |
| 126 | + key: ${{ steps.native-cabal-cache-restore.outputs.cache-primary-key }} |
| 127 | + |
| 128 | + - name: Cache ghc-wasm-meta |
| 129 | + uses: actions/cache/save@v4 |
| 130 | + if: steps.ghc-wasm-setup.outcome == 'success' |
| 131 | + with: |
| 132 | + path: ~/.ghc-wasm |
| 133 | + key: ${{ steps.ghc-wasm-cache-restore.outputs.cache-primary-key }} |
| 134 | + |
| 135 | + - name: Upload artifact |
| 136 | + uses: actions/upload-artifact@v4 |
| 137 | + with: |
| 138 | + name: als |
| 139 | + path: ~/out |
| 140 | + include-hidden-files: true |
0 commit comments