From 28c698962aaf601cfff5f407ff87fa2f28bce419 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Wed, 6 Dec 2023 20:09:15 +0200 Subject: [PATCH] Separate workflow for checks 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. --- .github/workflows/haskell-ci.yml | 64 ++----------- .github/workflows/lints.yml | 156 +++++++++++++++++++++++++++++++ cabal.haskell-ci | 4 +- 3 files changed, 167 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/lints.yml diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 90b427955..231d4b133 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -8,9 +8,9 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci # -# version: 0.17.20230811 +# version: 0.17.20231203 # -# REGENDATA ("0.17.20230811",["--config=cabal.haskell-ci","cabal.project"]) +# REGENDATA ("0.17.20231203",["--config=cabal.haskell-ci","cabal.project"]) # name: Haskell-CI on: @@ -28,11 +28,11 @@ jobs: strategy: matrix: include: - - compiler: ghc-9.8.0.20230809 + - compiler: ghc-9.8.1 compilerKind: ghc - compilerVersion: 9.8.0.20230809 + compilerVersion: 9.8.1 setup-method: ghcup - allow-failure: true + allow-failure: false - compiler: ghc-9.6.2 compilerKind: ghc compilerVersion: 9.6.2 @@ -90,11 +90,10 @@ jobs: 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.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup" + 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" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml; "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) - "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (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: @@ -114,12 +113,12 @@ jobs: echo "HC=$HC" >> "$GITHUB_ENV" echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$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" - if [ $((HCNUMVER >= 90800)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi + echo "HEADHACKAGE=false" >> "$GITHUB_ENV" echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" echo "GHCJSARITH=0" >> "$GITHUB_ENV" env: @@ -148,18 +147,6 @@ jobs: repository hackage.haskell.org url: http://hackage.haskell.org/ EOF - if $HEADHACKAGE; then - cat >> $CABAL_CONFIG <> $CABAL_CONFIG <= 90600 && HCNUMVER < 90800)) -ne 0 ] ; then 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" ; fi - if [ $((HCNUMVER >= 90600 && HCNUMVER < 90800)) -ne 0 ] ; then if [ ! -e $HOME/.haskell-ci-tools/hlint-$HLINTVER/hlint ]; then 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; fi ; fi - if [ $((HCNUMVER >= 90600 && HCNUMVER < 90800)) -ne 0 ] ; then mkdir -p $CABAL_DIR/bin && ln -sf "$HOME/.haskell-ci-tools/hlint-$HLINTVER/hlint" $CABAL_DIR/bin/hlint ; fi - if [ $((HCNUMVER >= 90600 && HCNUMVER < 90800)) -ne 0 ] ; then hlint --version ; fi - - name: save cache (tools) - uses: actions/cache/save@v3 - if: always() - with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-d1961fb1 - path: ~/.haskell-ci-tools - name: checkout uses: actions/checkout@v3 with: @@ -249,9 +219,6 @@ jobs: if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi cat >> cabal.project <> cabal.project - fi $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 @@ -279,19 +246,6 @@ jobs: run: | $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all cabal-docspec $ARG_COMPILER - - name: hlint - run: | - if [ $((HCNUMVER >= 90600 && HCNUMVER < 90800)) -ne 0 ] ; then (cd ${PKGDIR_lens} && hlint -XHaskell2010 src) ; fi - if [ $((HCNUMVER >= 90600 && HCNUMVER < 90800)) -ne 0 ] ; then (cd ${PKGDIR_lens_examples} && hlint -XHaskell2010 .) ; fi - if [ $((HCNUMVER >= 90600 && HCNUMVER < 90800)) -ne 0 ] ; then (cd ${PKGDIR_lens_properties} && hlint -XHaskell2010 src) ; fi - - 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 - name: haddock run: | if [ $((HCNUMVER >= 80800)) -ne 0 ] ; then $CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all ; fi diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml new file mode 100644 index 000000000..027e557b9 --- /dev/null +++ b/.github/workflows/lints.yml @@ -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 <> $CABAL_CONFIG <> "$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 <> 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 diff --git a/cabal.haskell-ci b/cabal.haskell-ci index 70caeba30..a536d829b 100644 --- a/cabal.haskell-ci +++ b/cabal.haskell-ci @@ -1,8 +1,7 @@ distribution: jammy no-tests-no-benchmarks: False unconstrained: False -hlint: True -hlint-version: >=3.6 && <3.7 +hlint: False apt: freeglut3-dev -- irc-channels: irc.freenode.org#haskell-lens irc-if-in-origin-repo: True @@ -13,3 +12,4 @@ docspec: True -- versions of Haddock do not gracefully handle these markers, we simply do not -- build the Haddocks on CI unless we are using GHC 8.8 or later. haddock: >=8.8 +cabal-check: False