Skip to content
28 changes: 0 additions & 28 deletions .github/workflows/release.yaml

This file was deleted.

193 changes: 136 additions & 57 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ on:

jobs:
build-and-test:
runs-on: ${{ matrix.os }}
name: Build and Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest, macos-13]
Expand Down Expand Up @@ -67,6 +68,19 @@ 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/programs
~/.stack/pantry
key: ${{ runner.os }}-${{ runner.arch }}-haskell-${{ env.GHC_VERSION }}-stack-latest
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-haskell-${{ env.GHC_VERSION }}-
${{ runner.os }}-${{ runner.arch }}-haskell-

- name: 🏗 Setup Haskell
if : runner.os == 'macOS'
uses: haskell-actions/setup@v2
Expand Down Expand Up @@ -299,45 +313,23 @@ 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: 🚢 Create/Update Dev Release
if: github.ref == 'refs/heads/dev' && 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

# 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' && 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
if: github.ref == 'refs/heads/dev'
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci'
runs-on: ubuntu-22.04

env:
GHC_WASM_META_FLAVOUR: '9.10'
GHC_WASM_META_COMMIT_HASH: '7927129e42bcd6a54b9e06e26455803fa4878261'
GHC_WASM_META_COMMIT_HASH: 'c3f44696d29aaeadd755d69c51735954bfcd59db'

steps:
- uses: actions/checkout@v4
Expand All @@ -354,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
Expand All @@ -363,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
Expand Down Expand Up @@ -407,27 +403,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/**') }}
key: dist-newstyle-${{ env.CI_CACHE_KEY }}

- name: Build dependencies
- name: Build dependencies other than Agda
working-directory: './als'
run: |
# Setup network submodule autotools
Expand Down Expand Up @@ -466,17 +454,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
# 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