Skip to content

Commit

Permalink
Fix coverage and simplify stack CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Oct 28, 2023
1 parent fd8e101 commit 046e3f8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 47 deletions.
53 changes: 28 additions & 25 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:

defaults: { run: { shell: bash } }

# Cancel running actions when a new action on the same PR is started
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build-cabal:
name: CI-cabal
Expand Down Expand Up @@ -107,7 +112,10 @@ jobs:
ghc: 9.0.2
stack-yaml: stack.yaml
- resolver: lts-20
ghc: 9.2.7
ghc: 9.2.8
stack-yaml: stack.yaml
- resolver: lts-21
ghc: 9.4.7
stack-yaml: stack.yaml
- resolver: nightly
stack-yaml: stack.yaml
Expand Down Expand Up @@ -161,44 +169,39 @@ jobs:
if: matrix.os == 'windows-latest'
with:
path: |
C:\\Users\\RUNNER~1\\AppData\\Roaming\\stack
C:\\Users\\RUNNER~1\\AppData\\Local\\Programs\\stack
key: ${{ runner.os }}-${{ matrix.resolver }}-programs-${{ env.cache-version }}
restore-keys: |
${{ runner.os }}-${{ matrix.resolver }}-programs-${{ env.cache-version }}
- name: Install Stack and GHC
- name: Reset modtime
run: |
set -ex
curl -sSL https://raw.githubusercontent.com/lehins/utils/master/haskell/git-modtime/git-modtime.hs -o git-modtime.hs
runhaskell -- git-modtime.hs -f .stack-work/tree-contents.txt
- name: Build
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
run: |
set -ex
curl -sSL https://get.haskellstack.org/ | sh -s - -f
curl -sSL https://raw.githubusercontent.com/lehins/utils/c426e74aa129b7cb14e83305fd2639ccc41b03cd/haskell/git-modtime/git-modtime.hs -o git-modtime.hs
[ -n "${{ matrix.ghc }}" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ] && STACK_ARGS="$STACK_ARGS --system-ghc"
[ -n "${{ matrix.stack-yaml }}" ] && STACK_YAML=${{ matrix.stack-yaml }}
# git-modtime.hs updates modification time of files to the latest commit time that
# a file was modified in. This ensures that stack does not rebuild unchanged
# files. More info in this SO answer:
# https://stackoverflow.com/questions/60906336/stack-haskell-build-cache-of-source-files-with-github-actions/61178945#61178945
# Windows is confused about stack's default user directory
stack $STACK_ARGS runghc -- git-modtime.hs -f .stack-work/tree-contents.txt
if [ "${{ matrix.os }}.${{ matrix.resolver }}" == "ubuntu-latest.lts-19" ] && [ -n "${COVERALLS_TOKEN}" ]; then
# Inspection tests aren't compatible with coverage
stack $STACK_ARGS build random:spec random:legacy-test --coverage --test --no-run-tests --haddock --no-haddock-deps
else
stack $STACK_ARGS build --test --no-run-tests --bench --no-run-benchmarks --haddock --no-haddock-deps
fi
- name: Tests
- name: Test
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
run: |
set -ex
[ -n "${{ matrix.ghc }}" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ] && STACK_ARGS="$STACK_ARGS --system-ghc"
[ -n "${{ matrix.stack-yaml }}" ] && STACK_YAML=${{ matrix.stack-yaml }}
if [ "${{ matrix.os }}.${{ matrix.resolver }}" == "ubuntu-latest.lts-14" ]; then
if [ "${{ matrix.os }}.${{ matrix.resolver }}" == "ubuntu-latest.lts-19" ] && [ -n "${COVERALLS_TOKEN}" ]; then
stack $STACK_ARGS test random:spec random:legacy-test --coverage --haddock --no-haddock-deps
stack $STACK_ARGS hpc report --all
# Upload coverage report only when the token is available.
if [ -n "${COVERALLS_TOKEN}" ]; then
curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.6.1/shc-linux-x64-8.8.4.tar.bz2 | tar xj shc
./shc --repo-token="$COVERALLS_TOKEN" --partial-coverage --fetch-coverage combined custom
fi
elif [ "${{ matrix.resolver }}" == "lts-6" ]; then
# Inspection tests are not supported by pre ghc-8.0 compiler
stack $STACK_ARGS test random:spec random:legacy-test --bench --no-run-benchmarks --haddock --no-haddock-deps
curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.7.0/shc-Linux-X64.tar.bz2 | tar xj shc
./shc --repo-token="$COVERALLS_TOKEN" --partial-coverage --fetch-coverage combined custom
else
stack $STACK_ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps
fi
Expand Down
31 changes: 9 additions & 22 deletions random.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,14 @@ library
default-language: Haskell2010
ghc-options:
-Wall
if impl(ghc >= 8.0)
ghc-options:
-Wincomplete-record-updates -Wincomplete-uni-patterns
-Wincomplete-record-updates -Wincomplete-uni-patterns

build-depends:
base >=4.9 && <5,
bytestring >=0.10.4 && <0.13,
deepseq >=1.1 && <2,
mtl >=2.2 && <2.4,
splitmix >=0.1 && <0.2
if impl(ghc < 8.0)
build-depends:
transformers

test-suite legacy-test
type: exitcode-stdio-1.0
Expand All @@ -118,10 +113,9 @@ test-suite legacy-test
RangeTest

default-language: Haskell2010
ghc-options: -with-rtsopts=-M8M
if impl(ghc >= 8.0)
ghc-options:
-Wno-deprecations
ghc-options:
-with-rtsopts=-M8M
-Wno-deprecations
build-depends:
base,
containers >=0.5 && <0.7,
Expand Down Expand Up @@ -172,19 +166,15 @@ test-suite spec-inspection
type: exitcode-stdio-1.0
main-is: Spec.hs
hs-source-dirs: test-inspection
build-depends:

default-language: Haskell2010
ghc-options: -Wall
other-modules:
Spec.Inspection
build-depends:
base,
random,
tasty >=1.0 && <1.6
if impl(ghc >= 8.0)
build-depends:
tasty-inspection-testing
other-modules:
Spec.Inspection
tasty >=1.0 && <1.6,
tasty-inspection-testing

benchmark legacy-bench
type: exitcode-stdio-1.0
Expand All @@ -193,10 +183,7 @@ benchmark legacy-bench
other-modules: BinSearch
default-language: Haskell2010
ghc-options:
-Wall -O2 -threaded -rtsopts -with-rtsopts=-N
if impl(ghc >= 8.0)
ghc-options:
-Wno-deprecations
-Wall -O2 -threaded -rtsopts -with-rtsopts=-N -Wno-deprecations

build-depends:
base,
Expand Down

0 comments on commit 046e3f8

Please sign in to comment.