Skip to content

Commit

Permalink
update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
raehik committed Feb 15, 2022
1 parent 5724ee2 commit 0d8c9af
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 10 deletions.
96 changes: 86 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ on:
- synchronize

jobs:
build-test-ubuntu-stack:
ubuntu-stack-test:
runs-on: ubuntu-latest
name: Ubuntu / Stack
name: Ubuntu / Stack / test
steps:
- uses: actions/checkout@v2

Expand All @@ -34,17 +34,18 @@ jobs:
- name: Build and run tests
run: stack --no-terminal haddock --test --no-haddock-deps

build-test-ubuntu-cabal:
ubuntu-cabal-test:
runs-on: ubuntu-latest
name: Ubuntu / GHC ${{ matrix.ghc }}, Cabal ${{ matrix.cabal }}
name: Ubuntu / GHC ${{ matrix.ghc }}, Cabal / test

strategy:
fail-fast: false # don't stop if one job (= GHC version) fails
matrix:
cabal: ["3.4"] # latest as of 2021-06-30
cabal: ["3.4"] # ghcup recommended as of 2021-09-24
ghc:
- "8.6"
- "8.8"
- "8.10"
- "8.4"
- "9.0"

steps:

# TODO: GHC decides to recompile based on timestamp, so cache isn't used
Expand All @@ -71,8 +72,83 @@ jobs:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- name: Freeze Cabal plan
run: cabal freeze
- run: cabal freeze

- name: Cache Cabal build artifacts
uses: actions/cache@v2
with:
path: |
${{ steps.setup-haskell-build-env.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-cabal-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
${{ runner.os }}-cabal-${{ matrix.ghc }}
- name: Test
run: cabal test --test-show-details=streaming
env:
HSPEC_OPTIONS: --color

mac-cabal-test:
runs-on: macos-latest
name: Mac / GHC ${{ matrix.ghc }}, Cabal / test
strategy:
fail-fast: false # don't stop if one job (= GHC version) fails
matrix:
cabal: ["3.4"] # ghcup recommended as of 2021-09-24
ghc: ["9.0"]
steps:

# TODO figure out timestamp fixer on Mac (no Mac available to test)
- uses: actions/checkout@v2

- name: Setup Haskell build environment
id: setup-haskell-build-env
uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- run: cabal freeze

- name: Cache Cabal build artifacts
uses: actions/cache@v2
with:
path: |
${{ steps.setup-haskell-build-env.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-cabal-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
${{ runner.os }}-cabal-${{ matrix.ghc }}
- name: Build
run: cabal build

- name: Test
run: cabal test --test-show-details=streaming
env:
HSPEC_OPTIONS: --color

windows-cabal-test:
runs-on: windows-latest
name: Windows / GHC ${{ matrix.ghc }}, Cabal / test
strategy:
fail-fast: false # don't stop if one job (= GHC version) fails
matrix:
cabal: ["3.4"] # ghcup recommended as of 2021-09-24
ghc: ["9.0"]
steps:
# TODO figure out timestamp fixer on Windows (need Bash)
- uses: actions/checkout@v2

- name: Setup Haskell build environment
id: setup-haskell-build-env
uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- run: cabal freeze

- name: Cache Cabal build artifacts
uses: actions/cache@v2
Expand Down
90 changes: 90 additions & 0 deletions .github/workflows/hackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# This workflow is based on the expectation that GitHub's runners install GHC
# using ghcup with default settings (installs GHCs to `~/.ghcup/ghc/$VERSION`).

name: Hackage artifacts

on:
push:
branches:
- main

env:
# ghcup needs full version string (e.g. 9.0.1, not 9.0)
ghc: "9.0.1"
EXE_NAME: fortran-src-extras

jobs:
hackage:
runs-on: ubuntu-latest
name: Hackage artifacts

steps:

# TODO: GHC decides to recompile based on timestamp, so cache isn't used
# Preferably GHC would work via hashes instead. Stack had this feature
# merged in Aug 2020.
# Upstream GHC issue: https://gitlab.haskell.org/ghc/ghc/-/issues/16495
# My issue on haskell/actions: https://github.com/haskell/actions/issues/41
# This also requires us to do a deep fetch, else we don't get the Git commit
# history we need to rewrite mod times.
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set all tracked file modification times to the time of their last commit
run: |
rev=HEAD
for f in $(git ls-tree -r -t --full-name --name-only "$rev") ; do
touch -d $(git log --pretty=format:%cI -1 "$rev" -- "$f") "$f";
done
- name: Delete preinstalled docs-stripped GHC ${{ env.ghc }}
run: rm -rf $HOME/.ghcup/ghc/${{ env.ghc }}

- name: Cache GHC ${{ env.ghc }}
uses: actions/cache@v2
with:
path: ~/.ghcup/ghc/${{ env.ghc }}
key: haddock-${{ env.ghc }}-ghc

- name: Install GHC ${{ env.ghc }} if not present from cache
run: |
if [ ! -d $HOME/.ghcup/ghc/${{ env.ghc }} ]; then
ghcup install ghc --force ${{ env.ghc }}
fi
- run: ghcup set ghc ${{ env.ghc }}

- run: cabal update

- run: cabal freeze

- name: Cache Cabal build artifacts
uses: actions/cache@v2
with:
path: |
~/.cabal/store
dist-newstyle
key: haddock-${{ env.ghc }}-cabal-${{ hashFiles('cabal.project.freeze') }}
restore-keys: haddock-${{ env.ghc }}-cabal

- run: cabal haddock --haddock-for-hackage --enable-documentation
- run: cabal sdist

- name: Upload Hackage sdist
uses: actions/upload-artifact@v2
with:
path: dist-newstyle/sdist/${{ env.EXE_NAME }}-*.tar.gz
name: ${{ env.EXE_NAME }}-sdist-${{ github.sha }}.tar.gz
if-no-files-found: error

- name: Upload Hackage Haddock docs
uses: actions/upload-artifact@v2
with:
path: dist-newstyle/${{ env.EXE_NAME }}-*-docs.tar.gz
name: ${{ env.EXE_NAME }}-hackage-haddocks-${{ github.sha }}.tar.gz
if-no-files-found: error

- name: Delete prepared tarballs (else can't extract just newest next time)
run: |
rm dist-newstyle/${{ env.EXE_NAME }}-*-docs.tar.gz
rm dist-newstyle/sdist/${{ env.EXE_NAME }}-*.tar.gz

0 comments on commit 0d8c9af

Please sign in to comment.