wip #42
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: Haskell CI | |
on: [push] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
ghc: ["8.10.7"] | |
os: [ubuntu-latest, windows-latest] | |
env: | |
# current ref from: 27.02.2022 | |
SECP256K1_REF: ac83be33d0956faf6b7f61a60ab524ef7d6a473a | |
steps: | |
- name: "WIN: Setup MSYS2 and libraries" | |
if: runner.os == 'Windows' | |
uses: msys2/setup-msys2@v2 | |
with: | |
update: true | |
install: >- | |
base-devel | |
autoconf-wrapper | |
autoconf | |
automake | |
libtool | |
make | |
git | |
mingw-w64-x86_64-toolchain | |
mingw-w64-x86_64-libsodium | |
mingw-w64-x86_64-jq | |
- name: "WIN: Setup pkg-config" | |
if: runner.os == 'Windows' | |
run: | | |
pacman --noconfirm -S mingw-w64-x86_64-pkg-config | |
- name: "LINUX: Setup haskell" | |
if: runner.os != 'Windows' | |
uses: haskell/actions/setup@v2 | |
id: setup-haskell | |
with: | |
ghc-version: ${{ matrix.ghc }} | |
cabal-version: 3.6.2.0 | |
- name: "WIN: Setup Haskell" | |
id: win-setup-haskell | |
if: runner.os == 'Windows' | |
run: | | |
# see https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/bootstrap/bootstrap-haskell | |
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \ | |
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \ | |
BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=1 \ | |
BOOTSTRAP_HASKELL_ADJUST_BASHRC=1 \ | |
BOOTSTRAP_HASKELL_GHC_VERSION="${{ matrix.ghc }}" \ | |
BOOTSTRAP_HASKELL_CABAL_VERSION="3.6.2.0" \ | |
sh | |
# MSYS2 doesn't inherit $GITHUB_PATH so this is needed | |
cat <(echo "source /c/ghcup/env") ~/.bashrc > ~/.bashrc.new | |
mv ~/.bashrc.new ~/.bashrc | |
source ~/.bashrc | |
# There is an issue with crt libraries, fixed by prepending the ghc | |
# mingw32 libraries directory to every other library directory. | |
echo "# Original cabal config extra-lib-dirs" | |
grep extra-lib-dirs /c/cabal/config | |
sed -i 's/C:\\msys64\\mingw64\\lib/C:\\ghcup\\ghc\\8.10.7\\mingw\\x86_64-w64-mingw32\\lib, C:\\msys64\\mingw64\\lib/g' /c/cabal/config | |
echo "# Modified cabal config extra-lib-dirs" | |
grep extra-lib-dirs /c/cabal/config | |
ghc --version | |
cabal --version | |
echo "::set-output name=cabal-store::$(dirname $(cabal --help | tail -1 | tr -d ' '))\\store" | |
- name: Update Hackage index | |
run: cabal update | |
- name: Set cache version | |
run: echo "CACHE_VERSION=20220919" >> $GITHUB_ENV | |
- name: "LINUX: Install build environment (apt-get)" | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install libsodium23 libsodium-dev | |
sudo apt-get -y install libsystemd0 libsystemd-dev | |
sudo apt-get -y remove --purge software-properties-common | |
sudo apt-get -y autoremove | |
- name: "LINUX: Install build environment (for secp256k1)" | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get -y install autoconf automake libtool | |
echo "CI_SECP_FLAGS=--prefix=/usr" >> $GITHUB_ENV | |
echo "CI_SECP_INSTALL_CMD=sudo" >> $GITHUB_ENV | |
- name: "Install secp256k1" | |
run: | | |
git clone https://github.com/bitcoin-core/secp256k1 | |
( cd secp256k1 | |
git switch $SECP256K1_REF --detach | |
./autogen.sh | |
./configure $CI_SECP_FLAGS --enable-module-schnorrsig --enable-experimental | |
make | |
make check | |
$CI_SECP_INSTALL_CMD make install | |
) | |
- uses: actions/checkout@v3 | |
- name: "Configure cabal.project.local" | |
run: | | |
# running cabal configure overrides every other configuration already | |
# present in the cabal.project.local file so it is quite disruptive. By | |
# manually adding the options we want, this is always consistent. | |
cat ./cabal.project.local.ci >> ./cabal.project.local | |
cat >> cabal.project.local <<EOF | |
-- Add strcittvar check | |
package io-classes | |
flags: +checktvarinvariant | |
package cardano-crypto-praos | |
flags: -external-libsodium-vrf | |
-- cabal configure --enable-tests | |
ignore-project: False | |
tests: True | |
EOF | |
cat ./cabal.project.local | |
- name: Record dependencies | |
id: record-deps | |
run: | | |
cabal build all --dry-run | |
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt | |
echo "::set-output name=weeknum::$(/bin/date -u "+%W")" | |
- uses: actions/cache@v3 | |
name: "Cache `cabal store`" | |
with: | |
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.setup-haskell.outputs.cabal-store }} | |
key: cache-dependencies-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }} | |
restore-keys: cache-dependencies-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }} | |
- uses: actions/cache@v3 | |
name: "Cache `dist-newstyle`" | |
with: | |
path: | | |
dist-newstyle | |
!dist-newstyle/**/.git | |
key: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ steps.record-deps.outputs.weeknum }} | |
restore-keys: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }} | |
- name: Build dependencies | |
run: cabal build --only-dependencies all | |
- name: Build projects [build] | |
run: cabal build all | |
# Test network packages | |
- name: ntp-client [test] | |
run: cabal run ntp-client:test | |
- name: network-mux [test] | |
run: cabal run network-mux:test | |
- name: ourobors-network-testing [test] | |
run: cabal run ouroboros-network-testing:test | |
# issue: #1818 | |
- name: ourobors-network-framework [test] | |
run: cabal run ouroboros-network-framework:test -- -p '$0 != "typed-protocols.Socket.socket send receive IPv4"' | |
- name: ouroboros-network [test] | |
run: cabal run ouroboros-network:test | |
# Consensus tests take too long on GitHub's Azure machines |