Add a cabal builder #138
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: Haskell CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
stack: | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache Key | |
id: cache_key | |
run: echo ::set-output name=key::$(md5sum stack.yaml | awk '{print $1}') | |
- name: Cache Dependencies | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.stack | |
key: ${{ matrix.os }}-${{ steps.cache_key.outputs.key }} | |
- name: Build Snapshot | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
stack --no-terminal test --bench --only-snapshot | |
- name: Build & Test | |
run: | | |
stack --no-terminal test --bench --no-run-benchmarks --haddock --no-haddock-deps | |
stack install | |
cp $HOME/.local/bin/mqtt-watch . | |
PKG_NAME=$(cat *.cabal | grep "name:" | sed "s/name:\s*\(.*\)/\1/") | |
mkdir -p dist/ && mv $(stack path --local-install-root)/doc/$PKG_NAME-*/* dist/ | |
- name: Store Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: mqtt-watch-${{ matrix.os }} | |
path: mqtt-watch | |
- name: Publish Docs | |
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: dist | |
enable_jekyll: false | |
cabal: | |
runs-on: 'ubuntu-latest' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Haskell | |
uses: haskell-actions/setup@v2 | |
id: setup | |
with: | |
ghc-version: '9.6.4' | |
cabal-version: '3.10.2.1' | |
- name: Generate Cache Keys | |
id: cache_key | |
run: | | |
echo "ghc_ver=${{ steps.setup.outputs.ghc-version }}" >> $GITHUB_ENV | |
cabal freeze | |
echo "dep_hash=$(md5sum cabal.project.freeze | awk '{print $1}')" >> $GITHUB_ENV | |
- name: Cache Dependencies | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cabal | |
dist-newstyle | |
key: ubuntu-latest-ghc-${{ env.ghc_ver }}-cabal-${{ env.dep_hash }} | |
restore-keys: | | |
ubuntu-latest-ghc-${{ env.ghc_ver }}-cabal- | |
ubuntu-latest-ghc-${{ env.ghc_ver }}- | |
ubuntu-latest- | |
- name: Install tasty-discover | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: cabal install --overwrite-policy=always tasty-discover | |
- name: Build & Test | |
run: | | |
cabal build | |
cabal test --test-show-details=streaming |