-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I'm experimenting with an idea of generating a separate workflow for checks which are enough to do once. E.g. hlint is run once. `cabal check` does the same for every GHC. Having such checks in a separate workflow, would: - allow per-GHC builds to pass even if there is e.g HLint issue - allow more parallism - simplify structure The goal is that `haskell-ci` would be able to generate `lints.yml` file too, as it looks there are potentially a lot of setup to do.
- Loading branch information
Showing
3 changed files
with
167 additions
and
57 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
name: Haskell-CI Checks | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
linux: | ||
name: Haskell-CI - Checks | ||
runs-on: ubuntu-20.04 | ||
timeout-minutes: | ||
60 | ||
container: | ||
image: buildpack-deps:jammy | ||
strategy: | ||
matrix: | ||
include: | ||
- compiler: ghc-9.6.2 | ||
compilerKind: ghc | ||
compilerVersion: 9.6.2 | ||
setup-method: ghcup | ||
|
||
steps: | ||
- name: apt | ||
run: | | ||
apt-get update | ||
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev | ||
mkdir -p "$HOME/.ghcup/bin" | ||
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup" | ||
chmod a+x "$HOME/.ghcup/bin/ghcup" | ||
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) | ||
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false) | ||
apt-get update | ||
apt-get install -y freeglut3-dev | ||
env: | ||
HCKIND: ${{ matrix.compilerKind }} | ||
HCNAME: ${{ matrix.compiler }} | ||
HCVER: ${{ matrix.compilerVersion }} | ||
- name: Set PATH and environment variables | ||
run: | | ||
echo "$HOME/.cabal/bin" >> $GITHUB_PATH | ||
echo "LANG=C.UTF-8" >> "$GITHUB_ENV" | ||
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" | ||
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" | ||
HCDIR=/opt/$HCKIND/$HCVER | ||
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") | ||
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') | ||
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') | ||
echo "HC=$HC" >> "$GITHUB_ENV" | ||
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" | ||
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" | ||
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV" | ||
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') | ||
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" | ||
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" | ||
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" | ||
echo "HEADHACKAGE=false" >> "$GITHUB_ENV" | ||
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" | ||
echo "GHCJSARITH=0" >> "$GITHUB_ENV" | ||
env: | ||
HCKIND: ${{ matrix.compilerKind }} | ||
HCNAME: ${{ matrix.compiler }} | ||
HCVER: ${{ matrix.compilerVersion }} | ||
- name: env | ||
run: | | ||
env | ||
- name: write cabal config | ||
run: | | ||
mkdir -p $CABAL_DIR | ||
cat >> $CABAL_CONFIG <<EOF | ||
remote-build-reporting: anonymous | ||
write-ghc-environment-files: never | ||
remote-repo-cache: $CABAL_DIR/packages | ||
logs-dir: $CABAL_DIR/logs | ||
world-file: $CABAL_DIR/world | ||
extra-prog-path: $CABAL_DIR/bin | ||
symlink-bindir: $CABAL_DIR/bin | ||
installdir: $CABAL_DIR/bin | ||
build-summary: $CABAL_DIR/logs/build.log | ||
store-dir: $CABAL_DIR/store | ||
install-dirs user | ||
prefix: $CABAL_DIR | ||
repository hackage.haskell.org | ||
url: http://hackage.haskell.org/ | ||
EOF | ||
cat >> $CABAL_CONFIG <<EOF | ||
program-default-options | ||
ghc-options: $GHCJOBS +RTS -M3G -RTS | ||
EOF | ||
cat $CABAL_CONFIG | ||
- name: versions | ||
run: | | ||
$HC --version || true | ||
$HC --print-project-git-commit-id || true | ||
$CABAL --version || true | ||
- name: update cabal index | ||
run: | | ||
$CABAL v2-update -v | ||
- name: install hlint | ||
run: | | ||
HLINTVER=$(cd /tmp && (${CABAL} v2-install -v $ARG_COMPILER --dry-run hlint --constraint='hlint >=3.6 && <3.7' | perl -ne 'if (/\bhlint-(\d+(\.\d+)*)\b/) { print "$1"; last; }')) | ||
echo "HLint version $HLINTVER" | ||
echo "Downloading HLint version $HLINTVER" | ||
mkdir -p $HOME/.haskell-ci-tools | ||
curl --write-out 'Status Code: %{http_code} Redirects: %{num_redirects} Total time: %{time_total} Total Dsize: %{size_download}\n' --silent --location --output $HOME/.haskell-ci-tools/hlint-$HLINTVER.tar.gz "https://github.com/ndmitchell/hlint/releases/download/v$HLINTVER/hlint-$HLINTVER-x86_64-linux.tar.gz"; tar -xzv -f $HOME/.haskell-ci-tools/hlint-$HLINTVER.tar.gz -C $HOME/.haskell-ci-tools | ||
mkdir -p $CABAL_DIR/bin | ||
ln -sf "$HOME/.haskell-ci-tools/hlint-$HLINTVER/hlint" $CABAL_DIR/bin/hlint | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
path: source | ||
- name: sdist | ||
run: | | ||
mkdir -p sdist | ||
$CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist | ||
- name: unpack | ||
run: | | ||
mkdir -p unpacked | ||
find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \; | ||
- name: generate cabal.project | ||
run: | | ||
PKGDIR_lens="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/lens-[0-9.]*')" | ||
echo "PKGDIR_lens=${PKGDIR_lens}" >> "$GITHUB_ENV" | ||
PKGDIR_lens_examples="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/lens-examples-[0-9.]*')" | ||
echo "PKGDIR_lens_examples=${PKGDIR_lens_examples}" >> "$GITHUB_ENV" | ||
PKGDIR_lens_properties="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/lens-properties-[0-9.]*')" | ||
echo "PKGDIR_lens_properties=${PKGDIR_lens_properties}" >> "$GITHUB_ENV" | ||
rm -f cabal.project cabal.project.local | ||
touch cabal.project | ||
touch cabal.project.local | ||
echo "packages: ${PKGDIR_lens}" >> cabal.project | ||
echo "packages: ${PKGDIR_lens_examples}" >> cabal.project | ||
echo "packages: ${PKGDIR_lens_properties}" >> cabal.project | ||
echo "package lens" >> cabal.project | ||
echo " ghc-options: -Werror=missing-methods" >> cabal.project | ||
echo "package lens-examples" >> cabal.project | ||
echo " ghc-options: -Werror=missing-methods" >> cabal.project | ||
echo "package lens-properties" >> cabal.project ; fi | ||
echo " ghc-options: -Werror=missing-methods" >> cabal.project | ||
cat >> cabal.project <<EOF | ||
EOF | ||
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(lens|lens-examples|lens-properties)$/; }' >> cabal.project.local | ||
cat cabal.project | ||
cat cabal.project.local | ||
- name: hlint | ||
run: | | ||
(cd ${PKGDIR_lens} && hlint -XHaskell2010 src) | ||
(cd ${PKGDIR_lens_examples} && hlint -XHaskell2010 .) | ||
(cd ${PKGDIR_lens_properties} && hlint -XHaskell2010 src) | ||
- name: cabal check | ||
run: | | ||
cd ${PKGDIR_lens} || false | ||
${CABAL} -vnormal check | ||
cd ${PKGDIR_lens_examples} || false | ||
${CABAL} -vnormal check | ||
cd ${PKGDIR_lens_properties} || false | ||
${CABAL} -vnormal check |
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