Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp CI #678

Merged
merged 16 commits into from
Feb 21, 2023
66 changes: 0 additions & 66 deletions .github/workflows/Cabal.yml

This file was deleted.

68 changes: 0 additions & 68 deletions .github/workflows/Stack.yml

This file was deleted.

67 changes: 67 additions & 0 deletions .github/workflows/presubmit-cabal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Haskell Cabal

on:
push:
branches: [master]
pull_request:
branches: [master]
types: [opened, synchronize]

permissions: {}

jobs:
test:
name: CI
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # don't cancel other jobs if one fails
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
ghc: ["8.10.7", "9.2.5", "9.4.4"]
steps:
- name: "Checkout code"
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
with:
persist-credentials: false

- name: Setup Haskell Compiler (cabal)
id: setup-haskell
uses: haskell/actions/setup@93635e8c4ac823f55cf3444537a63d3f2fd589de # v2.1.0
with:
ghc-version: ${{ matrix.ghc }}

- name: Cache dist-newstyle
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3.2.2
with:
path: dist-newstyle
key: dist-newstyle-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('internal/**','src/**','app/**','tests/**','benchmarks/**') }}
restore-keys: |
dist-newstyle-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal') }}-
dist-newstyle-${{ matrix.os }}-${{ matrix.ghc }}-

- name: Cache ~/.cabal/store
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3.2.2
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: cabal-store-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal') }}
restore-keys: cabal-store-${{ matrix.os }}-${{ matrix.ghc }}-

- name: Configure to run tests and benchmarks
run: cabal configure --enable-tests --enable-benchmarks

- name: Build code
run: cabal build

- name: Test code
run: cabal test

- name: Benchmark code
run: cabal bench

- name: Generate documentation
run: cabal haddock all

# TODO(mihaimaruseac): Move to using a custom action that can be reused
- name: Validate code formatting (self-validate)
if: matrix.os != 'windows-latest' # TODO(mihaimaruseac): Why does this fail on Windows (path issue)?
run: cabal run hindent -- **/*.hs --validate
75 changes: 75 additions & 0 deletions .github/workflows/presubmit-stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Haskell Stack

on:
push:
branches: [master]
pull_request:
branches: [master]
types: [opened, synchronize]

permissions: {}

jobs:
test:
name: CI
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # don't cancel other jobs if one fails
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# We don't split on multiple resolvers as the ~/.stack grows to ~700MB
# whereas all others (including Cabal ones) barely reach 50MB. Instead,
# we only use nightly as the resolver, as this should handle the newest
# GHC and is also the place where failures will be reported from Stack.
resolver: ["nightly"]
steps:
- name: "Checkout code"
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
with:
persist-credentials: false

- name: Setup Haskell Compiler (stack)
id: setup-haskell
uses: haskell/actions/setup@93635e8c4ac823f55cf3444537a63d3f2fd589de # v2.1.0
with:
enable-stack: true
stack-no-global: true

- name: Cache .stack-work
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3.2.2
with:
path: .stack-work
key: stack-work-${{ matrix.os }}-${{ matrix.resolver }}-${{ hashFiles('stack.yaml', '**/*.cabal') }}-${{ hashFiles('internal/**','src/**','app/**','tests/**','benchmarks/**') }}
restore-keys: |
stack-work-${{ matrix.os }}-${{ matrix.resolver }}-${{ hashFiles('stack.yaml', '**/*.cabal') }}-
stack-work-${{ matrix.os }}-${{ matrix.resolver }}-

- name: Cache ~/.stack
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3.2.2
with:
path: ${{ steps.setup-haskell.outputs.stack-root }}
key: stack-root-${{ matrix.os }}-${{ matrix.resolver }}-${{ hashFiles('stack.yaml', '**/*.cabal') }}
restore-keys: stack-root-${{ matrix.os }}-${{ matrix.resolver }}-

- name: Get dependencies
run: stack build --resolver=${{ matrix.resolver }} --only-dependencies --test --bench --no-run-tests --no-run-benchmarks

- name: Build code
run: stack build --resolver=${{ matrix.resolver }} --test --bench --no-run-tests --no-run-benchmarks

- name: Test code
run: stack test --resolver=${{ matrix.resolver }}

- name: Benchmark code
run: stack bench --resolver=${{ matrix.resolver }}

- name: Generate documentation
run: stack haddock --resolver=${{ matrix.resolver }}

- name: Validate cabal file is properly generated from HPack
if: matrix.os != 'windows-latest' # Since we're using `diff -u`, cannot run on Windows
run: |
mv hindent.cabal hindent.cabal.original
# See https://github.com/commercialhaskell/stack/issues/3697#issuecomment-353729540.
stack build --resolver=${{ matrix.resolver }} --dry-run
diff -u hindent.cabal.original hindent.cabal
Loading