From ce57c64b05a9a134ddb60cc19993f77c1b2d6205 Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Sun, 12 Oct 2025 13:04:09 +0800 Subject: [PATCH 1/9] [ fix ] Update test.yaml WASM build to match wasm.yaml approach --- .github/workflows/test.yaml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ac0c5b9..8b33890 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -407,27 +407,19 @@ jobs: mv cabal.project.wasm32 cabal.project wasm32-wasi-cabal configure --flag=Agda-2-8-0 - - name: 'Build dep: lsp-types' - uses: nick-fields/retry@v3 - id: build-dep-lsp-types - with: - timeout_minutes: 10 - max_attempts: 2 - command: cd als && wasm32-wasi-cabal build lib:lsp-types - - - name: 'Build dep: agda' + - name: Build Agda as dependency id: build-dep-agda working-directory: './als' run: wasm32-wasi-cabal build lib:agda - name: Cache dist-newstyle uses: actions/cache/save@v4 - if: steps.build-dep-lsp-types.outcome == 'success' && steps.build-dep-agda.outcome == 'success' + if: steps.build-dep-agda.outcome == 'success' with: path: als/dist-newstyle key: dist-newstyle-${{ env.CI_CACHE_KEY }}-${{ hashFiles('als/dist-newstyle/**') }} - - name: Build dependencies + - name: Build dependencies other than Agda working-directory: './als' run: | # Setup network submodule autotools From 60433b1b3e8922ed3c5c6cde54f682873f717c02 Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Sun, 12 Oct 2025 13:22:56 +0800 Subject: [PATCH 2/9] [ fix ] Add delay to dev release creation to avoid draft status --- .github/workflows/test.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8b33890..939dc02 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -316,7 +316,12 @@ jobs: run: | # Delete existing dev release if it exists gh release delete dev --cleanup-tag -y || true - + + # Wait for GitHub to process the deletion to avoid race condition + # that causes releases to be created as drafts + # See: https://github.com/cli/cli/issues/8458 + sleep 5 + # Create new dev pre-release gh release create dev \ --title "Development Release (dev)" \ From f155b05f82788e26715d46188538534b1a575fc3 Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Sun, 12 Oct 2025 13:39:02 +0800 Subject: [PATCH 3/9] [ change ][ ci ] Create dev release on either `dev` or `ci` branches --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 939dc02..68e6980 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -310,7 +310,7 @@ jobs: # dev release (optional) - name: ๐Ÿšข Create/Update Dev Release - if: github.ref == 'refs/heads/dev' && matrix.agda == 'Agda-2.8.0' && matrix.os == 'ubuntu-latest' + if: (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci') && matrix.agda == 'Agda-2.8.0' && matrix.os == 'ubuntu-latest' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -329,7 +329,7 @@ jobs: --prerelease - name: ๐Ÿ“ค Upload artifacts to dev release - if: github.ref == 'refs/heads/dev' && matrix.agda == 'Agda-2.8.0' + if: (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci') && matrix.agda == 'Agda-2.8.0' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -337,7 +337,7 @@ jobs: build-wasm: name: Build WASM - if: github.ref == 'refs/heads/dev' + if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' runs-on: ubuntu-22.04 env: From 0186b47941e4b25f8c446b6af16957c3b5b685ec Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Sun, 12 Oct 2025 17:00:04 +0800 Subject: [PATCH 4/9] [ fix ] Dependency of ghc-wasm-meta --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 68e6980..1b92141 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -342,7 +342,7 @@ jobs: env: GHC_WASM_META_FLAVOUR: '9.10' - GHC_WASM_META_COMMIT_HASH: '7927129e42bcd6a54b9e06e26455803fa4878261' + GHC_WASM_META_COMMIT_HASH: 'c3f44696d29aaeadd755d69c51735954bfcd59db' steps: - uses: actions/checkout@v4 From 3a4ae8812b1c946c9c9fa2d97960ffbc589c9d35 Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Sun, 12 Oct 2025 17:48:24 +0800 Subject: [PATCH 5/9] [ change ][ ci ] Consolidate release creation --- .github/workflows/release.yaml | 28 ---------------- .github/workflows/test.yaml | 61 ++++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 0fdfa5d..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Release - -on: - push: - tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 - -jobs: - release: - name: Create Github Release - if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest - steps: - - - name: ๐Ÿ“ฅ Checkout repository - uses: actions/checkout@v4 - - - name: ๐Ÿญ Create Release - run: | - gh release create ${{ github.ref_name }} --generate-notes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # - name: โซ Upload to Hackage - # id: upload_hackage - # env: - # HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }} - # uses: freckle/stack-upload-action@main diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1b92141..8f7f346 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,8 +15,45 @@ on: branches: [master] jobs: + create-release: + name: Create Release + if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' + runs-on: ubuntu-latest + steps: + + - name: ๐Ÿ“ฅ Checkout repository + uses: actions/checkout@v4 + + - name: ๐Ÿญ Create Stable Release + if: startsWith(github.ref, 'refs/tags/v') + run: | + gh release create ${{ github.ref_name }} --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: ๐Ÿšข Create/Update Dev Release + if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Delete existing dev release if it exists + gh release delete dev --cleanup-tag -y || true + + # Wait for GitHub to process the deletion to avoid race condition + # that causes releases to be created as drafts + # See: https://github.com/cli/cli/issues/8458 + sleep 5 + + # Create new dev pre-release + gh release create dev \ + --title "Development Release (dev)" \ + --notes "Development pre-release build from latest changes. This is a pre-release for testing purposes." \ + --prerelease + build-and-test: - runs-on: ${{ matrix.os }} + needs: create-release + if: always() # Run even if create-release is skipped (non-tag pushes) + runs-on: ${{ matrix.os }} strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest, macos-13] @@ -309,25 +346,6 @@ jobs: run: gh release upload ${{ github.ref_name }} $ARTEFACT.zip --clobber # dev release (optional) - - name: ๐Ÿšข Create/Update Dev Release - if: (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci') && matrix.agda == 'Agda-2.8.0' && matrix.os == 'ubuntu-latest' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Delete existing dev release if it exists - gh release delete dev --cleanup-tag -y || true - - # Wait for GitHub to process the deletion to avoid race condition - # that causes releases to be created as drafts - # See: https://github.com/cli/cli/issues/8458 - sleep 5 - - # Create new dev pre-release - gh release create dev \ - --title "Development Release (dev)" \ - --notes "Development pre-release build from latest changes. This is a pre-release for testing purposes." \ - --prerelease - - name: ๐Ÿ“ค Upload artifacts to dev release if: (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci') && matrix.agda == 'Agda-2.8.0' env: @@ -337,7 +355,8 @@ jobs: build-wasm: name: Build WASM - if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' + needs: create-release + if: always() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci') runs-on: ubuntu-22.04 env: From 58b7af30904f75b7ed86bf7ef3a3b8d0a5fb9793 Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Sun, 12 Oct 2025 20:38:10 +0800 Subject: [PATCH 6/9] [ change ][ ci ] Split the workflow into: build + test -> release -> upload --- .github/workflows/test.yaml | 176 +++++++++++++++++++++++------------- 1 file changed, 111 insertions(+), 65 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8f7f346..0c8815c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,44 +15,8 @@ on: branches: [master] jobs: - create-release: - name: Create Release - if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' - runs-on: ubuntu-latest - steps: - - - name: ๐Ÿ“ฅ Checkout repository - uses: actions/checkout@v4 - - - name: ๐Ÿญ Create Stable Release - if: startsWith(github.ref, 'refs/tags/v') - run: | - gh release create ${{ github.ref_name }} --generate-notes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: ๐Ÿšข Create/Update Dev Release - if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Delete existing dev release if it exists - gh release delete dev --cleanup-tag -y || true - - # Wait for GitHub to process the deletion to avoid race condition - # that causes releases to be created as drafts - # See: https://github.com/cli/cli/issues/8458 - sleep 5 - - # Create new dev pre-release - gh release create dev \ - --title "Development Release (dev)" \ - --notes "Development pre-release build from latest changes. This is a pre-release for testing purposes." \ - --prerelease - build-and-test: - needs: create-release - if: always() # Run even if create-release is skipped (non-tag pushes) + name: Build and Test runs-on: ${{ matrix.os }} strategy: matrix: @@ -336,27 +300,18 @@ jobs: mv zip/"$($env:ARTEFACT).zip" . - name: ๐Ÿงช Run tests - run: stack test $STACK_YAML_ARG --ta --als-path=zip/als - - # release (optional) - - name: ๐Ÿšข Release Artifacts (stable) - if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release upload ${{ github.ref_name }} $ARTEFACT.zip --clobber + run: stack test $STACK_YAML_ARG - # dev release (optional) - - name: ๐Ÿ“ค Upload artifacts to dev release - if: (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci') && matrix.agda == 'Agda-2.8.0' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload dev $ARTEFACT.zip --clobber + - name: ๐Ÿ“ค Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARTEFACT }} + path: ${{ env.ARTEFACT }}.zip + retention-days: 1 build-wasm: name: Build WASM - needs: create-release - if: always() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci') + if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' runs-on: ubuntu-22.04 env: @@ -482,17 +437,108 @@ jobs: path: ~/.ghc-wasm key: ${{ steps.ghc-wasm-cache-restore.outputs.cache-primary-key }} - - name: ๐Ÿ“ค Upload WASM to dev release + - name: ๐Ÿ“ค Upload WASM artifact + uses: actions/upload-artifact@v4 + with: + name: als-dev-wasm + path: ~/out/${{ env.WASM_BINARY_NAME }} + retention-days: 1 + + create-release: + name: Create Release + needs: [build-and-test, build-wasm] + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci') + runs-on: ubuntu-latest + steps: + + - name: ๐Ÿ“ฅ Checkout repository + uses: actions/checkout@v4 + + - name: ๐Ÿญ Create Stable Release + if: startsWith(github.ref, 'refs/tags/v') + run: | + gh release create ${{ github.ref_name }} --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: ๐Ÿšข Create/Update Dev Release + if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - cd ~/out - ls -la - echo "Looking for WASM binary: $WASM_BINARY_NAME" - if [ -f "$WASM_BINARY_NAME" ]; then - mv "$WASM_BINARY_NAME" als-dev-wasm - gh release upload dev als-dev-wasm --clobber --repo ${{ github.repository }} - else - echo "WASM binary '$WASM_BINARY_NAME' not found in ~/out" - exit 1 - fi \ No newline at end of file + # Delete existing dev release if it exists + gh release delete dev --cleanup-tag -y || true + + # Wait for GitHub to process the deletion to avoid race condition + # that causes releases to be created as drafts + # See: https://github.com/cli/cli/issues/8458 + sleep 5 + + # Create new dev pre-release + gh release create dev \ + --title "Development Release (dev)" \ + --notes "Development pre-release build from latest changes. This is a pre-release for testing purposes." \ + --prerelease + + upload-stable-release: + name: Upload to Stable Release + needs: create-release + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + + - name: ๐Ÿ“ฅ Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: ๐Ÿšข Upload artifacts to release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd artifacts + for dir in */; do + artifact_name="${dir%/}" + echo "Uploading ${artifact_name}..." + if [ -f "${artifact_name}/${artifact_name}.zip" ]; then + gh release upload ${{ github.ref_name }} "${artifact_name}/${artifact_name}.zip" --clobber --repo ${{ github.repository }} + else + echo "Warning: No .zip file found in ${artifact_name}" + fi + done + + upload-dev-release: + name: Upload to Dev Release + needs: create-release + if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' + runs-on: ubuntu-latest + steps: + + - name: ๐Ÿ“ฅ Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: ๐Ÿšข Upload artifacts to dev release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd artifacts + # Upload only Agda-2.8.0 artifacts and WASM + for dir in *Agda-2.8.0* als-dev-wasm; do + if [ -d "$dir" ]; then + artifact_name="$dir" + echo "Uploading ${artifact_name}..." + if [ -f "${artifact_name}/${artifact_name}.zip" ]; then + gh release upload dev "${artifact_name}/${artifact_name}.zip" --clobber --repo ${{ github.repository }} + elif [ "$artifact_name" = "als-dev-wasm" ]; then + # Find the WASM binary (filename may vary) + wasm_file=$(find "${artifact_name}" -type f -name "als*" | head -1) + if [ -n "$wasm_file" ]; then + gh release upload dev "$wasm_file" --clobber --repo ${{ github.repository }} + else + echo "Warning: WASM binary not found in ${artifact_name}" + fi + fi + fi + done \ No newline at end of file From 3fbc1da7dbc882496ab2e6d5933e27299a992224 Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Sun, 12 Oct 2025 21:20:58 +0800 Subject: [PATCH 7/9] [ change ][ ci ] Cache the Haskell toolchain --- .github/workflows/test.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0c8815c..a209382 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -68,6 +68,17 @@ jobs: echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}" echo GHC_VERSION="${GHC_VERSION}" >> "${GITHUB_ENV}" + - name: ๐Ÿ’พ Cache Haskell toolchain + if: runner.os == 'macOS' + uses: actions/cache@v4 + with: + path: | + ~/.ghcup + ~/.stack + key: ${{ runner.os }}-haskell-${{ env.GHC_VERSION }}-stack-latest + restore-keys: | + ${{ runner.os }}-haskell-${{ env.GHC_VERSION }}- + - name: ๐Ÿ— Setup Haskell if : runner.os == 'macOS' uses: haskell-actions/setup@v2 From fdc58cb46ced4f81d150513f2f15669d70e54542 Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Sun, 12 Oct 2025 21:34:08 +0800 Subject: [PATCH 8/9] [ change ][ ci ] Improve CI caching strategy --- .github/workflows/test.yaml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a209382..a6d26df 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -74,10 +74,12 @@ jobs: with: path: | ~/.ghcup - ~/.stack + ~/.stack/programs + ~/.stack/pantry key: ${{ runner.os }}-haskell-${{ env.GHC_VERSION }}-stack-latest restore-keys: | ${{ runner.os }}-haskell-${{ env.GHC_VERSION }}- + ${{ runner.os }}-haskell- - name: ๐Ÿ— Setup Haskell if : runner.os == 'macOS' @@ -344,6 +346,8 @@ jobs: with: path: ~/.ghc-wasm key: ghc-wasm-${{ env.CI_CACHE_KEY }} + restore-keys: | + ghc-wasm-${{ runner.os }}-${{ runner.arch }}- - name: Try to restore cached native cabal id: native-cabal-cache-restore @@ -353,15 +357,17 @@ jobs: ~/.config/cabal ~/.cache/cabal key: native-cabal-${{ env.CI_CACHE_KEY }} + restore-keys: | + native-cabal-${{ runner.os }}-${{ runner.arch }}- - name: Try to restore cached dist-newstyle id: dist-newstyle-cache-restore uses: actions/cache/restore@v4 with: path: als/dist-newstyle - key: dist-newstyle-${{ env.CI_CACHE_KEY }}-${{ hashFiles('als/dist-newstyle/**') }} + key: dist-newstyle-${{ env.CI_CACHE_KEY }} restore-keys: | - dist-newstyle-${{ env.CI_CACHE_KEY }}- + dist-newstyle-${{ runner.os }}-${{ runner.arch }}- - name: Clone and setup ghc-wasm-meta id: ghc-wasm-setup @@ -407,7 +413,7 @@ jobs: if: steps.build-dep-agda.outcome == 'success' with: path: als/dist-newstyle - key: dist-newstyle-${{ env.CI_CACHE_KEY }}-${{ hashFiles('als/dist-newstyle/**') }} + key: dist-newstyle-${{ env.CI_CACHE_KEY }} - name: Build dependencies other than Agda working-directory: './als' From ee483f28d57a990c982405cdb04bfb58c8775086 Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Sun, 12 Oct 2025 21:56:09 +0800 Subject: [PATCH 9/9] [ fix ][ ci ] Prevent mixing cache key on ARM64 and Intel macOS --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a6d26df..374e282 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -76,10 +76,10 @@ jobs: ~/.ghcup ~/.stack/programs ~/.stack/pantry - key: ${{ runner.os }}-haskell-${{ env.GHC_VERSION }}-stack-latest + key: ${{ runner.os }}-${{ runner.arch }}-haskell-${{ env.GHC_VERSION }}-stack-latest restore-keys: | - ${{ runner.os }}-haskell-${{ env.GHC_VERSION }}- - ${{ runner.os }}-haskell- + ${{ runner.os }}-${{ runner.arch }}-haskell-${{ env.GHC_VERSION }}- + ${{ runner.os }}-${{ runner.arch }}-haskell- - name: ๐Ÿ— Setup Haskell if : runner.os == 'macOS'