lsp 2 #136
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
# modified from https://github.com/simonmichael/hledger/blob/master/.github/workflows/linux.yml | |
name: CI (Linux) | |
on: | |
push: | |
branches: [master, ci-*] | |
tags: | |
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | |
pull_request: | |
branches: [master] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
- name: Determine stack resolver | |
run: | | |
STACK_RESOLVER=$(yq .resolver stack.yaml) | |
echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}" | |
# things to be restored: | |
# Include STACK_RESOLVER in cache key, otherwise caches accumulate build products for different resolvers. | |
- name: 💾 Restore cached stack global package db | |
id: stack-global | |
uses: actions/cache/restore@v3 | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global | |
- name: 💾 Restore cached .stack-work | |
id: stack-work | |
uses: actions/cache/restore@v3 | |
with: | |
path: .stack-work | |
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work-${{ hashFiles('**.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work | |
# actions: | |
- name: ⏬ Install stack | |
run: | | |
# mkdir -p ~/.local/bin | |
# export PATH=~/.local/bin:$PATH | |
## Stack is preinstalled on the GHA runners | |
# curl -sL https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack | |
# if [[ ! -x ~/.local/bin/stack ]]; then curl -sL https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack; fi | |
stack --version | |
- name: ⏬ Install GHC | |
run: | | |
df -h | |
stack setup --install-ghc | |
df -h | |
- name: ⏬ Install dependencies | |
run: | | |
stack build --only-dependencies | |
- name: 🔨 Build and run tests | |
run: | | |
stack test | |
# things to be cached | |
- name: 💾 Cache stack global package db | |
if: always() && steps.stack-global.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
path: ~/.stack | |
key: ${{ steps.stack-global.outputs.cache-primary-key }} | |
- name: 💾 Cache .stack-work | |
if: always() && steps.stack-work.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
path: .stack-work | |
key: ${{ steps.stack-work.outputs.cache-primary-key }} | |
# release (optional) | |
- name: 📦 Compress files | |
id: zip | |
run: | | |
# locate the data-dir | |
datadir=$(find "$(stack path --snapshot-install-root)/share" -type d -name "Agda-*") | |
# locate the executable | |
executable=$(find "$(stack path --local-install-root)/bin" -name "als") | |
# make a temporary directory for compresssing | |
mkdir zip | |
cp -r "$datadir" zip/data | |
cp "$executable" zip/ | |
# compress | |
cd zip | |
zip -r als-ubuntu.zip ./* | |
cd .. | |
mv zip/als-ubuntu.zip . | |
- name: 🚢 Release Artifacts | |
if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload ${{ github.ref_name }} als-ubuntu.zip --clobber |