Skip to content

Small CI config tidy #164

Small CI config tidy

Small CI config tidy #164

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request_target:
workflow_dispatch:
jobs:
extract-ghc-version:
name: Extract GHC version
runs-on: ubuntu-latest
outputs:
ghc-version: ${{ steps.get-ghc-version.outputs.ghc_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download yq-go
run: |
curl -L "https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64" -o /usr/local/bin/yq
chmod +x /usr/local/bin/yq
- name: Extract GHC version from nixkell.toml
id: get-ghc-version
run: |
echo "ghc_version=$(yq -eoy '.ghc.version' nixkell.toml)" | tee -a $GITHUB_OUTPUT
nix:
name: Build with GHC ${{ needs.extract-ghc-version.outputs.ghc-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: extract-ghc-version
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macOS-latest
env:
GHC_VERSION: ${{ needs.extract-ghc-version.outputs.ghc-version }}
steps:
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-799466911
- name: Checkout PR
uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout
uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request_target' }}
- name: Free disk space (Linux only)
if: ${{ runner.os == 'Linux' }}
uses: jlumbroso/free-disk-space@main
- name: Set nix path
id: nix-path
run: |
echo "nixpkgs=$(jq -r .nixpkgs.url ./nix/sources.json)" | tee -a $GITHUB_OUTPUT
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=${{ steps.nix-path.outputs.nixpkgs }}
extra_nix_config: |
log-lines = 1000
- name: Install and configure Cachix
uses: cachix/cachix-action@v15
with:
name: nixkell
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Nix Shell
run: |
nix-shell --run "echo OK"
- name: Check code formatting (Linux only)
if: ${{ runner.os == 'Linux' }}
run: |
nix-shell --run "treefmt --fail-on-change"
- name: GHC version
run: |
echo "Using GHC version $GHC_VERSION"
- name: Build
run: |
nix-build ./nix/release.nix --argstr compiler "$GHC_VERSION"
- name: Run
run: |
result/bin/nixkell