Skip to content

Haskell CI - NIGHTLY #13809

Haskell CI - NIGHTLY

Haskell CI - NIGHTLY #13809

Workflow file for this run

name: Haskell CI
# If it's a scheduled (for us: nightly) build, set the name of this run to a static value, so we can identify it easier.
# Otherwise, replicate the default run name: either the PR title if it exists, or the commit message otherwise.
run-name: |
${{github.event_name == 'schedule' && 'Haskell CI - NIGHTLY'
|| github.event.pull_request.title == '' && github.event.head_commit.message
|| github.event.pull_request.title}}
on:
push:
branches: [ "master", "release/**" ]
pull_request:
branches: [ "**" ]
schedule:
# "Nightly" builds: Every day at 06:00 UTC
- cron: '0 6 * * *'
# for running the workflow manually - useful for branches without PRs, for which jobs don't get ran automatically
workflow_dispatch:
inputs:
nightly:
description: Run with the same settings as a nightly build
type: boolean
default: false
# Cancel running workflows when a new workflow on the same PR or branch is started,
# but put scheduled workflows into their own group
concurrency:
group: ${{
format('{0}-{1}{2}',
github.workflow,
github.event.pull_request.number || github.ref,
github.event_name == 'schedule' && '-scheduled' || '')}}
cancel-in-progress: true
jobs:
build:
strategy:
matrix:
ghc: ["8.10.7", "9.2.8", "9.6.4", "9.8.2"]
os: [ubuntu-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
# Modify this value to "invalidate" the cabal cache.
CABAL_CACHE_VERSION: "2023-07-17"
# current ref from: 27.02.2022
SECP256K1_REF: ac83be33d0956faf6b7f61a60ab524ef7d6a473a
SECP_CACHE_VERSION: "2022-12-30"
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
uses: input-output-hk/actions/base@latest
with:
use-sodium-vrf: false # default is true
- name: Install Haskell
id: install-haskell
uses: input-output-hk/actions/haskell@latest
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: latest
- name: Configure to use libsodium
run: |
cat >> cabal.project <<EOF
package cardano-crypto-praos
flags: -external-libsodium-vrf
EOF
- name: Cabal update
run: cabal update
- name: Cabal configure
run: cabal configure --enable-tests --enable-benchmarks --write-ghc-environment-files=always
- uses: actions/cache@v4
if: matrix.os != 'macos-latest'
name: Cache cabal store
with:
path: |
${{ steps.install-haskell.outputs.cabal-store }}
# cache is invalidated upon a change to cabal.project (and/or cabal.project.local), a bump to
# CABAL_CACHE_VERSION or after a week of inactivity
key: cache-${{ runner.os }}-${{ matrix.ghc }}-${{ env.CABAL_CACHE_VERSION }}-${{ hashFiles('cabal.project*') }}
# Restoring attempts are from current branch then master
restore-keys: |
cache-${{ runner.os }}-${{ matrix.ghc }}-${{ env.CABAL_CACHE_VERSION }}-${{ hashFiles('cabal.project*') }}
- name: Check workflow test matrix
run: cabal build all --dry-run && scripts/check-workflow-test-matrix.hs
- name: Build dependencies
run: cabal build all --only-dependencies
- name: Build
run: cabal build all
# Pass working directory to test jobs
- name: Archive working directory
run: tar --format pax -cf /var/tmp/state.tar . && mv /var/tmp/state.tar .
- name: Upload working directory archive
uses: actions/upload-artifact@v4
with:
name: state-${{ matrix.ghc }}-${{ matrix.os }}
path: state.tar
overwrite: true
retention-days: 1
test:
needs: build
strategy:
matrix:
package:
- byron-spec-chain
- byron-spec-ledger
- cardano-crypto-wrapper
- cardano-data
- cardano-ledger-allegra
- cardano-ledger-alonzo
- cardano-ledger-alonzo-test
- cardano-ledger-api
- cardano-ledger-babbage
- cardano-ledger-babbage-test
- cardano-ledger-binary
- cardano-ledger-byron
- cardano-ledger-conformance
- cardano-ledger-conway
- cardano-ledger-conway-test
- cardano-ledger-core
- cardano-ledger-mary
- cardano-ledger-shelley
- cardano-ledger-shelley-ma-test
- cardano-ledger-shelley-test
- cardano-ledger-test
- cardano-protocol-tpraos
- constrained-generators
- non-integral
- set-algebra
- small-steps
- vector-map
ghc: ["8.10.7", "9.2.8", "9.6.4", "9.8.2"]
os: [ubuntu-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.package }}-${{ matrix.ghc }}-${{ matrix.os }}
env:
# Modify this value to "invalidate" the cabal cache.
CABAL_CACHE_VERSION: "2023-07-17"
# current ref from: 27.02.2022
SECP256K1_REF: ac83be33d0956faf6b7f61a60ab524ef7d6a473a
SECP_CACHE_VERSION: "2022-12-30"
defaults:
run:
shell: bash
steps:
- name: Install system dependencies
uses: input-output-hk/actions/base@latest
with:
use-sodium-vrf: false # default is true
- name: Install Haskell
id: install-haskell
uses: input-output-hk/actions/haskell@latest
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: latest
- name: Set up Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Install cbor-diag and cddl
run: |
gem install cddl -v 0.10.3
gem install cbor-diag
- name: Download Mainnet Mirror
run: |
REF=a31ac75
{
curl -L https://github.com/input-output-hk/cardano-mainnet-mirror/tarball/$REF -o mainnet-mirror.tgz
tar -xzf mainnet-mirror.tgz
mv input-output-hk-cardano-mainnet-mirror-$REF/epochs .
} ||
{
git clone https://github.com/input-output-hk/cardano-mainnet-mirror
cd cardano-mainnet-mirror
git checkout $REF
mv epochs ..
cd ..
}
- name: Set NIGHTLY environment variable if the job was triggered by the scheduler
if: "${{ github.event_name == 'schedule'
|| contains(github.event.pull_request.title, 'nightly')
|| github.event_name == 'workflow_dispatch' && github.event.inputs.nightly }}"
run: |
echo "NIGHTLY=true" >> $GITHUB_ENV
# Retrieve working directory from build jobs
- name: Download working directory archive
uses: actions/download-artifact@v4
with:
name: state-${{ matrix.ghc }}-${{ matrix.os }}
- name: Unarchive working directory
run: tar -xf state.tar && rm state.tar
- uses: actions/cache@v4
if: matrix.os != 'macos-latest'
name: Cache cabal store
with:
path: |
${{ steps.install-haskell.outputs.cabal-store }}
# cache is invalidated upon a change to cabal.project (and/or cabal.project.local), a bump to
# CABAL_CACHE_VERSION or after a week of inactivity
key: cache-${{ runner.os }}-${{ matrix.ghc }}-${{ env.CABAL_CACHE_VERSION }}-${{ hashFiles('cabal.project*') }}
# Restoring attempts are from current branch then master
restore-keys: |
cache-${{ runner.os }}-${{ matrix.ghc }}-${{ env.CABAL_CACHE_VERSION }}-${{ hashFiles('cabal.project*') }}
- name: Cabal update
run: cabal update
- name: Run tests
run: |
export CARDANO_MAINNET_MIRROR="$(pwd)/epochs"
cabal test ${{ matrix.package }}
complete:
name: Tests completed
runs-on: ubuntu-latest
needs: test
if: always()
steps:
- run: |
case ${{ needs.test.result }} in
failure)
echo 'Some tests failed'
false;;
success)
echo 'All tests completed successfully';;
*)
echo 'Tests were ${{ needs.test.result }}';;
esac
fourmolu:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install fourmolu
run: |
FOURMOLU_VERSION="0.14.0.0"
mkdir -p "$HOME/.local/bin"
curl -sL "https://github.com/fourmolu/fourmolu/releases/download/v${FOURMOLU_VERSION}/fourmolu-${FOURMOLU_VERSION}-linux-x86_64" -o "$HOME/.local/bin/fourmolu"
chmod a+x "$HOME/.local/bin/fourmolu"
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Run fourmolu
run: ./scripts/fourmolize.sh
cabal-format:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Format all cabal files
run: ./scripts/cabal-format.sh
gen-hie:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
fail-fast: false
steps:
- name: Cache implicit-hie executable (gen-hie)
id: cache-gen-hie
uses: actions/cache@v4
with:
path: |
~/.cabal/bin/gen-hie
key: ${{ runner.os }}-cache-gen-hie
- name: Install gen-hie if not cached
if: steps.cache-gen-hie.outputs.cache-hit != 'true'
run: cabal update && cabal install implicit-hie --install-method=copy --overwrite-policy=always
- name: Add cabal-bin to PATH
run: echo "$HOME/.cabal/bin" >> $GITHUB_PATH
- uses: actions/checkout@v4
- name: Regenerate hie.yaml and confirm that it is in sync
run: ./scripts/gen-hie.sh
branch-history:
name: Check branch history
runs-on: ubuntu-latest
if: ${{ github.base_ref != '' && github.head_ref != '' }}
steps:
- uses: actions/checkout@v4
- name: Ensure the branch doesn't contain any merges
run: |
git fetch origin ${{ github.base_ref }} ${{ github.head_ref }}
if git log --merges --oneline --decorate origin/${{ github.base_ref }}..origin/${{ github.head_ref }} | grep .; then
echo 'Branch must not contain merges'
false
fi
notify-nightly-failure:
name: Send a slack notification on \#ledger-internal if the nightly build failed
runs-on: ubuntu-latest
needs:
- test
if: always() && github.event_name == 'schedule' && needs.test.result == 'failure'
steps:
- name: Send slack notification
id: slack
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Nightly Github Actions build failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK