mirror of
https://github.com/Lysxia/generic-random.git
synced 2024-09-11 06:35:24 +03:00
ci: Switch to Github Actions
This commit is contained in:
parent
03856f8af7
commit
03af36d496
128
.github/workflows/ci.yml
vendored
Normal file
128
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
name: CI
|
||||
|
||||
# Trigger the workflow on push or pull request, but only for the master branch
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
cabal:
|
||||
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||
cabal: ["3.2"]
|
||||
ghc:
|
||||
- "7.10"
|
||||
- "8.0"
|
||||
- "8.2"
|
||||
- "8.4"
|
||||
- "8.6"
|
||||
- "8.8"
|
||||
- "8.10"
|
||||
exclude:
|
||||
- os: macOS-latest
|
||||
ghc: 8.8
|
||||
- os: macOS-latest
|
||||
ghc: 8.6
|
||||
- os: macOS-latest
|
||||
ghc: 8.4
|
||||
- os: macOS-latest
|
||||
ghc: 8.2
|
||||
- os: macOS-latest
|
||||
ghc: 8.0
|
||||
- os: macOS-latest
|
||||
ghc: 7.10
|
||||
- os: windows-latest
|
||||
ghc: 8.10
|
||||
- os: windows-latest
|
||||
ghc: 8.6
|
||||
- os: windows-latest
|
||||
ghc: 8.4
|
||||
- os: windows-latest
|
||||
ghc: 8.2
|
||||
- os: windows-latest
|
||||
ghc: 8.0
|
||||
- os: windows-latest
|
||||
ghc: 7.10
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
|
||||
|
||||
- uses: actions/setup-haskell@v1.1.4
|
||||
id: setup-haskell-cabal
|
||||
name: Setup Haskell
|
||||
with:
|
||||
ghc-version: ${{ matrix.ghc }}
|
||||
cabal-version: ${{ matrix.cabal }}
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
|
||||
|
||||
- name: Freeze
|
||||
run: |
|
||||
cabal freeze
|
||||
|
||||
- uses: actions/cache@v2.1.3
|
||||
name: Cache ~/.cabal/store
|
||||
with:
|
||||
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
|
||||
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cabal build all --only-dependencies
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=always
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cabal test all
|
||||
|
||||
- name: Test inspect
|
||||
if: matrix.ghc == '8.10'
|
||||
run: |
|
||||
rm cabal.project.freeze
|
||||
cabal test .:inspect --flags="enable-inspect"
|
||||
|
||||
stack:
|
||||
name: stack / ghc ${{ matrix.ghc }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
stack: ["latest"]
|
||||
ghc: ["8.8"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
|
||||
|
||||
- uses: actions/setup-haskell@v1.1.4
|
||||
name: Setup Haskell Stack
|
||||
with:
|
||||
ghc-version: ${{ matrix.ghc }}
|
||||
stack-version: ${{ matrix.stack }}
|
||||
|
||||
- uses: actions/cache@v2.1.3
|
||||
name: Cache ~/.stack
|
||||
with:
|
||||
path: ~/.stack
|
||||
key: ${{ runner.os }}-${{ matrix.ghc }}-stack
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --only-dependencies
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
stack test --system-ghc
|
118
.travis.yml
118
.travis.yml
@ -1,118 +0,0 @@
|
||||
# This Travis job script has been generated by a script via
|
||||
#
|
||||
# runghc make_travis_yml_2.hs 'generic-random.cabal'
|
||||
#
|
||||
# For more information, see https://github.com/haskell-CI/haskell-ci
|
||||
#
|
||||
language: c
|
||||
sudo: false
|
||||
|
||||
git:
|
||||
submodules: false # whether to recursively clone submodules
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.cabal/packages
|
||||
- $HOME/.cabal/store
|
||||
|
||||
before_cache:
|
||||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
|
||||
# remove files that are regenerated by 'cabal update'
|
||||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
|
||||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
|
||||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
|
||||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
|
||||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
|
||||
|
||||
- rm -rfv $HOME/.cabal/packages/head.hackage
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- compiler: "ghc-8.6.1"
|
||||
# env: TEST=--disable-tests BENCH=--disable-benchmarks
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.6.1], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-8.4.1"
|
||||
# env: TEST=--disable-tests BENCH=--disable-benchmarks
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.4.1], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-8.2.1"
|
||||
# env: TEST=--disable-tests BENCH=--disable-benchmarks
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.2.1], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-8.0.1"
|
||||
# env: TEST=--disable-tests BENCH=--disable-benchmarks
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.0.1], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-7.10.3"
|
||||
# env: TEST=--disable-tests BENCH=--disable-benchmarks
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.10.3], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-7.8.4"
|
||||
# env: TEST=--disable-tests BENCH=--disable-benchmarks
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.8.4], sources: [hvr-ghc]}}
|
||||
|
||||
before_install:
|
||||
- HC=${CC}
|
||||
- HCPKG=${HC/ghc/ghc-pkg}
|
||||
- unset CC
|
||||
- ROOTDIR=$(pwd)
|
||||
- mkdir -p $HOME/.local/bin
|
||||
- "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"
|
||||
- HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
|
||||
- echo $HCNUMVER
|
||||
|
||||
install:
|
||||
- cabal --version
|
||||
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
|
||||
- BENCH=${BENCH---enable-benchmarks}
|
||||
- TEST=${TEST---enable-tests}
|
||||
- HADDOCK=${HADDOCK-true}
|
||||
- UNCONSTRAINED=${UNCONSTRAINED-true}
|
||||
- NOINSTALLEDCONSTRAINTS=${NOINSTALLEDCONSTRAINTS-false}
|
||||
- GHCHEAD=${GHCHEAD-false}
|
||||
- travis_retry cabal update -v
|
||||
- "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
|
||||
- rm -fv cabal.project cabal.project.local
|
||||
- grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
|
||||
- "printf 'packages: \".\"\\n' > cabal.project"
|
||||
- touch cabal.project.local
|
||||
- "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- generic-random | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
|
||||
- cat cabal.project || true
|
||||
- cat cabal.project.local || true
|
||||
- if [ -f "./configure.ac" ]; then
|
||||
(cd "." && autoreconf -i);
|
||||
fi
|
||||
- rm -f cabal.project.freeze
|
||||
- cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
|
||||
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
|
||||
- rm -rf .ghc.environment.* "."/dist
|
||||
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
|
||||
|
||||
# Here starts the actual work to be performed for the package under test;
|
||||
# any command which exits with a non-zero exit code causes the build to fail.
|
||||
script:
|
||||
# test that source-distributions can be generated
|
||||
- (cd "." && cabal sdist)
|
||||
- mv "."/dist/generic-random-*.tar.gz ${DISTDIR}/
|
||||
- cd ${DISTDIR} || false
|
||||
- find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
|
||||
- "printf 'packages: generic-random-*/*.cabal\\n' > cabal.project"
|
||||
- touch cabal.project.local
|
||||
- "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- generic-random | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
|
||||
- cat cabal.project || true
|
||||
- cat cabal.project.local || true
|
||||
# this builds all libraries and executables (without tests/benchmarks)
|
||||
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
|
||||
|
||||
# build & run tests, build benchmarks
|
||||
- cabal new-build -w ${HC} ${TEST} ${BENCH} all
|
||||
- if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} ${BENCH} all; fi
|
||||
|
||||
# cabal check
|
||||
- (cd generic-random-* && cabal check)
|
||||
|
||||
# haddock
|
||||
- rm -rf ./dist-newstyle
|
||||
- if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi
|
||||
|
||||
# Build without installed constraints for packages in global-db
|
||||
- if $UNCONSTRAINED; then rm -f cabal.project.local; echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks all; else echo "Not building without installed constraints"; fi
|
||||
|
||||
# REGENDATA ["generic-random.cabal"]
|
||||
# EOF
|
@ -17,18 +17,20 @@ executable generic-example
|
||||
executable text-example
|
||||
main-is: text.hs
|
||||
ghc-options: -Wall -Wno-orphans -Wno-unused-top-binds
|
||||
if impl(ghc < 7.10)
|
||||
ghc-options: -fcontext-stack=30
|
||||
build-depends:
|
||||
base,
|
||||
QuickCheck,
|
||||
text,
|
||||
generic-random
|
||||
default-language: Haskell2010
|
||||
if !impl(ghc >= 8.0)
|
||||
buildable: False
|
||||
|
||||
executable tour-example
|
||||
main-is: tour.hs
|
||||
ghc-options: -Wall -Wno-orphans -Wno-unused-imports
|
||||
ghc-options: -Wall
|
||||
if impl(ghc >= 8.0)
|
||||
ghc-options: -Wno-orphans -Wno-unused-imports
|
||||
if impl(ghc < 7.10)
|
||||
ghc-options: -fcontext-stack=30
|
||||
build-depends:
|
||||
@ -40,8 +42,9 @@ executable tour-example
|
||||
|
||||
executable tour-bench
|
||||
main-is: tour.hs
|
||||
ghc-options: -O2
|
||||
ghc-options: -dsuppress-all -dno-suppress-module-prefixes -Wno-unused-imports
|
||||
ghc-options: -O2 -dsuppress-all -dno-suppress-module-prefixes
|
||||
if impl(ghc >= 8.0)
|
||||
ghc-options: -Wno-unused-imports
|
||||
cpp-options: -DBENCHMODE
|
||||
build-depends:
|
||||
base,
|
||||
|
@ -6,14 +6,13 @@
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE InstanceSigs #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE TypeApplications #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
|
||||
import Control.Monad
|
||||
import Control.Monad (replicateM)
|
||||
import GHC.Generics
|
||||
import Test.QuickCheck
|
||||
import Test.QuickCheck (Arbitrary(..), Gen, quickCheck, sample, generate)
|
||||
|
||||
import Generic.Random
|
||||
import Generic.Random (genericArbitraryG, (:+)(..), (%))
|
||||
|
||||
data MyType
|
||||
= OneThing Int
|
||||
@ -37,7 +36,7 @@ main :: IO ()
|
||||
#ifndef BENCHMODE
|
||||
main = do
|
||||
-- Print some examples
|
||||
sample (arbitrary @MyType)
|
||||
sample (arbitrary :: Gen MyType)
|
||||
|
||||
-- Check the property that ThreeThings contains three things.
|
||||
quickCheck $ \case
|
||||
@ -46,7 +45,7 @@ main = do
|
||||
#else
|
||||
-- Quick and dirty benchmark
|
||||
main = do
|
||||
xs <- generate (replicateM 1000000 (arbitrary @MyType))
|
||||
xs <- generate (replicateM 1000000 (arbitrary :: Gen MyType))
|
||||
go xs
|
||||
where
|
||||
go [] = print ()
|
||||
|
5
stack.yaml
Normal file
5
stack.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
resolver: lts-16.31
|
||||
packages:
|
||||
- '.'
|
||||
- 'examples/'
|
||||
extra-deps: []
|
Loading…
Reference in New Issue
Block a user