build #278
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
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '23 14 * * 2' | |
release: | |
name: build | |
jobs: | |
lint: | |
name: "Run hlint" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up HLint | |
uses: haskell-actions/hlint-setup@v2 | |
- name: Run HLint | |
uses: haskell-actions/hlint-run@v2 | |
with: | |
fail-on: warning | |
fourmolu: | |
name: "Run fourmolu" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: haskell-actions/run-fourmolu@v11 | |
with: | |
version: "0.14.0.0" | |
generateMatrix: | |
name: "Generate matrix from cabal" | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout base repo | |
uses: actions/checkout@v4 | |
- name: Extract the tested GHC versions | |
id: set-matrix | |
run: | | |
wget https://github.com/Kleidukos/get-tested/releases/download/v0.1.5.0/get-tested-0.1.5.0-linux-amd64 -O get-tested | |
chmod +x get-tested | |
./get-tested --ubuntu rhine-koans.cabal >> $GITHUB_OUTPUT | |
build-cabal: | |
runs-on: ubuntu-latest | |
needs: generateMatrix | |
strategy: | |
matrix: ${{ fromJSON(needs.generateMatrix.outputs.matrix) }} | |
name: Haskell GHC ${{ matrix.ghc }} cabal | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: haskell-actions/setup@v2 | |
id: setup | |
with: | |
ghc-version: ${{ matrix.ghc }} | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev | |
- name: Configure the build | |
run: | | |
cabal configure --enable-tests --enable-benchmarks --disable-documentation | |
cabal build all --dry-run | |
# The last step generates dist-newstyle/cache/plan.json for the cache key. | |
- name: Restore cached dependencies | |
uses: actions/cache/restore@v4 | |
id: cache | |
env: | |
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} | |
with: | |
path: ${{ steps.setup.outputs.cabal-store }} | |
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} | |
restore-keys: | | |
${{ env.key }}- | |
- name: Install dependencies | |
# If we had an exact cache hit, the dependencies will be up to date. | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: cabal build all --only-dependencies | |
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail. | |
- name: Save cached dependencies | |
uses: actions/cache/save@v4 | |
# If we had an exact cache hit, trying to save the cache would error because of key clash. | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
path: ${{ steps.setup.outputs.cabal-store }} | |
key: ${{ steps.cache.outputs.cache-primary-key }} | |
- name: Cabal build dependencies | |
run: cabal build all --enable-tests --only-dependencies | |
- name: Cabal build solutions | |
run: cabal build all --enable-tests -fdev -fsolution | |
- name: Cabal test solutions | |
run: cabal test all --enable-tests --test-show-details=Always -fsolution | |
build-flake: | |
name: Nix Flake | |
runs-on: | |
- ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Free disk space | |
run: | | |
sudo rm -rf /usr/local/* /usr/share/* /opt/* | |
docker rmi $(docker image ls -aq) | |
- uses: cachix/install-nix-action@v30 | |
- uses: DeterminateSystems/magic-nix-cache-action@v8 | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: rhine-koans | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- name: Check whether .nix files are formatted | |
run: | | |
nix fmt | |
git diff --exit-code | |
- name: Build executables | |
run: nix build .#rhine-koans-all --accept-flake-config | |
- name: Run tests | |
run: | | |
nix develop --accept-flake-config -c cabal update | |
nix develop --accept-flake-config -c cabal test all -fsolution | |
presentation: | |
name: Build presentation | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v30 | |
- uses: DeterminateSystems/magic-nix-cache-action@v8 | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: rhine-koans | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- name: Build presentation | |
run: nix build --accept-flake-config | |
- name: Install pdftotext | |
run: nix profile install nixpkgs#poppler_utils | |
- name: Compare presentation to checked in version | |
run: diff <(pdftotext -layout presentation/presentation.pdf /dev/stdout) <(pdftotext -layout result/presentation.pdf /dev/stdout) | |
diffs: | |
name: Check whether diffs between solution and problem have changed | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check diffs | |
run: ./check_diffs.sh | |
success: | |
name: All GHCs built successfully | |
runs-on: ubuntu-latest | |
needs: | |
- build-cabal | |
- build-flake | |
steps: | |
- name: Success | |
run: echo "Success" |