Skip to content

CI

CI #223

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
schedule:
- cron: '0 0 * * *'
workflow_call:
jobs:
build_and_test:
name: build_and_test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13.1
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: persistent_mtl
ports:
- 5432:5432
env:
TEST_POSTGRESQL: 1
steps:
-
uses: actions/checkout@v3
-
uses: actions/cache@v3
with:
path: ~/.stack
key: ${{ runner.os }}-stack-cache-${{ hashFiles('stack.yaml', 'package.yaml') }}
-
run: stack test --coverage
-
name: Check that files are unmodified
run: git diff --exit-code
-
name: Check for any outdated packages
run: cabal outdated --exit-code
-
name: Generate coverage data
run: |
HPC_LCOV_VERSION=1.1.1
curl -fsSL \
"https://github.com/brandonchinn178/hpc-lcov/releases/download/v${HPC_LCOV_VERSION}/hpc-lcov-${HPC_LCOV_VERSION}-linux-x86_64" \
-o /usr/local/bin/hpc-lcov
chmod +x /usr/local/bin/hpc-lcov
hpc-lcov
-
uses: codecov/codecov-action@v3
with:
files: lcov.info
compat_test:
strategy:
matrix:
ghc_version:
- '9.4'
- '9.6'
- '9.8'
persistent_version:
- '2.14'
include:
- ghc_version: '9.4.4'
persistent_version: '2.14'
oldest: true
name: compat_test (ghc-${{ matrix.ghc_version }}, persistent-${{ matrix.persistent_version }})
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v3
-
id: setup
name: Set up GHC ${{ matrix.ghc_version }}
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc_version }}
-
name: Configure the build
run:
cabal configure
--enable-test
--test-options='--color=always'
--test-show-details=streaming
--constraint='persistent ^>= ${{ matrix.persistent_version }}'
--constraint='persistent >= 2.14.0.2'
-
# https://github.com/bitemyapp/esqueleto/pull/381
if: ${{ matrix.ghc_version == '9.8' }}
name: Patch esqueleto
run: |
cabal configure --enable-append --allow-newer esqueleto:text
cat >> cabal.project.local <<EOF
source-repository-package
type: git
location: https://github.com/MercuryTechnologies/esqueleto.git
tag: 94d27de57072a823d97bd9868b33c45545c067c4
EOF
-
if: ${{ matrix.oldest }}
name: Use oldest dependencies
run:
cabal configure
--enable-append --prefer-oldest
--constraint 'array installed'
--constraint 'time installed'
--constraint 'persistent-sqlite > 2.13.0.3'
--constraint 'silently >= 0.0.3'
--constraint 'string-conversions >= 0.4'
-
name: Get build plan
run: cabal build --dry-run
-
name: Get current month to clear cache
run: echo "CURR_MONTH=$(date +%B)" | tee -a "$GITHUB_ENV"
-
uses: actions/cache@v3
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ runner.os }}-cabal-cache-${{ env.CURR_MONTH }}-${{ matrix.ghc_version }}-${{ hashFiles('**/plan.json') }}
restore-keys: |
${{ runner.os }}-cabal-cache-${{ env.CURR_MONTH }}-${{ matrix.ghc_version }}-
-
name: Build + Test
run: cabal test
lint:
runs-on: ubuntu-latest
env:
HLINT_VERSION: '3.5'
FOURMOLU_VERSION: '0.13.0.0'
steps:
-
uses: actions/checkout@v3
-
name: Install hlint
run: |
HLINT_ARCHIVE="hlint-${HLINT_VERSION}-x86_64-linux.tar.gz"
curl -sSLO "https://github.com/ndmitchell/hlint/releases/download/v${HLINT_VERSION}/${HLINT_ARCHIVE}"
tar xzf "${HLINT_ARCHIVE}" -C /usr/local/bin/ --strip-components=1 "hlint-${HLINT_VERSION}/hlint"
-
name: Install fourmolu
run: |
curl -sSL \
"https://github.com/fourmolu/fourmolu/releases/download/v${FOURMOLU_VERSION}/fourmolu-${FOURMOLU_VERSION}-linux-x86_64" \
-o /usr/local/bin/fourmolu
chmod +x /usr/local/bin/fourmolu
-
run: pip install pre-commit
-
run: pre-commit run --all-files -v --show-diff-on-failure
env:
SKIP: no-commit-to-branch
check_sdist:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v3
-
uses: actions/cache@v3
with:
path: ~/.stack
key: ${{ runner.os }}-check_sdist-${{ hashFiles('stack.yaml', 'package.yaml') }}
-
name: Strip unreleased section from CHANGELOG
run: sed -i -n '/^# Unreleased/d; /^#/,$p' CHANGELOG.md
-
name: Create sdist bundle
run: stack sdist --test-tarball --tar-dir .
-
uses: actions/upload-artifact@v3
with:
name: persistent-mtl-sdist
path: persistent-mtl-*.tar.gz
check_codegen:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v3
-
uses: actions/cache@v3
with:
path: ~/.stack
key: ${{ runner.os }}-check_codegen-${{ hashFiles('stack.yaml') }}
-
run: scripts/generate/run.sh
-
run: git diff --exit-code *.hs