haskell-gha-1.0: tests/golden/config/expected.yaml
# Do not edit this file, it was generated by the following command:
# haskell-gha --generate --config haskell-gha.conf.yaml
#
# To regenerate it, run from the root of the repository:
# haskell-gha
#
# For more information, see https://github.com/arybczak/haskell-gha
name: Postgres CI
on:
push:
branches:
- master
- release/**
pull_request:
merge_group:
workflow_dispatch:
# The test reporter writes check runs.
permissions:
contents: read
# For the annotations of the test results.
checks: write
concurrency:
group: ${{ github.workflow_ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
fourmolu:
name: Fourmolu
runs-on:
group: small
labels:
- self-hosted
- linux
timeout-minutes: 90
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: haskell-actions/run-fourmolu@v12
with:
version: '0.19.0.1'
pattern: |
src/**/*.hs
!src/Generated.hs
hlint:
name: HLint
# HLint needs no large runner.
runs-on: ubuntu-slim
timeout-minutes: 90
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: haskell-actions/hlint-setup@v2
with:
version: '3.8'
- uses: haskell-actions/hlint-run@v2
with:
path: '["src", "test"]'
fail-on: error
build:
name: 'GHC ${{ matrix.ghc }}, ${{ matrix.dependencies }}, postgres ${{ matrix.postgres }}'
runs-on: ubuntu-24.04
timeout-minutes: 90
# The services of each build job.
services:
# The database for the tests.
postgres:
image: postgres:${{ matrix.postgres }}
env:
POSTGRES_PASSWORD: postgres # Only for CI.
ports:
- '5432:5432'
# The runner starts the steps when the database accepts connections.
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-retries 10
strategy:
fail-fast: false
# The oldest and the newest supported Postgres.
matrix:
ghc:
- '9.10'
- '9.12'
dependencies:
- newest
- oldest
postgres:
- '15'
- '18'
exclude:
- ghc: '9.10'
postgres: '15'
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
submodules: recursive
- name: Install the system packages
run: |
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libpq-dev postgresql-client
- name: Install GHC and cabal
id: setup
run: |
mkdir -p "$RUNNER_TEMP"/.ghcup/bin
curl -fsSL -o "$RUNNER_TEMP"/.ghcup/bin/ghcup "https://downloads.haskell.org/ghcup/$(uname -m)-linux-ghcup"
chmod +x "$RUNNER_TEMP"/.ghcup/bin/ghcup
export GHCUP_INSTALL_BASE_PREFIX="$RUNNER_TEMP" PATH="$RUNNER_TEMP/.ghcup/bin:$PATH"
echo "GHCUP_INSTALL_BASE_PREFIX=$RUNNER_TEMP" >> "$GITHUB_ENV"
echo "$RUNNER_TEMP/.ghcup/bin" >> "$GITHUB_PATH"
versions=$(ghcup -s vanilla list -t ghc -r)
if grep -qF -e 'ghc ${{ matrix.ghc }} ' -e 'ghc ${{ matrix.ghc }}.' <<< "$versions"; then
channel=vanilla
else
echo 'The vanilla channel of GHCup has no GHC ${{ matrix.ghc }}, so the step uses the prerelease channel.'
channel=prereleases
fi
ghcup -s "$channel" install ghc '${{ matrix.ghc }}' --set
ghcup -s vanilla install cabal 3.18.1.0 --set
cabal update
echo "ghc-version=$(ghc --numeric-version)" >> "$GITHUB_OUTPUT"
echo "cabal-version=$(cabal --numeric-version)" >> "$GITHUB_OUTPUT"
echo "cabal-store=$(cabal path -z --store-dir)" >> "$GITHUB_OUTPUT"
- name: Show the versions
id: versions
run: |
ghc --version
cabal --version
echo "GHC ${{ steps.setup.outputs.ghc-version }}, cabal ${{ steps.setup.outputs.cabal-version }}, image $ImageOS $ImageVersion" >> "$GITHUB_STEP_SUMMARY"
echo "image=$ImageOS" >> "$GITHUB_OUTPUT"
- name: Show the Postgres version
run: psql --version
- name: Unpack the source tarballs
run: |
shopt -s extglob
cabal sdist all --output-directory="$RUNNER_TEMP"/haskell-gha-sdist
mkdir "$RUNNER_TEMP"/haskell-gha
for f in cabal.project cabal.project.freeze cabal.project.local; do
if [ -f "$f" ]; then cp "$f" "$RUNNER_TEMP"/haskell-gha; fi
done
tar -xzf "$RUNNER_TEMP"/haskell-gha-sdist/config-+([0-9.]).tar.gz --strip-components=1 -C "$RUNNER_TEMP"/haskell-gha
- name: Configure the project
working-directory: ${{ runner.temp }}/haskell-gha
run: |
if [ -f cabal.project.local ]; then
echo '::error::The repository contains cabal.project.local, which holds the settings of one developer. Move the settings to cabal.project or to the key cabal-project-local of the configuration of haskell-gha, and remove the file from the repository.'
exit 1
fi
cat >> cabal.project.local <<'EOF'
jobs: 2
program-options
ghc-options: -Werror -Wno-unused-imports
package config
flags: +postgres
constraints: postgresql-libpq >= 0.10
EOF
- name: Prefer the oldest dependencies
if: matrix.dependencies == 'oldest'
working-directory: ${{ runner.temp }}/haskell-gha
run: |
echo 'prefer-oldest: True' >> cabal.project.local
- name: Enable the GHC job semaphore or parallel module builds
working-directory: ${{ runner.temp }}/haskell-gha
run: |
if ghc --info | grep -F '("Semaphore version","2")' > /dev/null; then
echo 'GHC and cabal use version 2 of the semaphore protocol, so GHC uses the semaphore.'
cat >> cabal.project.local <<'EOF'
semaphore: True
EOF
else
echo 'GHC uses version 1 of the semaphore protocol and cabal version 2, so GHC uses -j2.'
cat >> cabal.project.local <<'EOF'
program-options
ghc-options: -j2
EOF
fi
- name: Make the build plan
id: plan
working-directory: ${{ runner.temp }}/haskell-gha
run: |
cabal build all --dry-run
echo "hash=$(sha256sum dist-newstyle/cache/plan.json | cut -d ' ' -f 1)" >> "$GITHUB_OUTPUT"
- uses: runs-on/cache/restore@v4
id: cache
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: haskell-gha.yaml-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.versions.outputs.image }}-ghc-${{ steps.setup.outputs.ghc-version }}-${{ matrix.dependencies }}-${{ steps.plan.outputs.hash }}
restore-keys: haskell-gha.yaml-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.versions.outputs.image }}-ghc-${{ steps.setup.outputs.ghc-version }}-${{ matrix.dependencies }}-
- name: Build the dependencies
working-directory: ${{ runner.temp }}/haskell-gha
run: |
cabal build all --only-dependencies
- uses: runs-on/cache/save@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: Build
working-directory: ${{ runner.temp }}/haskell-gha
run: |
cabal build all
# A check that the build made the programs.
- name: Show the executables
run: cabal list-bin all
- name: Check the packages
working-directory: ${{ runner.temp }}/haskell-gha
run: |
failed=0
check() {
echo "Checking the package $1"
(cd "$2" && cabal check) || { echo "::error::cabal check failed for the package $1"; failed=1; }
}
check config .
exit "$failed"
- name: Build the documentation
working-directory: ${{ runner.temp }}/haskell-gha
run: |
cabal haddock all --disable-documentation --haddock-for-hackage