Merge pull request #30 from brandonchinn178/updates #97
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: | |
pull_request: | |
push: | |
branches: | |
- main | |
workflow_call: | |
env: | |
TOML_TEST_VERSION: '1.2.0' | |
jobs: | |
build_and_test: | |
name: build_and_test | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v3 | |
- | |
name: Install toml-test | |
run: | | |
curl -fsSL "https://github.com/BurntSushi/toml-test/releases/download/v${TOML_TEST_VERSION}/toml-test-v${TOML_TEST_VERSION}-linux-amd64.gz" \ | |
| gunzip \ | |
> /usr/local/bin/toml-test | |
chmod +x /usr/local/bin/toml-test | |
- | |
uses: actions/cache@v3 | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-stack-cache-${{ hashFiles('stack.yaml', 'package.yaml') }} | |
- | |
name: Build + test | |
run: stack test --coverage | |
- | |
name: Check that Cabal file was generated | |
run: git diff --exit-code '*.cabal' | |
- | |
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@v2 | |
with: | |
files: lcov.info | |
ghc_compat_test: | |
strategy: | |
matrix: | |
ghc_version: | |
- '9.0' | |
- '9.2' | |
- '9.4' | |
- '9.6' | |
include: | |
- ghc_version: '9.0' | |
oldest: true | |
name: ghc_compat_test (${{ matrix.ghc_version }}) | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v3 | |
- | |
name: Install toml-test | |
run: | | |
curl -fsSL "https://github.com/BurntSushi/toml-test/releases/download/v${TOML_TEST_VERSION}/toml-test-v${TOML_TEST_VERSION}-linux-amd64.gz" \ | |
| gunzip \ | |
> /usr/local/bin/toml-test | |
chmod +x /usr/local/bin/toml-test | |
- | |
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-show-details=streaming | |
- | |
if: ${{ matrix.oldest }} | |
name: Use oldest dependencies | |
run: cabal configure --enable-append --prefer-oldest | |
- | |
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: | |
FOURMOLU_VERSION: '0.13.0.0' | |
steps: | |
- | |
uses: actions/checkout@v3 | |
- | |
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 | |
- | |
name: Run fourmolu | |
run: fourmolu -m check $(git ls-files '*.hs') | |
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') }} | |
- | |
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: toml-reader-sdist | |
path: toml-reader-*.tar.gz |