Skip to content

CI

CI #231

Workflow file for this run

# SPDX-FileCopyrightText: 2020 Kowainik
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io/>
#
# SPDX-License-Identifier: MPL-2.0
# Sources:
# • https://github.com/kowainik/validation-selective/blob/5b46cd4810bbaa09b704062ebbfa2bb47137425d/.github/workflows/ci.yml
# • https://kodimensional.dev/github-actions
# • https://github.com/serokell/tztime/blob/main/.github/workflows/ci.yml
name: CI
# Trigger the workflow on push or pull request
on:
pull_request:
push:
branches:
- master
schedule:
- cron: '5 4 * * 6'
jobs:
xrefcheck:
if: ${{ github.event_name != 'schedule' }}
name: Verify cross references
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: serokell/xrefcheck-action@v1
with:
xrefcheck-version: '0.2.2'
reuse:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
hlint:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/hlint-setup@v2
with:
version: '3.5'
- uses: haskell-actions/hlint-run@v2
with:
path: '["src/", "test/"]'
fail-on: warning
stylish:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache binaries
id: cache-stylish
uses: actions/cache@v3
with:
path: ~/.local/bin
key: bin-stylish
- name: Setup
if: steps.cache-stylish.outputs.cache-hit != 'true'
run: |
mkdir -p "$HOME/.local/bin"
wget https://github.com/haskell/stylish-haskell/releases/download/v0.14.3.0/stylish-haskell-v0.14.3.0-linux-x86_64.tar.gz
tar -zxf stylish-haskell-v0.14.3.0-linux-x86_64.tar.gz \
--strip-components 1 \
-C "$HOME/.local/bin" \
stylish-haskell-v0.14.3.0-linux-x86_64/stylish-haskell
chmod +x "$HOME/.local/bin"/stylish-haskell
- name: Stylish Haskell
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
./scripts/validate-stylish.sh
whitespace:
if: ${{ github.event_name != 'schedule' }}
name: Find Trailing Whitespace
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: harupy/[email protected]
cabal:
if: ${{ github.event_name != 'schedule' }}
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
runs-on: ${{ matrix.os }}
needs: collect-ghc-versions
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
cabal: ["3.8"]
ghc: ${{ fromJSON(needs.collect-ghc-versions.outputs.ghcvers) }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: haskell-actions/setup@v2
id: setup-haskell-cabal
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- uses: actions/cache@v3
name: Cache cabal-store
with:
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal
- name: Configure
shell: bash
run: |
cat > cabal.project <<EOF
packages:
./
package hsblst
ghc-options: -Werror
EOF
- name: Build
run: |
cabal update
cabal build --enable-tests --enable-benchmarks --write-ghc-environment-files=always
- name: Test
run: |
cabal test all --enable-tests
- name: Haddock
# Run haddock for all components
run: |
cabal haddock --haddock-all
- name: Install
# Check the package actually builds from sdist
run: |
cabal install --lib
collect-ghc-versions:
if: ${{ github.event_name != 'schedule' }}
name: Extract GHC versions from tested-with package.yaml field.
runs-on: ubuntu-latest
outputs:
ghcvers: ${{ steps.ghcvers.outputs.ghcvers }}
steps:
- uses: actions/checkout@v4
- id: ghcvers
run: |
echo -n "ghcvers=" >> "$GITHUB_OUTPUT"
yq -I0 '."tested-with" | map(sub("^GHC *== *";""))' package.yaml -o json >> "$GITHUB_OUTPUT"
stack:
name: stack / ${{ matrix.resolver }}
runs-on: ubuntu-latest
strategy:
matrix:
stack: ["latest"]
# Remember to update the `tested-with` section of `package.yaml`.
resolver: ["lts", "nightly"]
steps:
- name: Get compiler version
id: ghcver
run: |
GHCVER=$(curl -L https://www.stackage.org/${{ matrix.resolver }}/ghc-major-version)
echo "ghcver=$GHCVER" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Check tested-with contains current GHC version
run: |
export GHCVER=${{ steps.ghcver.outputs.ghcver }}
yq -e '."tested-with" | contains(["GHC == " + strenv(GHCVER)])' package.yaml
- uses: haskell-actions/setup@v2
name: Setup Haskell Stack
id: setup-haskell
with:
ghc-version: ${{ steps.ghcver.outputs.ghcver }}
stack-version: ${{ matrix.stack }}
- uses: actions/cache@v3
name: Cache ~/.stack and cabal store
with:
path: |
~/.stack
${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-${{ steps.ghcver.outputs.ghcver }}-stack
- name: Set stack config
run: |
stack config set system-ghc --global true
stack config set install-ghc --global false
# this is a dirty hack because using short resolver name gets an old
# resolver for some reason
RESOLVER=$(curl -w '%{redirect_url}' https://www.stackage.org/${{ matrix.resolver }} | sed 's!.*/!!')
stack config set resolver $RESOLVER
- name: Configure for Weeder
run: |
echo 'ghc-options: { "$locals": -fwrite-ide-info }' >> stack.yaml
- name: Stack build
run: |
stack build \
--test --bench --no-run-tests --no-run-benchmarks \
--ghc-options '-Werror' \
--haddock --no-haddock-deps
- name: Weeder for GHC 9.6
if: ${{ startsWith(steps.ghcver.outputs.ghcver, '9.6') }}
run: |
cabal install --installdir "$PWD" weeder
./weeder --hie-directory ./.stack-work/dist/
- name: Stack test
run: |
stack test
- name: Notify on scheduled failures
if: ${{ failure() && github.event_name == 'schedule' }}
run: |
curl -XPOST https://slack.com/api/chat.postMessage \
-H "Authorization: Bearer ${{ secrets.SLACK_TOKEN }}" \
-d "channel=libraries" \
-d "text=Scheduled job failed on hsblst with resolver ${{ matrix.resolver }} ghc ${{ steps.ghcver.outputs.ghcver }}"
validate-cabal-files:
if: ${{ github.event_name != 'schedule' }}
name: Validate cabal files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Get hpack
run: |
wget https://github.com/lierdakil/hpack-static/releases/download/v0.34.4/hpack.gz
gunzip hpack.gz
chmod +x hpack
- name: Generate cabalfile
run: ./hpack -f
- run: git diff hsblst.cabal
- name: Fail if .cabal file was changed
run: git diff-files --quiet hsblst.cabal || exit 1