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