From cc9b8840b82e4f12bd10516b2f312184046356bf Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Thu, 22 Jun 2023 11:56:22 +0530 Subject: [PATCH] Replace travis CI with github actions (#51) * Use github actions for basic testing * Remove travis * Use CPP * Run tests without fast * Add more stackage resolvers --- .github/workflows/tests.yml | 75 +++++++++++++++++++++ .travis.yml | 131 ------------------------------------ src/Weigh.hs | 2 + stack.yaml | 3 +- stack.yaml.lock | 8 +-- 5 files changed, 82 insertions(+), 137 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..57493b1 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,75 @@ +name: Tests + +on: + pull_request: + push: + branches: + - master + +jobs: + build: + name: CI + runs-on: ${{ matrix.os }} + env: + STACK_ROOT: ${{ github.workspace }}/.stack + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + stack-yaml: stack.yaml + resolver: lts-21 + - os: macos-latest + stack-yaml: stack.yaml + resolver: lts-21 + - os: windows-latest + stack-yaml: stack.yaml + resolver: lts-21 + - os: ubuntu-latest + stack-yaml: stack.yaml + resolver: lts-20 + - os: macos-latest + stack-yaml: stack.yaml + resolver: lts-20 + - os: windows-latest + stack-yaml: stack.yaml + resolver: lts-20 + - os: ubuntu-latest + stack-yaml: stack.yaml + resolver: lts-19 + - os: macos-latest + stack-yaml: stack.yaml + resolver: lts-19 + - os: windows-latest + stack-yaml: stack.yaml + resolver: lts-19 + + steps: + - name: Clone project + uses: actions/checkout@v2 + with: + submodules: 'true' + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: | + ~/.stack + ${{ github.workspace }}/.stack + key: ${{ runner.os }}-${{ matrix.resolver }}-haskell-${{ hashFiles('stack.yaml') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.resolver }}-haskell- + + - name: Build and run tests + shell: bash + run: | + set -ex + if [ "$RUNNER_OS" == "Linux" ] || [ "$RUNNER_OS" == "macOS" ]; then + curl -sSL https://get.haskellstack.org/ | sh -s - -f + fi + stack test --no-terminal --stack-yaml=${{ matrix.stack-yaml }} --resolver=${{ matrix.resolver }} + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + generate_release_notes: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fbe47d6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,131 +0,0 @@ -# Copy these contents into the root directory of your Github project in a file -# named .travis.yml - -# Use new container infrastructure to enable caching -sudo: false - -# Choose a lightweight base image; we provide our own build tools. -language: c - -# Caching so the next build will be fast too. -cache: - directories: - - $HOME/.ghc - - $HOME/.cabal - - $HOME/.stack - -# The different configurations we want to test. We have BUILD=cabal which uses -# cabal-install, and BUILD=stack which uses Stack. More documentation on each -# of those below. -# -# We set the compiler values here to tell Travis to use a different -# cache file per set of arguments. -# -# If you need to have different apt packages for each combination in the -# matrix, you can use a line such as: -# addons: {apt: {packages: [libfcgi-dev,libgmp-dev]}} -matrix: - include: - - # - env: BUILD=stack ARGS="--resolver lts-3" - # compiler: ": #stack 7.10.2" - # addons: {apt: {packages: [ghc-7.10.2], sources: [hvr-ghc]}} - - # - env: BUILD=stack ARGS="--resolver lts-5" - # compiler: ": #stack 7.10.3" - # addons: {apt: {packages: [ghc-7.10.3], sources: [hvr-ghc]}} - - - env: BUILD=stack ARGS="--resolver lts-9.21" - compiler: ": #stack 8.0.2" - addons: {apt: {packages: [ghc-8.0.2], sources: [hvr-ghc]}} - - - env: BUILD=stack ARGS="--resolver lts-11.22" - compiler: ": #stack 8.2.2" - addons: {apt: {packages: [ghc-8.2.2], sources: [hvr-ghc]}} - - - env: BUILD=stack ARGS="--resolver lts-12.26" - compiler: ": #stack 8.4.4" - addons: {apt: {packages: [ghc-8.4.4], sources: [hvr-ghc]}} - - - env: BUILD=stack ARGS="--resolver lts-13.26" - compiler: ": #stack 8.6.5" - addons: {apt: {packages: [ghc-8.6.5], sources: [hvr-ghc]}} - - - # Build on OS X in addition to Linux - - env: BUILD=stack ARGS="" - compiler: ": #stack default osx" - os: osx - -before_install: -# Using compiler above sets CC to an invalid value, so unset it -- unset CC - -# We want to always allow newer versions of packages when building on GHC HEAD -- CABALARGS="" -- if [ "x$GHCVER" = "xhead" ]; then CABALARGS=--allow-newer; fi - -# Download and unpack the stack executable -- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:/opt/alex/$ALEXVER/bin:/opt/happy/$HAPPYVER/bin:$HOME/.cabal/bin:$PATH -- mkdir -p ~/.local/bin -- | - if [ `uname` = "Darwin" ] - then - travis_retry curl --insecure -L https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin - else - travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' - fi - - # Use the more reliable S3 mirror of Hackage - mkdir -p $HOME/.cabal - echo 'remote-repo: hackage.haskell.org:http://hackage.fpcomplete.com/' > $HOME/.cabal/config - echo 'remote-repo-cache: $HOME/.cabal/packages' >> $HOME/.cabal/config - - if [ "$CABALVER" != "1.16" ] - then - echo 'jobs: $ncpus' >> $HOME/.cabal/config - fi - -# Get the list of packages from the stack.yaml file -- PACKAGES=$(stack --install-ghc query locals | grep '^ *path' | sed 's@^ *path:@@') - -install: -- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" -- if [ -f configure.ac ]; then autoreconf -i; fi -- | - set -ex - case "$BUILD" in - stack) - stack --no-terminal --install-ghc $ARGS test --bench --only-dependencies - ;; - cabal) - cabal --version - travis_retry cabal update - cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS $PACKAGES - ;; - esac - set +ex - -script: -- | - set -ex - case "$BUILD" in - stack) - stack --no-terminal $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps - ;; - cabal) - cabal install --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS $PACKAGES - - ORIGDIR=$(pwd) - for dir in $PACKAGES - do - cd $dir - cabal check || [ "$CABALVER" == "1.16" ] - cabal sdist - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz && \ - (cd dist && cabal install --force-reinstalls "$SRC_TGZ") - cd $ORIGDIR - done - ;; - esac - set +ex diff --git a/src/Weigh.hs b/src/Weigh.hs index 351b3ee..d2ef13b 100644 --- a/src/Weigh.hs +++ b/src/Weigh.hs @@ -75,7 +75,9 @@ module Weigh import Control.Applicative import Control.Arrow import Control.DeepSeq +#if MIN_VERSION_base(4,18,0) import Control.Monad (unless) +#endif import Control.Monad.State import Criterion.Measurement import qualified Data.Foldable as Foldable diff --git a/stack.yaml b/stack.yaml index a41a543..f9994e6 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,2 +1 @@ -resolver: lts-11.3 -#resolver: nightly-2017-11-23 +resolver: lts-19.33 diff --git a/stack.yaml.lock b/stack.yaml.lock index 7c3a65e..d79c369 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -6,7 +6,7 @@ packages: [] snapshots: - completed: - size: 506659 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/11/3.yaml - sha256: 4a02ab9386e5968c58529fdf79707ccd0ae1352c213e28a78ee9e0d836be1824 - original: lts-11.3 + sha256: 6d1532d40621957a25bad5195bfca7938e8a06d923c91bc52aa0f3c41181f2d4 + size: 619204 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/33.yaml + original: lts-19.33