Fix CI #3057
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: cabal-linux | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
GHC: '9.6.4' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup packages | |
run: | | |
sudo apt update -qq | |
sudo apt -y --allow-downgrades --allow-remove-essential --allow-change-held-packages install locales software-properties-common apt-transport-https | |
sudo bash -c "echo deb [trusted=yes] https://apt-hasktorch.com/apt ./ > /etc/apt/sources.list.d/libtorch.list" | |
sudo rm -f /etc/apt/sources.list.d/sbt.list | |
sudo apt update -qq | |
sudo apt -y purge ghc* cabal-install* php* || true | |
sudo apt -y --allow-downgrades --allow-remove-essential --allow-change-held-packages install build-essential zlib1g-dev liblapack-dev libblas-dev devscripts debhelper python3-pip cmake curl wget unzip git libtinfo-dev python3 python3-yaml | |
sudo apt -y install libtorch=2.0.0+cpu-1 libtokenizers=0.1-1 | |
- name: Setup Haskell | |
run: | | |
echo "$HOME/.ghcup/bin" >> "${GITHUB_PATH}" | |
ghcup install ghc --set ${{ env.GHC }} | |
mkdir -p ~/.cabal | |
# The presence of ~/.cabal should switch cabal 3.10 to not use the XDG layout. | |
## GHCup is preinstalled on the GHA runners. This would be the magic incantation to install it: | |
# curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh | |
## Cabal is preinstalled on the GHA runners | |
# ghcup install cabal | |
- name: Information about the Haskell setup | |
run: | | |
echo "PATH = ${PATH}" | |
echo "GHC is $(which ghc)" | |
echo "Cabal is $(which cabal)" | |
echo "GHC_VERSION=$(ghc --numeric-version)" >> "${GITHUB_ENV}" | |
echo "CABAL_VERSION=$(cabal --numeric-version)" >> "${GITHUB_ENV}" | |
- name: Generate install-plan | |
run: | | |
# source setenv | |
./setup-cabal.sh | |
cabal v2-update | |
cabal v2-build --jobs=2 all --dry-run | |
## The latter leaves a build plan in dist-newstyle/cache/plan.json | |
- name: Restore cached dependencies | |
uses: actions/cache/restore@v3 | |
id: cache | |
with: | |
# We don't cache dist-newstyle because it is fat and in practice hardly reused. | |
path: ~/.cabal/store | |
# Append the build plan to the cache key so that a new cache gets saved when dependencies update. | |
# `plan.json` is a good cache key because it does not contain time stamps (unlike `cabal.project.freeze`). | |
key: ${{ runner.os }}-cabal-${{ env.CABAL_VERSION }}-ghc-${{ env.GHC_VERSION }}-plan-${{ hashFiles('**/plan.json') }} | |
restore-keys: ${{ runner.os }}-cabal-${{ env.CABAL_VERSION }}-ghc-${{ env.GHC_VERSION }}- | |
- name: Install dependencies | |
run: | | |
# source setenv | |
cabal v2-build --jobs=2 all --only-dependencies | |
- name: Cache dependencies | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
uses: actions/cache/save@v3 | |
with: | |
path: ~/.cabal/store | |
key: ${{ steps.cache.outputs.cache-primary-key }} | |
- name: Build | |
run: | | |
# source setenv | |
cabal v2-build --jobs=2 all | |
- name: Tests | |
run: | | |
# source setenv | |
cabal v2-test --jobs=2 all | |
- name: Runs | |
run: | | |
# source setenv | |
cabal v2-exec codegen-exe | |
cabal v2-exec xor-mlp | |
- name: Benchmark | |
run: | | |
# source setenv | |
cabal v2-bench hasktorch:runtime --benchmark-options='--output benchmark-runtime.html' | |
cabal v2-bench hasktorch:alloc --benchmark-options='--output benchmark-alloc.html' | |
- name: Archive benchmark results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: benchmark-report | |
path: hasktorch/benchmark*.html |