Last active
October 21, 2022 15:38
-
-
Save KtorZ/ee63855c893747f5156da171027793e8 to your computer and use it in GitHub Desktop.
Drop-in Github workflow for Haskell projects using stack.
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: Code Style | |
on: | |
pull_request: | |
branches: [ "master" ] | |
push: | |
branches: [ "master" ] | |
tags: [ "*.*.*" ] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: π₯ Checkout repository | |
uses: actions/checkout@v1 | |
- name: β Check hlint and stylish | |
run: | | |
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s . | |
curl -sSL https://raw.github.com/jaspervdj/stylish-haskell/master/scripts/latest.sh | sh -s $(find . -type f -name "*.hs" ! -path "*.stack-work*") -i | |
if [ -z "$(git status --porcelain)" ]; then | |
echo "No style errors detected." | |
else | |
echo "Style errors detected:" | |
git --no-pager diff | |
exit 1 | |
fi |
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: Continuous Integration | |
on: | |
pull_request: | |
branches: [ "master" ] | |
push: | |
branches: [ "master" ] | |
tags: [ "*.*.*" ] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: π½ Install OS Packages | |
uses: mstksg/get-package@v1 | |
with: | |
apt-get: libgmp-dev | |
- name: π₯ Checkout repository | |
uses: actions/checkout@v1 | |
- name: π§° Setup Stack | |
uses: mstksg/setup-stack@v1 | |
- 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@v1 | |
with: | |
path: ~/.stack | |
key: ${{ matrix.os }}-${{ steps.cache_key.outputs.key }} | |
- name: π·οΈ Variables | |
id: variables | |
run: | | |
echo ::set-output name=pkg_name::$(cat *.cabal | grep "name:" | sed "s/name:\s*\(.*\)/\1/") | |
- 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 --haddock --no-haddock-deps --no-run-benchmarks | |
mkdir -p dist/haddock && mv $(stack path --local-install-root)/doc/* dist/haddock | |
sed -i 's@href="[^"]*/doc/\([^"]*.html\)"@href="\1"@g' dist/haddock/index.html | |
wget -O Makefile https://gist.githubusercontent.com/KtorZ/0c7411f9bda2db1b3e0ded2ef0c40381/raw/1f818bd0385d8d917903e3f67ee3bfee3002de7a/Makefile | |
mkdir -p .coverage && touch .coverage/template.overlay | |
DESTDIR=dist/coverage make report && DESTDIR=dist/coverage make badge | |
env: | |
PKG_NAME: ${{ steps.variables.outputs.pkg_name }} | |
- name: π Publish Documentation | |
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: true | |
release: | |
needs: [build] | |
if: ${{ startsWith(github.ref, 'refs/tags') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout repository | |
uses: actions/checkout@v1 | |
- name: π Release | |
uses: docker://antonyurchenko/git-release:latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DRAFT_RELEASE: "true" | |
PRE_RELEASE: "false" | |
CHANGELOG_FILE: "ChangeLog.md" | |
ALLOW_EMPTY_CHANGELOG: "false" | |
ALLOW_TAG_PREFIX: "true" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would suggest to change the script in line 24 to this one, as github changed the way it works now to retrieve the latest stylish-haskell release file.
https://raw.githubusercontent.com/cad0p/uu-afp-2021-assign2/master/scripts/stylish-haskell.sh