Skip to content

ci: debug linux install target #191

ci: debug linux install target

ci: debug linux install target #191

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:
#linux:
# name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [ubuntu-24.04]
# platform: ['x86_64-linux']
# ghc-version: ['9.6.6']
# cabal-version: ['3.12.1.0']
# steps:
# - uses: actions/checkout@v4
# # Following https://github.com/docker/build-push-action?tab=readme-ov-file#usage
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ github.token }}
# - name: Cache
# uses: actions/cache@v4
# id: cache
# with:
# path: |
# root-local-state-cabal-store
# root-cache-cabal
# dist-newstyle
# key: plan-${{ hashFiles('dist-newstyle/cache/plan.json') }}
# - name: Inject cache into docker
# uses: reproducible-containers/[email protected]
# with:
# cache-map: |
# {
# "root-local-state-cabal-store": "/root/.local/state/cabal/store",
# "root-cache-cabal": "/root/.cache/cabal",
# "dist-newstyle": "dist-newstyle"
# }
# skip-extraction: ${{ steps.cache.outputs.cache-hit }}
# - name: Build and test
# uses: docker/build-push-action@v6
# with:
# context: .
# pull: true
# # XXX: don't push feature branches either?
# push: ${{ github.event_name != 'pull_request' }} # Don't push on PRs.
# file: Dockerfile
# tags: |
# ghcr.io/spex-lang/spex-build:${{ github.ref_name }}
# ghcr.io/spex-lang/spex-build:latest
# # We pass in the version as a secret, since they don't affect the
# # container caching, this will be picked up and used by --version.
# # https://docs.docker.com/build/building/secrets/
# secrets: version=${{ github.sha }}
# # https://docs.docker.com/build/ci/github-actions/cache/#github-cache
# # https://docs.docker.com/build/ci/github-actions/cache/#cache-mounts
# cache-from: type=registry,ref=ghcr.io/spex-lang/spex-build:buildcache
# cache-to: type=registry,ref=ghcr.io/spex-lang/spex-build:buildcache,mode=max
# - name: Create new git tag, if merge to main and .cabal version is bumped
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
# uses: sol/haskell-autotag@v1
# id: autotag
# - name: Build static binaries
# if: steps.autotag.outputs.created
# uses: docker/build-push-action@v6
# with:
# context: .
# pull: true
# push: ${{ github.event_name != 'pull_request' }} # Don't push on PRs.
# file: release/Dockerfile
# tags: |
# ghcr.io/spex-lang/spex:${{ github.ref_name }}
# ghcr.io/spex-lang/spex:latest
# outputs: type=local,dest=${{ github.workspace }}/bin/
# # https://docs.docker.com/build/ci/github-actions/cache/#github-cache
# cache-from: type=registry,ref=ghcr.io/spex-lang/spex:buildcache
# cache-to: type=registry,ref=ghcr.io/spex-lang/spex:buildcache,mode=max
# - name: Release
# if: steps.autotag.outputs.created
# run: |
# ls -R bin/
# find bin/ -maxdepth 1 -type f -executable -exec \
# mv {} "{}-${{ steps.autotag.outputs.version }}-${{ matrix.platform }}" \;
# gh release create --draft --notes-file=CHANGELOG.md \
# "v${{ steps.autotag.outputs.version }}" ${{ github.workspace }}/bin/*
#
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
# XXX: only build if Dockerfile changed?
# git diff --name-only ${{ github.event.after }} ${{ github.event.before }} | grep Dockerfile?
- name: Build image (Linux only)
if: ${{ env.platform == 'x86_64-linux' }}
run: make build-image
- name: Push image (Linux only)
if: ${{ env.platform == 'x86_64-linux' }}
run: make push-image
- name: Restore cached dependencies
uses: actions/cache/restore@v4
id: cache
env:
key: ${{ runner.os }}-ghc-${{ matrix.ghc-version }}-cabal-${{ matrix.cabal-version }}
with:
# '/home/runner/.cache/cabal/packages\n /home/runner/.cabal/store\n dist-newstyle' ||
path: ${{ env.platform == 'x86_64-linux' &&
'/home/runner/.cabal/store' ||
steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-plan-
- name: Build dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: make build-deps
- name: Debug .cache/cabal cache
if: ${{ env.platform != 'x86_64-windows' }}
run: |
ls -Rlh ${HOME}/.cache/cabal || true
- name: Debug .cabal/store cache
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
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
# XXX: is env needed?
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
# XXX: is shell bash needeD?
shell: bash
# XXX: is env needed?
env:
SPEX_GIT_COMMIT: ${{ github.sha }}
run: make install
- name: Upload binary artifacts
if: steps.install.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: ${{ env.platform }}
path: bin/*
if-no-files-found: error
release:
name: Create release
runs-on: ubuntu-latest
needs: [build]
if: ${{ needs.build.outputs.new-version }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
spex.cabal
Makefile
CHANGELOG.md
sparse-checkout-cone-mode: false
- name: Download binary artifacts
uses: actions/download-artifact@v4
with:
path: bin
- name: Compress binaries and create release
env:
NEW_VERSION: ${{ needs.build.outputs.new-version }}
run: make release