Merge pull request #4642 from unisonweb/fix/local-defs #997
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: Haddocks | |
defaults: | |
run: | |
working-directory: unison | |
shell: bash | |
on: | |
push: | |
branches: | |
- trunk | |
jobs: | |
build: | |
name: Haddocks | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
path: unison | |
# The number towards the beginning of the cache keys allow you to manually avoid using a previous cache. | |
# GitHub will automatically delete caches that haven't been accessed in 7 days, but there is no way to | |
# purge one manually. | |
# Cache ~/.stack, keyed by the contents of 'stack.yaml'. | |
- uses: actions/cache@v2 | |
name: cache ~/.stack | |
with: | |
path: ~/.stack | |
# Main cache key: commit hash. This should always result in a cache miss... | |
# So when loading a cache we'll always fall back to the restore-keys, | |
# which should load the most recent cache via a prefix search on the most | |
# recent branch cache. | |
# Then it will save a new cache at this commit sha, which should be used by | |
# the next build on this branch. | |
key: stack-0-haddocks-${{github.sha}} | |
# Fall-back to the most recent haddocks build, or to a standard Linux build failing that. | |
restore-keys: | | |
stack-0-haddocks | |
stack-0-Linux | |
# Cache each local package's ~/.stack-work for fast incremental builds in CI. | |
- uses: actions/cache@v2 | |
name: cache .stack-work | |
with: | |
path: | | |
**/.stack-work | |
# Main cache key: commit hash. This should always result in a cache miss... | |
# So when loading a cache we'll always fall back to the restore-keys, | |
# which should load the most recent cache via a prefix search on the most | |
# recent branch cache. | |
# Then it will save a new cache at this commit sha, which should be used by | |
# the next build on this branch. | |
key: stack-work-2-haddocks-${{github.sha}} | |
# Fall-back to the most recent haddocks build, or to a standard Linux build failing that. | |
restore-keys: | | |
stack-work-2_Linux-haddocks | |
stack-work-2_Linux | |
- name: install stack (Linux) | |
working-directory: ${{ github.workspace }} | |
run: | | |
mkdir stack && cd stack | |
curl -L https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-linux-x86_64.tar.gz | tar -xz | |
echo "$PWD/stack-"* >> $GITHUB_PATH | |
# One of the transcripts fails if the user's git name hasn't been set. | |
- name: set git user info | |
working-directory: unison | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
- name: build with haddocks | |
working-directory: unison | |
run: stack --no-terminal build --fast --haddock | |
# Haddocks | |
- name: Checkout haddocks branch | |
uses: actions/checkout@v2 | |
with: | |
ref: 'haddocks' | |
path: 'haddocks' | |
- name: Copy haddocks | |
working-directory: 'unison' | |
run: | | |
docs_root="$(stack path --local-doc-root)" | |
# Erase any stale files | |
cd "$GITHUB_WORKSPACE"/haddocks | |
rm -rf ./* | |
git checkout --orphan fresh-haddocks-branch | |
cp -r "${docs_root}"/* "$GITHUB_WORKSPACE"/haddocks | |
git add . | |
git commit -m "Regenerated haddocks based on ${GITHUB_SHA}" | |
# Push the branch with only a single commit over the remote | |
git push --force origin fresh-haddocks-branch:haddocks |