Skip to content

Commit

Permalink
[#398] Improve GitHub Actions CI cache support (#413)
Browse files Browse the repository at this point in the history
Resolves #398
  • Loading branch information
chshersh authored Feb 21, 2020
1 parent 03da50a commit 795b45c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 42 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:

jobs:
build:
name: ghc ${{ matrix.ghc }}
runs-on: ubuntu-16.04
strategy:
matrix:
ghc: ["8.2.2", "8.4.4", "8.6.5", "8.8.2"]
cabal: ["3.0"]

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
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- uses: actions/cache@v1
name: Cache ~/.cabal/store
with:
path: ~/.cabal/store
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal

- name: Build
run: |
cabal new-update
cabal new-build all --enable-tests --enable-benchmarks --write-ghc-environment-files=always
- name: Test
run: |
cabal new-test all --enable-tests
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Features related to the structure and content of the generated projects.
[Dead simple Haskell Travis Settings for Cabal and Stack](https://chshersh.github.io/posts/2019-02-25-haskell-travis).
+ Generation of the `appveyor.yaml` file which runs build and tests on CI under Windows.
+ Generation of the `.github/workflows/ci.yml` file that runs build and tests on
GitHub ACtuions CI under Linux using Cabal.
GitHub Actions CI under Linux using Cabal.
+ Configuration matrix on CI to build with multiple GHC versions and various build tools.
+ `-Werror` is enabled on CI not to miss any warnings.
+ Run HLint checks on CI.
Expand Down
4 changes: 3 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
packages:
summoner-cli/
summoner-tui/
summoner-tui/

tests: true
25 changes: 5 additions & 20 deletions summoner-cli/src/Summoner/Template/GitHub.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,34 +139,19 @@ gitHubFiles Settings{..} = concat
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

# We cache the elements of the Cabal store separately,
# as the entirety of ~/.cabal can grow very large
# for projects with many dependencies.

- uses: actions/cache@v1
name: Cache ~/.cabal/packages
with:
path: ~/.cabal/packages
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-packages
- uses: actions/cache@v1
name: Cache ~/.cabal/store
with:
path: ~/.cabal/store
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-store
- uses: actions/cache@v1
name: Cache dist-newstyle
with:
path: dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-dist
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal

- name: Install dependencies
- name: Build
run: |
cabal new-update
cabal new-configure --enable-tests --enable-benchmarks --write-ghc-environment-files=always -j2
cabal new-build --only-dependencies
- name: Build & test
cabal new-build --enable-tests --enable-benchmarks --write-ghc-environment-files=always

- name: Test
run: |
cabal v2-build
${cabalTest}
|]

Expand Down
25 changes: 5 additions & 20 deletions summoner-cli/test/golden/fullProject/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,17 @@ jobs:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

# We cache the elements of the Cabal store separately,
# as the entirety of ~/.cabal can grow very large
# for projects with many dependencies.

- uses: actions/cache@v1
name: Cache ~/.cabal/packages
with:
path: ~/.cabal/packages
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-packages
- uses: actions/cache@v1
name: Cache ~/.cabal/store
with:
path: ~/.cabal/store
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-store
- uses: actions/cache@v1
name: Cache dist-newstyle
with:
path: dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-dist
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal

- name: Install dependencies
- name: Build
run: |
cabal new-update
cabal new-configure --enable-tests --enable-benchmarks --write-ghc-environment-files=always -j2
cabal new-build --only-dependencies
- name: Build & test
cabal new-build --enable-tests --enable-benchmarks --write-ghc-environment-files=always
- name: Test
run: |
cabal v2-build
cabal new-test --enable-tests

0 comments on commit 795b45c

Please sign in to comment.