Skip to content

docs: tweak motivation section in readme #240

docs: tweak motivation section in readme

docs: tweak motivation section in readme #240

Workflow file for this run

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]
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
with:
# NOTE: This is how many commits to checkout, the default is 1, but
# since in the "Build image" step we need to determine if the
# Dockerfile changed, so we need to fetch more than the last commit.
# Setting it to 0 will fetch all commits. We should monitor this to
# see if it gets slow over time.
fetch-depth: 0
- 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: 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' }}
env:
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
GITHUB_EVENT_AFTER: ${{ github.event.after }}
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
Dockerfile.app
sparse-checkout-cone-mode: false
# This is needed in order to push the new image.
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- 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
smoke-test-image:
name: Smoke test container image
needs: [build, release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
Makefile
sparse-checkout-cone-mode: false
- name: Smoke test containerised `spex --version`
env:
NEW_VERSION: ${{ needs.build.outputs.new-version }}
run: make smoke-image