Merge pull request #276 from gelisam/gelisam/run-workflow #146
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
# Build every pull request, to check for regressions. | |
pull_request: | |
types: [opened, synchronize] | |
# Build when a PR is merged, to update the README's CI badge. | |
push: | |
branches: [main] | |
# Build once a month, to detect missing upper bounds. | |
schedule: | |
- cron: '0 0 1 * *' | |
workflow_dispatch: | |
jobs: | |
stack: | |
name: ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# Check that the build passes with the recommended snapshot. | |
- name: stable | |
stack_yaml: "stack.yaml" | |
os: ubuntu-latest | |
# Check that the lower bounds are still correct by building with the | |
# lowest-supported version of all our dependencies. | |
- name: oldest | |
stack_yaml: "oldest-supported-lts.yaml" | |
os: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
# see https://github.com/actions/cache/issues/403 | |
- name: Work around actions/cache bug | |
if: matrix.os == 'macos-latest' | |
run: | | |
brew update && brew install gnu-tar | |
echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV | |
- uses: actions/cache@v2 | |
name: Cache Stack Artifacts | |
with: | |
path: | | |
~/.stack | |
~/.local/bin | |
.stack-work | |
key: ${{ runner.os }}-stack-${{ hashFiles(matrix.stack_yaml) }}-6 | |
- uses: haskell-actions/setup@v2 | |
id: setup-haskell-stack | |
name: Setup Stack | |
with: | |
enable-stack: true | |
stack-setup-ghc: true | |
stack-no-global: true | |
# For some reason, installing happy from lts-9.0 fails unless some other | |
# version of happy is already in the PATH. So let's install a version of | |
# happy from an lts which does not have this problem. | |
- name: Install happy | |
if: matrix.stack_yaml == 'oldest-supported-lts.yaml' | |
run: | | |
stack --stack-yaml=stack.yaml install happy | |
- name: Build with happy hack | |
if: matrix.stack_yaml == 'oldest-supported-lts.yaml' | |
run: | | |
PATH="$HOME/.local/bin:$PATH" stack --stack-yaml=${{ matrix.stack_yaml }} install --test --bench --no-run-tests --no-run-benchmarks | |
- name: Build | |
if: matrix.stack_yaml == 'stack.yaml' | |
run: | | |
stack --stack-yaml=${{ matrix.stack_yaml }} install --test --bench --no-run-tests --no-run-benchmarks | |
- name: Test | |
run: | | |
stack --stack-yaml=${{ matrix.stack_yaml }} test | |
- name: Run installed exe | |
run: | | |
stack run '2+2' | |
~/.local/bin/hawk '2+2' | |
cabal: | |
name: ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# Check that our upper bounds are correct by building with the latest | |
# version of everything. We use cabal because it uses the latest | |
# versions of our dependencies allowed by our upper bounds. | |
# | |
# TODO: revert to "ghc: latest" once the latest version of ghc is | |
# supported, so we can detect when an even-more-recent version of ghc | |
# is released and breaks hawk. | |
- name: newest | |
ghc: 8.10.4 | |
os: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: haskell-actions/setup@v2 | |
id: setup-haskell-cabal | |
name: Setup Cabal | |
with: | |
ghc-version: ${{ matrix.ghc }} | |
cabal-version: ${{ matrix.cabal }} | |
# This freeze file is regenerated on every build, so we will always test | |
# with the most recent version of our dependencies allowed by our upper | |
# bounds. | |
- name: Freeze | |
run: | | |
cabal v2-configure --enable-tests --enable-benchmarks --test-show-details=direct | |
cabal freeze | |
# Only reuse the cached copy of our dependencies if our freeze file matches | |
# the cache's copy. | |
- uses: actions/cache@v2 | |
name: Cache Cabal Artifacts | |
with: | |
path: | | |
${{ steps.setup-haskell-cabal.outputs.cabal-store }} | |
key: ${{ runner.os }}-cabal-v2-${{ hashFiles('cabal.project.freeze') }} | |
- name: Build | |
run: | | |
cabal v2-build --enable-tests | |
- name: Test | |
run: | | |
rm -rf dist-newstyle/sdist sdist | |
cabal sdist | |
cp -r dist-newstyle/sdist . | |
cd sdist | |
tar xzvf *.tar.gz | |
rm -rf *.tar.gz | |
cd * | |
cabal test |