CI: Switch to haskell-ci.dhall

This commit is contained in:
Richard Marko 2023-11-08 15:44:21 +01:00
parent f0dfc6d670
commit 0ee3bd31d5
8 changed files with 102 additions and 335 deletions

View File

@ -1,80 +0,0 @@
name: "Hackage, Cabal, Linux"
on:
pull_request:
push:
branches:
- master
schedule:
- cron: "45 02 * * *"
env:
cabalConfig: --enable-tests --disable-optimization --enable-deterministic
jobs:
build10:
name: "GHC"
runs-on: ubuntu-latest
strategy:
matrix:
packageRoot: [ hnix-store-remote ]
ghc: [ "9.0", "8.6" ]
defaults:
run:
working-directory: "./${{ matrix.packageRoot }}"
steps:
- name: "Git checkout"
uses: actions/checkout@v4
with:
submodules: recursive
- name: "Haskell env setup"
id: HaskEnvSetup
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
- name: "Repository update"
run: cabal v2-update
- name: "Install additional system packages"
run: sudo apt install libsodium-dev
# Still required for Remote
- name: "Install Nix"
uses: cachix/install-nix-action@v23
if: matrix.packageRoot == 'hnix-store-remote'
# Remote: Enabling testsuite, because it requires networking in the default Nix environment.
- name: "Project-specific Cabal configuration"
if: matrix.packageRoot == 'hnix-store-remote'
run: echo "cabalConfig=$cabalConfig -f io-testsuite" >> $GITHUB_ENV
# NOTE: Freeze is for the caching
- name: "Configuration freeze"
run: cabal v2-freeze $cabalConfig
- name: "Hack: Copy freeze file to the root dir"
run: cp -a cabal.project.freeze ../cabal.project.freeze
- name: "Configuring GitHub cache"
uses: actions/cache@v3.3.2
with:
path: |
${{ steps.HaskEnvSetup.outputs.cabal-store }}
dist-newstyle
key: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ matrix.ghc }}-${{ hashFiles( 'cabal.project.freeze' ) }}
# 2022-04-22: `v2-` added to invalidate corrupted caches, can be removed after one week
restore-keys: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ matrix.ghc }}-v2
- name: "Build"
run: cabal v2-build $cabalConfig
- name: "Tests"
run: cabal v2-test $cabalConfig
- name: "Source distribution file"
if: ${{ matrix.ghc == '9.0' }}
run: cabal v2-sdist

View File

@ -1,72 +0,0 @@
name: "Hackage, Cabal, Linux"
on:
pull_request:
push:
branches:
- master
schedule:
- cron: "45 02 * * *"
env:
cabalConfig: --enable-tests --disable-optimization --enable-deterministic
jobs:
build10:
name: "GHC"
runs-on: ubuntu-latest
strategy:
matrix:
# Separation between Core & Store workflows made deliberately, so when one fixes Core, CI does not falls because of the Hackage Core Remote builds with.
# Also singleton also use is deliberate, it allows to reference the value in the further configuration & also leaves a name in the CI & preserves matrix flexibility for the future.
packageRoot: [ hnix-store-core ]
ghc: [ "9.0", "8.6" ]
defaults:
run:
working-directory: "./${{ matrix.packageRoot }}"
steps:
- name: "Git checkout"
uses: actions/checkout@v4
with:
submodules: recursive
- name: "Haskell env setup"
id: HaskEnvSetup
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
- name: "Repository update"
run: cabal v2-update
- name: "Install additional system packages"
run: sudo apt install libsodium-dev
# NOTE: Freeze is for the caching
- name: "Configuration freeze"
run: cabal v2-freeze $cabalConfig
- name: "Hack: Copy freeze file to the root dir"
run: cp -a cabal.project.freeze ../cabal.project.freeze
- name: "Configuring GitHub cache"
uses: actions/cache@v3.3.2
with:
path: |
${{ steps.HaskEnvSetup.outputs.cabal-store }}
dist-newstyle
key: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ matrix.ghc }}-${{ hashFiles( 'cabal.project.freeze' ) }}
# 2022-04-22: `v2-` added to invalidate corrupted caches, can be removed after one week
restore-keys: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ matrix.ghc }}-v2-
- name: "Build"
run: cabal v2-build $cabalConfig
- name: "Tests"
run: cabal v2-test $cabalConfig
- name: "Source distribution file"
if: ${{ matrix.ghc == '9.0' }}
run: cabal v2-sdist

View File

@ -1,64 +0,0 @@
name: "Hackage, Cabal, macOS"
on:
pull_request:
push:
branches:
- master
schedule:
- cron: "45 03 * * *"
env:
cabalConfig: --enable-tests --disable-optimization --enable-deterministic
jobs:
build10:
name: "GHC"
runs-on: macos-latest
strategy:
matrix:
packageRoot: [ hnix-store-core ]
defaults:
run:
working-directory: "./${{ matrix.packageRoot }}"
steps:
- name: "Git checkout"
uses: actions/checkout@v4
with:
submodules: recursive
- name: "Haskell env setup"
id: HaskEnvSetup
uses: haskell/actions/setup@v2
with:
ghc-version: '9.0'
- name: "Repository update"
run: cabal v2-update
- name: "Install additional system packages"
run: cabal v2-install tasty-discover
# NOTE: Freeze is for the caching
- name: "Configuration freeze"
run: cabal v2-freeze $cabalConfig
- name: "Copy freeze file to the root dir"
run: cp -a cabal.project.freeze ../cabal.project.freeze
- name: "Configuring GitHub cache"
uses: actions/cache@v3.3.2
with:
path: |
${{ steps.HaskEnvSetup.outputs.cabal-store }}
dist-newstyle
key: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ hashFiles( 'cabal.project.freeze' ) }}
restore-keys: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-
- name: "Build"
run: cabal v2-build $cabalConfig
- name: "Tests"
run: cabal v2-test $cabalConfig

View File

@ -1,75 +0,0 @@
name: "Release testing, Hackage, Cabal, Linux"
on:
release:
# created: a draft is saved, or a release or pre-release is published without previously being saved as a draft
types: [ created ]
env:
cabalConfig: --enable-tests --disable-optimization --enable-deterministic
jobs:
build10:
name: "GHC"
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
packageRoot: [ hnix-store-core, hnix-store-remote ]
# Since CI by default tests boundary GHCs, test middle versions of GHCs
ghc: [ "8.10", "8.8"]
defaults:
run:
working-directory: "./${{ matrix.packageRoot }}"
steps:
- name: "Git checkout"
uses: actions/checkout@v4
with:
submodules: recursive
- name: "Haskell env setup"
id: HaskEnvSetup
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
- name: "Repository update"
run: cabal v2-update
- name: "Install additional system packages"
run: sudo apt install libsodium-dev
# Still required for Remote
- name: "Install Nix"
uses: cachix/install-nix-action@v23
if: matrix.packageRoot == 'hnix-store-remote'
# Remote: Enabling testsuite, because it requires networking in the default Nix environment.
- name: "Project-specific Cabal configuration"
if: matrix.packageRoot == 'hnix-store-remote'
run: echo "cabalConfig=$cabalConfig -f io-testsuite" >> $GITHUB_ENV
# NOTE: Freeze is for the caching
- name: "Configuration freeze"
run: cabal v2-freeze $cabalConfig
- name: "Copy freeze file to the root dir"
run: cp -a cabal.project.freeze ../cabal.project.freeze
- name: "Configuring GitHub cache"
uses: actions/cache@v3.3.2
with:
path: |
${{ steps.HaskEnvSetup.outputs.cabal-store }}
dist-newstyle
key: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ matrix.ghc }}-${{ hashFiles( 'cabal.project.freeze' ) }}
# 2022-04-22: `v2-` added to invalidate corrupted caches, can be removed after one week
restore-keys: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ matrix.ghc }}-
- name: "Build"
run: cabal v2-build $cabalConfig
- name: "Tests"
run: cabal v2-test $cabalConfig

View File

@ -1,44 +0,0 @@
name: "(Optional) Nix dev env, Linux, main"
on:
pull_request:
push:
branches:
- master
schedule:
- cron: "45 03 * * *"
env:
cachixAccount: "hnix-store"
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}
jobs:
# 2020-12-22: NOTE: This is very MVP - is should be expanded, like it is in HNix.
build10:
name: "Default"
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
packageRoot: [ hnix-store-core, hnix-store-remote ]
defaults:
run:
working-directory: "./${{ matrix.packageRoot }}"
steps:
- name: "Git checkout"
uses: actions/checkout@v4
with:
submodules: recursive
- name: "Install Nix"
uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: "Install Cachix"
uses: cachix/cachix-action@v12
with:
name: ${{ env.cachixAccount }}
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: "Determined Nix-build"
run: nix-build ../ -A "haskellPackages.${{ matrix.packageRoot }}"

27
.github/workflows/ci.dhall vendored Normal file
View File

@ -0,0 +1,27 @@
let haskellCi =
https://raw.githubusercontent.com/sorki/github-actions-dhall/main/haskell-ci.dhall
let defSteps = haskellCi.defaultCabalSteps
in haskellCi.generalCi
( haskellCi.withNix
( defSteps
with extraSteps.pre
=
defSteps.extraSteps.pre
# [ haskellCi.installCachixStep "hnix-store"
, haskellCi.BuildStep.NameIf
{ name =
"Install libsodium"
, run = "sudo apt install libsodium-dev"
, `if` = "matrix.os == 'ubuntu-latest'"
}
]
)
)
haskellCi.DhallMatrix::{
, ghc =
[ haskellCi.GHC.GHC963, haskellCi.GHC.GHC947, haskellCi.GHC.GHC902 ]
, os = [ haskellCi.OS.Ubuntu, haskellCi.OS.MacOS ]
}
: haskellCi.CI.Type

9
.github/workflows/ci.sh vendored Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Script by @fisx
set -eo pipefail
cd "$( dirname "${BASH_SOURCE[0]}" )"
which dhall-to-yaml || cabal install dhall-yaml
echo "regenerating ci.yaml"
dhall-to-yaml-ng --generated-comment --file ci.dhall > ci.yaml

66
.github/workflows/ci.yaml vendored Normal file
View File

@ -0,0 +1,66 @@
# Code generated by dhall-to-yaml. DO NOT EDIT.
jobs:
build:
name: "GHC ${{ matrix.ghc }}, Cabal ${{ matrix.cabal }}, OS ${{ matrix.os }}"
"runs-on": "${{ matrix.os }}"
steps:
- uses: "cachix/install-nix-action@v23"
with:
nix_path: "nixpkgs=channel:nixos-unstable"
- uses: "cachix/cachix-action@v12"
with:
name: "hnix-store"
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- if: "matrix.os == 'ubuntu-latest'"
name: Install libsodium
run: "sudo apt install libsodium-dev"
- uses: "actions/checkout@v4"
with:
submodules: recursive
- id: "setup-haskell-cabal"
uses: "haskell-actions/setup@v2"
with:
"cabal-version": "${{ matrix.cabal }}"
"ghc-version": "${{ matrix.ghc }}"
- name: Update Hackage repository
run: cabal update
- name: cabal.project.local.ci
run: |
if [ -e cabal.project.local.ci ]; then
cp cabal.project.local.ci cabal.project.local
fi
- name: freeze
run: "cabal freeze --enable-tests --enable-benchmarks"
- uses: "actions/cache@v3"
with:
key: "${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.cabal}}-${{ hashFiles('cabal.project.freeze') }}"
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
- name: Install dependencies
run: "cabal build all --enable-tests --enable-benchmarks --only-dependencies"
- name: build all
run: "cabal build all --enable-tests --enable-benchmarks"
- name: test all
run: "cabal test all --enable-tests"
- name: haddock all
run: cabal haddock all
- name: Build with Nix
run: "nix-build"
strategy:
matrix:
cabal:
- '3.10'
ghc:
- '9.6.3'
- '9.4.7'
- '9.0.2'
os:
- "ubuntu-latest"
- "macos-latest"
name: Haskell CI
'on':
pull_request: {}
push: {}
schedule:
- cron: "4 20 10 * *"