Skip to content

Commit

Permalink
Update Github Actions and fix Doctest (#352)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
xsebek authored Jun 4, 2022
1 parent 8578a56 commit 7ad65ad
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 36 deletions.
79 changes: 49 additions & 30 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
## 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
#
# haskell-ci regenerate
#
# 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:
Expand All @@ -36,35 +43,37 @@ 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:
- name: apt
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 }}
Expand All @@ -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"
Expand Down Expand Up @@ -114,6 +123,10 @@ jobs:
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: |
Expand All @@ -132,6 +145,15 @@ jobs:
rm -f cabal-plan.xz
chmod a+x $HOME/.cabal/bin/cabal-plan
cabal-plan --version
- name: install cabal-docspec
run: |
mkdir -p $HOME/.cabal/bin
curl -sL https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20211114/cabal-docspec-0.0.0.20211114.xz > 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:
Expand Down Expand Up @@ -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 <<EOF
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(swarm)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
Expand All @@ -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
8 changes: 4 additions & 4 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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'
Expand Down
26 changes: 26 additions & 0 deletions cabal.haskell-ci
Original file line number Diff line number Diff line change
@@ -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
9 changes: 8 additions & 1 deletion src/Swarm/Language/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ module Swarm.Language.Parse (
parsePolytype,
parseType,
parseTerm,
binOps,
unOps,

-- * Utility functions
runParser,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion swarm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ maintainer: [email protected]
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/
Expand Down

0 comments on commit 7ad65ad

Please sign in to comment.