From 7ad65ad00aa0f5946bfe34656e958fdb62df65c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=A0ebek?= <44544735+xsebek@users.noreply.github.com> Date: Sat, 4 Jun 2022 22:04:26 +0200 Subject: [PATCH] Update Github Actions and fix Doctest (#352) * Fix doctests * Regenerate haskell-ci with config - use latest haskell-ci - configure haskell-ci to use doctest * Update tested with compiler - update cabal tested-with field - update .mergify.yaml to new compiler - restore note about mergify in haskell-ci --- .github/workflows/haskell-ci.yml | 79 ++++++++++++++++++++------------ .mergify.yml | 8 ++-- cabal.haskell-ci | 26 +++++++++++ src/Swarm/Language/Parse.hs | 9 +++- swarm.cabal | 2 +- 5 files changed, 88 insertions(+), 36 deletions(-) create mode 100644 cabal.haskell-ci diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 01cc08e2b..b41accc75 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -1,8 +1,15 @@ -## Hand edited to add paths filter ;) +##################################################################### +## NOTE: # +## When changing versions, do not forget to update .mergify.yaml # +## # +## WARNING: # +## Hand edited to add filter in on.push and on.pull_request. # +## If possible do not manually edit beside the above. # +##################################################################### # # This GitHub workflow config has been generated by a script via # -# haskell-ci 'github' 'swarm.cabal' +# haskell-ci 'github' '--config=cabal.haskell-ci' 'swarm.cabal' # # To regenerate the script (for example after adjusting tested-with) run # @@ -10,9 +17,9 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci # -# version: 0.13.20210901 +# version: 0.15.20220531 # -# REGENDATA ("0.13.20210901",["github","swarm.cabal"]) +# REGENDATA ("0.15.20220531",["github","--config=cabal.haskell-ci","swarm.cabal"]) # name: Haskell-CI on: @@ -36,25 +43,25 @@ on: - 'cabal.project*' jobs: linux: - # when changing the name or adding ghc version, please don't forget to update - # the .mergify.yml rules at the root of the project. name: Haskell-CI - Linux - ${{ matrix.compiler }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 + timeout-minutes: + 60 container: image: buildpack-deps:bionic continue-on-error: ${{ matrix.allow-failure }} strategy: matrix: include: - - compiler: ghc-9.0.1 + - compiler: ghc-9.0.2 compilerKind: ghc - compilerVersion: 9.0.1 - setup-method: hvr-ppa + compilerVersion: 9.0.2 + setup-method: ghcup allow-failure: false - - compiler: ghc-8.10.4 + - compiler: ghc-8.10.7 compilerKind: ghc - compilerVersion: 8.10.4 - setup-method: hvr-ppa + compilerVersion: 8.10.7 + setup-method: ghcup allow-failure: false fail-fast: false steps: @@ -62,9 +69,11 @@ jobs: run: | apt-get update apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" cabal-install-3.4 + mkdir -p "$HOME/.ghcup/bin" + curl -sL https://downloads.haskell.org/ghcup/0.1.17.8/x86_64-linux-ghcup-0.1.17.8 > "$HOME/.ghcup/bin/ghcup" + chmod a+x "$HOME/.ghcup/bin/ghcup" + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" + "$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 env: HCKIND: ${{ matrix.compilerKind }} HCNAME: ${{ matrix.compiler }} @@ -76,11 +85,11 @@ jobs: echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" HCDIR=/opt/$HCKIND/$HCVER - HC=$HCDIR/bin/$HCKIND + HC=$HOME/.ghcup/bin/$HCKIND-$HCVER echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - echo "CABAL=/opt/cabal/3.4/bin/cabal -vnormal+nowrap" >> "$GITHUB_ENV" + echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV" + echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV" + echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.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" @@ -114,6 +123,10 @@ jobs: repository hackage.haskell.org url: http://hackage.haskell.org/ EOF + cat >> $CABAL_CONFIG < cabal-docspec.xz + echo 'e224700d9e8c9ec7ec6bc3f542ba433cd9925a5d356676c62a9bd1f2c8be8f8a cabal-docspec.xz' | sha256sum -c - + xz -d < cabal-docspec.xz > $HOME/.cabal/bin/cabal-docspec + rm -f cabal-docspec.xz + chmod a+x $HOME/.cabal/bin/cabal-docspec + cabal-docspec --version - name: checkout uses: actions/checkout@v2 with: @@ -159,8 +181,8 @@ jobs: echo "packages: ${PKGDIR_swarm}" >> cabal.project echo "package swarm" >> cabal.project echo " ghc-options: -Werror=missing-methods" >> cabal.project - # ensure we use the ghc901 fix - cat "${GITHUB_WORKSPACE}/source/cabal.project" | grep -v "^packages" >> cabal.project + cat >> cabal.project <> cabal.project.local cat cabal.project cat cabal.project.local @@ -178,23 +200,20 @@ jobs: run: | $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all - - name: build w/o tests - run: | - $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all - name: build run: | $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always - name: tests run: | $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct + - name: docspec + run: | + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all + cabal-docspec $ARG_COMPILER - name: cabal check run: | cd ${PKGDIR_swarm} || false ${CABAL} -vnormal check - name: haddock run: | - $CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all - - name: unconstrained build - run: | - rm -f cabal.project.local - $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all + $CABAL v2-haddock --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all diff --git a/.mergify.yml b/.mergify.yml index 58f86e145..c0e7a3433 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -1,8 +1,8 @@ queue_rules: - name: default conditions: - - check-success=Haskell-CI - Linux - ghc-9.0.1 - - check-success=Haskell-CI - Linux - ghc-8.10.4 + - check-success=Haskell-CI - Linux - ghc-9.0.2 + - check-success=Haskell-CI - Linux - ghc-8.10.7 pull_request_rules: - actions: @@ -26,8 +26,8 @@ pull_request_rules: - -files~=^[^/]*\.yaml$ - -files~=^data/.*\.yaml$ - and: - - check-success=Haskell-CI - Linux - ghc-9.0.1 - - check-success=Haskell-CI - Linux - ghc-8.10.4 + - check-success=Haskell-CI - Linux - ghc-9.0.2 + - check-success=Haskell-CI - Linux - ghc-8.10.7 - label=merge me - ! '#approved-reviews-by>=1' - ! '#changes-requested-reviews-by=0' diff --git a/cabal.haskell-ci b/cabal.haskell-ci new file mode 100644 index 000000000..7b05dfd9f --- /dev/null +++ b/cabal.haskell-ci @@ -0,0 +1,26 @@ +-- See cabal.haskell-ci in the tool repository for all field explanations +-- https://github.com/haskell-CI/haskell-ci/blob/master/cabal.haskell-ci + +-- --no-tests --no-benchmarks build is useful to verify that package +-- builds when less constrained +-- But Swarm constrains all library dependencies and tests almost not at all +no-tests-no-benchmarks: False +unconstrained: False + +-- Run cabal-docspec +docspec: True + +-- Build haddocks. Accepts booleans or version range. +haddock: True + +-- Build benchmarks. There are no way to run benchmarks. Accepts booleans or version range. +-- Swarm has benchmarks so at least build them :) +benchmarks: True + +-- TODO: enable HLint + +-- Run HLint +-- hlint: True +-- hlint-job: 9.0.2 +-- hlint-yaml: .hlint.yaml +-- hlint-download-binary: True \ No newline at end of file diff --git a/src/Swarm/Language/Parse.hs b/src/Swarm/Language/Parse.hs index 08db22f7d..701b572a0 100644 --- a/src/Swarm/Language/Parse.hs +++ b/src/Swarm/Language/Parse.hs @@ -24,6 +24,8 @@ module Swarm.Language.Parse ( parsePolytype, parseType, parseTerm, + binOps, + unOps, -- * Utility functions runParser, @@ -58,6 +60,11 @@ import Data.Set.Lens (setOf) import Swarm.Language.Syntax import Swarm.Language.Types +-- Imports for doctests (cabal-docspec needs this) + +-- $setup +-- >>> import qualified Data.Map.Strict as Map + -- | When parsing a term using a quasiquoter (i.e. something in the -- Swarm source code that will be parsed at compile time), we want -- to allow antiquoting, i.e. writing something like $x to refer to @@ -345,7 +352,7 @@ parseExpr = fixDefMissingSemis <$> makeExprParser parseTermAtom table -- | Precedences and parsers of binary operators. -- -- >>> Map.map length binOps --- fromList [(4,6),(6,2),(7,2),(8,1)] +-- fromList [(0,1),(2,1),(3,1),(4,6),(6,3),(7,2),(8,1)] binOps :: Map.Map Int [Operator Parser Syntax] binOps = Map.unionsWith (++) $ mapMaybe binOpToTuple allConst where diff --git a/swarm.cabal b/swarm.cabal index a604b370a..60f5dc87a 100644 --- a/swarm.cabal +++ b/swarm.cabal @@ -18,7 +18,7 @@ maintainer: byorgey@gmail.com bug-reports: https://github.com/swarm-game/swarm/issues copyright: Brent Yorgey 2021 category: Game -tested-with: GHC ==8.10.4 || ==9.0.1 +tested-with: GHC ==8.10.7 || ==9.0.2 extra-source-files: CHANGELOG.md example/*.sw data-dir: data/