Skip to content

Commit

Permalink
Various minor changes
Browse files Browse the repository at this point in the history
- Re-enabling mate on failure
- Use windows default shell
- split up win setup
- harmonize ghc install
- tmate on failure only
- PKG_CONFIG_PATH mutilation on unixy things only with export
- fix cache store path.
- missing env var
  • Loading branch information
angerman committed Nov 22, 2022
1 parent 55ccfb3 commit 4a8ef27
Showing 1 changed file with 69 additions and 62 deletions.
131 changes: 69 additions & 62 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ jobs:
build:
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash

strategy:
fail-fast: false
matrix:
Expand All @@ -40,40 +36,38 @@ jobs:

steps:
- name: "View pkg-config"
run: |
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
- name: "LINUX,MAC: Setup haskell"
if: runner.os != 'Windows'
uses: haskell/actions/setup@v1
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 3.8.1.0
run: echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"

- name: "WIN: Install ghcup"
shell: pwsh
- name: "WIN: Install System Dependencies via pacman (msys2)"
if: runner.os == 'Windows'
run: |
# ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
# pacman, to install the necessary dependencies, ...
ghcup run -- pacman --noconfirm -S `
mingw-w64-x86_64-pkg-config `
mingw-w64-x86_64-libsodium `
base-devel `
autoconf-wrapper `
autoconf `
automake `
libtool `
make `
openssl-devel
# ... and also the ghc and cabal combination we want.
# ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
# pacman, to install the necessary dependencies, ...
ghcup run -- pacman --noconfirm -S `
mingw-w64-x86_64-pkg-config `
mingw-w64-x86_64-libsodium `
base-devel `
autoconf-wrapper `
autoconf `
automake `
libtool `
make
# this seems to break something. It _must_ come after the pacman setup
# above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
# as such we'd need pacman.exe instead.
- name: Setup Haskell
run: |
# Use GHCUP to manage ghc/cabal
ghcup install ghc --set ${{ matrix.ghc }}
ghcup install cabal --set 3.6.2.0
ghc --version
cabal --version
- name: "WIN: fixup cabal config"
if: runner.os == 'Windows'
run: |
# make sure cabal knows about msys64, and mingw64 tools. Not clear why C:/cabal/config is empty
# and C:/cabal doesn't even exist. The ghcup bootstrap file should have create it in the image:
# See https://github.com/haskell/ghcup-hs/blob/787edc17af4907dbc51c85e25c490edd8d68b80b/scripts/bootstrap/bootstrap-haskell#L591
Expand All @@ -97,29 +91,30 @@ jobs:
run: |
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
- name: "OUTPUT Record cabal-store"
- name: "OUTPUT Record cabal-store (Linux)"
id: lin-setup-haskell
if: runner.os != 'Windows'
run: echo "cabal-store=/home/runner/.cabal/store" >> $GITHUB_OUTPUT

- name: "OUTPUT Record cabal-store (Windows)"
id: win-setup-haskell
shell: bash
if: runner.os == 'Windows'
run: echo "cabal-store=$(dirname $(cabal --help | tail -1 | tr -d ' '))\\store" >> $GITHUB_OUTPUT
shell: bash
run: echo "cabal-store=C:\\cabal\\store" >> $GITHUB_OUTPUT

- name: Set cache version
run: echo "CACHE_VERSION=grFfw8r" >> $GITHUB_ENV

- uses: actions/checkout@v2

- name: Add build script path
shell: bash
run: |
touch ~/.bashrc
if [ "${{ runner.os }}" == "Windows" ]; then
# MSYS2 doesn't inherit $GITHUB_PATH, so this workaround is needed
cat <(echo "export PATH=$PATH:$(pwd)/.github/bin") ~/.bashrc > ~/.bashrc.new
mv ~/.bashrc.new ~/.bashrc
else
# MacOS and Linux use $GITUB_PATH
echo "$(pwd)/.github/bin" >> $GITHUB_PATH
fi
- name: "[PowerShell] Add build script path"
if: runner.os == 'Windows'
shell: pwsh
run: Add-Content $env:GITHUB_PATH "$(pwd)/.github/bin"

- name: "[Bash] Add build script path"
if: runner.os != 'Windows'
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH

- name: "LINUX: Install build environment (apt-get)"
if: runner.os == 'Linux'
Expand Down Expand Up @@ -169,6 +164,7 @@ jobs:
run: cabal update

- name: Configure build
shell: bash
run: |
if [ "${{github.event.inputs.tests}}" == "all" ]; then
echo "Reconfigure cabal projects to run tests for all dependencies"
Expand All @@ -180,14 +176,18 @@ jobs:
echo "# cabal.project.local"
cat cabal.project.local
- name: Record dependencies
id: record-deps
- name: Update pkg-config paths
if: runner.os != 'Windows'
run: |
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
- name: Record dependencies
id: record-deps
run: |
cabal build all --dry-run
cat ${{ env.PLAN_JSON }} | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
- name: "OUTPUT Record weeknum"
shell: bash
Expand All @@ -196,7 +196,7 @@ jobs:
- name: Cache Cabal store
uses: actions/cache@v2
with:
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.setup-haskell.outputs.cabal-store }}
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.lin-setup-haskell.outputs.cabal-store }}
key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}-${{ hashFiles('date.txt') }}
restore-keys: |
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
Expand All @@ -213,27 +213,33 @@ jobs:

- name: Build
run: |
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
env | grep PKG_CONFIG_PATH
cabal build cardano-node cardano-cli cardano-node-chairman cardano-submit-api
- name: Run tests (all)
if: github.event.inputs.tests == "all"
env:
TMPDIR: ${{ runner.temp }}
TMP: ${{ runner.temp }}
KEEP_WORKSPACE: 1
run: cabal test all

- name: Run tests
run: |
if [ "${{github.event.inputs.tests}}" == "all" ]; then
TMPDIR="${{ runner.temp }}" TMP="${{ runner.temp }}" KEEP_WORKSPACE=1 cabal test all;
else
TMPDIR="${{ runner.temp }}" TMP="${{ runner.temp }}" KEEP_WORKSPACE=1 cabal test \
if: github.event.inputs.tests != "all"
env:
TMPDIR: ${{ runner.temp }}
TMP: ${{ runner.temp }}
KEEP_WORKSPACE: 1
run: cabal test \
cardano-testnet \
cardano-api \
cardano-node \
cardano-node-chairman \
cardano-cli \
cardano-submit-api
fi

- name: "Tar artifacts"
shell: bash
run: |
mkdir -p artifacts
Expand All @@ -258,6 +264,7 @@ jobs:

- name: Delete socket files in chairman tests in preparation for uploading artifacts
if: ${{ always() }}
shell: bash
run: |
if [ -d "${{ runner.temp }}/chairman" ]; then
find "${{ runner.temp }}/chairman" -type s -exec rm -f {} \;
Expand All @@ -275,9 +282,9 @@ jobs:
# `/msys2/mingw64` paths are not in PATH by default for the workflow, but tmate
# will put them in.
#
# - name: Setup tmate session
# if: ${{ matrix.os == 'windows-latest' }}
# uses: mxschmitt/action-tmate@v3
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3

release:
needs: [build]
Expand Down

0 comments on commit 4a8ef27

Please sign in to comment.