fix: return 404 on no matching ops in the mock #226
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: main | |
env: | |
LANG: C.UTF-8 | |
GH_TOKEN: ${{ github.token }} | |
on: | |
push: | |
branches: main | |
pull_request: | |
branches: main | |
permissions: | |
contents: write | |
packages: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build on ${{ matrix.os }} using GHC ${{ matrix.ghc-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# os: [ubuntu-24.04, macos-15, windows-2022] | |
os: [ubuntu-24.04] | |
ghc-version: ['9.6.6'] | |
cabal-version: ['3.12.1.0'] | |
env: | |
platform: ${{ startsWith(matrix.os, 'ubuntu') && 'x86_64-linux' || | |
startsWith(matrix.os, 'macos') && 'arm64-macos' || | |
startsWith(matrix.os, 'windows') && 'x86_64-windows' }} | |
outputs: | |
new-version: ${{ steps.version-bump.outputs.new-version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up GHC ${{ matrix.ghc-version }} (MacOS and Windows only) | |
if: ${{ env.platform != 'x86_64-linux' }} | |
uses: haskell-actions/setup@v2 | |
id: setup | |
with: | |
ghc-version: ${{ matrix.ghc-version }} | |
cabal-version: ${{ matrix.cabal-version }} | |
cabal-update: false | |
- name: Install make (Windows only) | |
if: ${{ env.platform == 'x86_64-windows' }} | |
run: choco install make | |
# Use Alpine container to get static binaries on Linux. | |
- name: Login to GitHub Container Registry (Linux only) | |
if: ${{ env.platform == 'x86_64-linux' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Pull image (Linux only) | |
if: ${{ env.platform == 'x86_64-linux' }} | |
run: make pull-image | |
- name: Build image (Linux only) | |
if: ${{ env.platform == 'x86_64-linux' }} | |
env: | |
GITHUB_EVENT_BEFORE: ${{ github.event.before }} | |
GITHUB_EVENT_AFTER: ${{ github.event.after }} | |
run: make build-image | |
- name: Push image (Linux only) | |
# Don't push on PRs. | |
if: ${{ env.platform == 'x86_64-linux' && | |
github.event_name == 'push' && | |
github.ref == 'refs/heads/main' }} | |
run: make push-image | |
- name: Configure and create build plan | |
run: make dist-newstyle/cache/plan.json | |
# XXX: Use a separate step to create the path, using >> GITHUB_ENV | |
# if the caches are not all in the same directories on all OSes... | |
# '/home/runner/.cache/cabal/packages\n /home/runner/.cabal/store\n dist-newstyle' || | |
- name: Restore cached dependencies | |
uses: actions/cache/restore@v4 | |
id: cache | |
env: | |
key: ${{ runner.os }}-ghc-${{ matrix.ghc-version }}-cabal-${{ matrix.cabal-version }} | |
with: | |
path: ${{ env.platform == 'x86_64-linux' && | |
'/home/runner/.cabal/store' || | |
steps.setup.outputs.cabal-store }} | |
key: ${{ env.key }}-plan-${{ hashFiles('dist-newstyle/cache/plan.json') }} | |
restore-keys: ${{ env.key }}-plan- | |
- name: Build dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: make build-deps | |
- name: Debug .cabal cache | |
shell: bash | |
#if: ${{ env.platform != 'x86_64-windows' }} | |
run: | | |
ls -Rlh ${HOME}/.cabal || true | |
- name: Debug .cabal/store cache | |
shell: bash | |
#if: ${{ env.platform != 'x86_64-windows' }} | |
run: | | |
echo ${{ steps.setup.outputs.cabal-store }} | |
ls -Rlh ${{ steps.setup.outputs.cabal-store }} || true | |
echo "===" | |
ls -Rlh ${HOME}/.cabal/store || true | |
- name: Debug dist-newstyle cache | |
shell: bash | |
#if: ${{ env.platform != 'x86_64-windows' }} | |
run: | | |
ls -Rlh dist-newstyle || true | |
# Cache dependencies already here, so that we do not have to rebuild them | |
# should the subsequent steps fail. | |
- name: Save cached dependencies | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
uses: actions/cache/save@v4 | |
with: | |
path: ${{ env.platform == 'x86_64-linux' && | |
'/home/runner/.cabal/store' || | |
steps.setup.outputs.cabal-store }} | |
key: ${{ steps.cache.outputs.cache-primary-key }} | |
- name: Build | |
env: | |
SPEX_GIT_COMMIT: ${{ github.sha }} | |
run: make build | |
- name: Test | |
run: make test | |
- name: Check for version bump | |
id: version-bump | |
run: make bump | |
- name: Install binaries | |
# Only if there's a version bump and we are merging to main, i.e | |
# exclude PRs. | |
if: ${{ steps.version-bump.outputs.new-version != '' && | |
github.event_name == 'push' && | |
github.ref == 'refs/heads/main' }} | |
id: install | |
run: make install | |
- name: Install upx (Windows only) | |
if: ${{ env.platform == 'x86_64-windows' && | |
steps.install.outcome == 'success' }} | |
run: choco install upx | |
# upx: CantPackException: macOS is currently not supported | |
# - name: Install upx (MacOS only) | |
# if: ${{ env.platform == 'arm64-macos' }} | |
# run: brew install upx | |
- name: Compress binaries (Linux and Windows only) | |
if: ${{ env.platform != 'arm64-macos' && | |
steps.install.outcome == 'success' }} | |
run: make compress | |
- name: Upload binary artifacts | |
if: steps.install.outcome == 'success' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.platform }} | |
path: dist-newstyle/bin/* | |
if-no-files-found: error | |
release: | |
name: Create release | |
runs-on: ubuntu-latest | |
needs: build | |
# Exclude PRs. | |
if: ${{ needs.build.outputs.new-version && | |
github.event_name == 'push' && | |
github.ref == 'refs/heads/main' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
spex.cabal | |
cabal.project | |
Makefile | |
CHANGELOG.md | |
sparse-checkout-cone-mode: false | |
- name: Download binary artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist-newstyle/bin/ | |
- name: Create release | |
env: | |
NEW_VERSION: ${{ needs.build.outputs.new-version }} | |
run: make release | |
smoke-test: | |
name: Smoke test on ${{ matrix.os }} | |
needs: release | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-24.04, macos-15, windows-2022] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
spex.cabal | |
cabal.project | |
Makefile | |
sparse-checkout-cone-mode: false | |
- name: Download and run spexup | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: make spexup | |
- name: Smoke test `spex --version` | |
run: make smoke |