|
| 1 | +name: Haskell CI (WASM) |
| 2 | + |
| 3 | +on: |
| 4 | + merge_group: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + # we need this to populate cache for `master` branch to make it available to the child branches, see |
| 8 | + # https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache |
| 9 | + branches: |
| 10 | + - master |
| 11 | + # GH caches are removed when not accessed within 7 days - this schedule runs the job every 6 days making |
| 12 | + # sure that we always have some caches on master |
| 13 | +# schedule: |
| 14 | +# - cron: '0 0 */6 * *' |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ${{ matrix.sys.os }} |
| 19 | + |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + sys: |
| 24 | + - { os: ubuntu-latest, shell: bash } |
| 25 | +# - { os: macos-latest, shell: bash } |
| 26 | + |
| 27 | + defaults: |
| 28 | + run: |
| 29 | + shell: ${{ matrix.sys.shell }} |
| 30 | + |
| 31 | + env: |
| 32 | + # Modify this value to "invalidate" the cabal cache. |
| 33 | + CABAL_CACHE_VERSION: "2025-05-29" |
| 34 | + |
| 35 | + concurrency: |
| 36 | + group: > |
| 37 | + wasm |
| 38 | + a+${{ github.event_name }} |
| 39 | + b+${{ github.workflow_ref }} |
| 40 | + c+${{ github.job }} |
| 41 | + f+${{ matrix.sys.os }} |
| 42 | + g+${{ (startsWith(github.ref, 'refs/heads/gh-readonly-queue/') && github.run_id) || github.event.pull_request.number || github.ref }} |
| 43 | + cancel-in-progress: true |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Concurrency group |
| 47 | + run: > |
| 48 | + echo |
| 49 | + wasm |
| 50 | + a+${{ github.event_name }} |
| 51 | + b+${{ github.workflow_ref }} |
| 52 | + c+${{ github.job }} |
| 53 | + f+${{ matrix.sys.os }} |
| 54 | + g+${{ (startsWith(github.ref, 'refs/heads/gh-readonly-queue/') && github.run_id) || github.event.pull_request.number || github.ref }} |
| 55 | +
|
| 56 | + - uses: actions/checkout@v4 |
| 57 | + |
| 58 | + - uses: cachix/install-nix-action@v30 |
| 59 | + with: |
| 60 | + nix_path: nixpkgs=channel:nixos-unstable |
| 61 | + extra_nix_config: | |
| 62 | + trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= |
| 63 | + substituters = https://cache.iog.io/ https://cache.nixos.org/ |
| 64 | +
|
| 65 | + - uses: rrbutani/use-nix-shell-action@v1 |
| 66 | + with: |
| 67 | + devShell: .#wasm |
| 68 | + |
| 69 | + - name: Cabal update |
| 70 | + run: | |
| 71 | + wasm32-wasi-cabal update |
| 72 | +
|
| 73 | + # A dry run `build all` operation does *NOT* downlaod anything, it just looks at the package |
| 74 | + # indices to generate an install plan. |
| 75 | + - name: Build dry run |
| 76 | + run: | |
| 77 | + wasm32-wasi-cabal build cardano-wasm --dry-run |
| 78 | +
|
| 79 | + # From the install plan we generate a dependency list. |
| 80 | + - name: Record dependencies |
| 81 | + id: record-deps |
| 82 | + run: | |
| 83 | + cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[] | select(.style != "local") | .id' | sort | uniq > dependencies.txt |
| 84 | +
|
| 85 | + - name: Store month number as environment variable used in cache version |
| 86 | + run: | |
| 87 | + cat <<EOF >> $GITHUB_ENV |
| 88 | + MONTHNUM=$(date -u '+%m') |
| 89 | + GHC=$(ghc --numeric-version) |
| 90 | + STORE=$(wasm32-wasi-cabal path --store | tail -n 1) |
| 91 | + EOF |
| 92 | +
|
| 93 | +# Cache is disabled because GHA default builders are not able to build all dependencies |
| 94 | +# because they lack RAM, so having the cache expire would break the CI check. |
| 95 | +# For this reason, we are providing a build of the dependencies instead in |
| 96 | +# the "Restore cached deps" step, and we make the check not required. |
| 97 | +# When we are able to make this CI check self-sufficient, we should reenable the |
| 98 | +# caching and remove the manual restoring of cached deps. |
| 99 | + |
| 100 | + # From the dependency list we restore the cached dependencies. |
| 101 | + # We use the hash of `dependencies.txt` as part of the cache key because that will be stable |
| 102 | + # until the `index-state` values in the `cabal.project` file changes. |
| 103 | +# - name: Restore cached dependencies |
| 104 | +# uses: actions/cache/restore@v4 |
| 105 | +# id: cache |
| 106 | +# with: |
| 107 | +# path: | |
| 108 | +# ${{ env.STORE }} |
| 109 | +# dist-newstyle |
| 110 | +# key: |
| 111 | +# wasm-cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ env.GHC }}-${{ hashFiles('cardano-wasm/dependencies.txt') }} |
| 112 | +# restore-keys: | |
| 113 | +# wasm-cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ env.GHC }}- |
| 114 | + |
| 115 | + - name: Restore cached deps |
| 116 | + run: | |
| 117 | + wget "https://agrius.feralhosting.com/palas/wasm-cache/4c200033737be4736cd2a363d64c49a385937d5ea57d8e52773f65d08bbd1342.tar.bz2" |
| 118 | + tar -jxf 4c200033737be4736cd2a363d64c49a385937d5ea57d8e52773f65d08bbd1342.tar.bz2 |
| 119 | + rm -fr ~/.ghc-wasm/.cabal/store/ |
| 120 | + mv store ~/.ghc-wasm/.cabal/ |
| 121 | +
|
| 122 | + # Now we install the dependencies. If the cache was found and restored in the previous step, |
| 123 | + # this should be a no-op, but if the cache key was not found we need to build stuff so we can |
| 124 | + # cache it for the next step. |
| 125 | + - name: Install dependencies |
| 126 | + run: | |
| 127 | + wasm32-wasi-cabal build cardano-wasm --only-dependencies --no-semaphore -j1 --ghc-options="-j1" |
| 128 | +
|
| 129 | + # Always store the cabal cache. |
| 130 | +# - name: Cache Cabal store |
| 131 | +# uses: actions/cache/save@v4 |
| 132 | +# if: always() |
| 133 | +# with: |
| 134 | +# path: | |
| 135 | +# ${{ env.STORE }} |
| 136 | +# dist-newstyle |
| 137 | +# key: |
| 138 | +# ${{ steps.cache.outputs.cache-primary-key }} |
| 139 | + |
| 140 | + # Now we build. |
| 141 | + - name: Build all |
| 142 | + run: | |
| 143 | + wasm32-wasi-cabal build cardano-wasm --no-semaphore -j1 --ghc-options="-j1" |
| 144 | +
|
| 145 | + # - name: Run tests |
| 146 | + # env: |
| 147 | + # TMPDIR: ${{ runner.temp }} |
| 148 | + # TMP: ${{ runner.temp }} |
| 149 | + # KEEP_WORKSPACE: 1 |
| 150 | + # run: cabal test all --enable-tests --test-show-details=direct |
| 151 | + |
| 152 | + # Uncomment the following back in for debugging. Remember to launch a `pwsh` from |
| 153 | + # the tmux session to debug `pwsh` issues. And be reminded that the `/msys2` and |
| 154 | + # `/msys2/mingw64` paths are not in PATH by default for the workflow, but tmate |
| 155 | + # will put them in. |
| 156 | + # You may also want to run |
| 157 | + # |
| 158 | + # $env:PATH=("C:\Program Files\PowerShell\7;{0}" -f $env:ORIGINAL_PATH) |
| 159 | + # |
| 160 | + # to restore the original path. Do note that some test might need msys2 |
| 161 | + # and will silently fail if msys2 is not in path. See the "Run tests" step. |
| 162 | + # |
| 163 | + # - name: Setup tmate session |
| 164 | + # if: ${{ failure() }} |
| 165 | + # uses: mxschmitt/action-tmate@v3 |
| 166 | + # with: |
| 167 | + # limit-access-to-actor: true |
| 168 | + |
| 169 | + wasm-builds-complete: |
| 170 | + needs: [build] |
| 171 | + if: ${{ always() }} |
| 172 | + runs-on: ubuntu-latest |
| 173 | + steps: |
| 174 | + - name: Check if any previous job failed |
| 175 | + run: | |
| 176 | + if [[ "${{ needs.build.result }}" == "failure" ]]; then |
| 177 | + # this ignores skipped dependencies |
| 178 | + echo 'Required jobs failed to build.' |
| 179 | + exit 1 |
| 180 | + else |
| 181 | + echo 'Build complete' |
| 182 | + fi |
| 183 | +
|
0 commit comments