Skip to content

Updating GitHub actions [13] #101

Updating GitHub actions [13]

Updating GitHub actions [13] #101

################################################################################
### GitHub Actions curation providing quality assurance for Haskell projects
###
name: 'PHANE Integration Test CI'
################################################################################
### Actions Configuration
###
defaults:
run:
shell: bash
env:
PROJECTFILE: --project-file=config/cabal.project.integration
# TESTDETAILS: --test-show-details=streaming
TESTOPTIONS: --subset-rapid
# TESTOPTIONS: --test-options="--timeout=30s"
THISMAINEXE: :pkg:PhyG:exe:phyg
THISTESTEXE: :pkg:PhyG-integration-tests:exe:PhyG-Integration-Tests
on:
# Build every pull request, to check for regressions.
pull_request:
branches: [ main ]
# Build on branch updates
push:
branches: [ main, github-ci ]
# INFO: The following configuration block ensures that only one build runs per branch,
# which may be desirable for projects with a costly build process.
# Remove this block from the CI workflow to let each CI job run to completion.
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
################################################################################
### Actions: Curation
###
jobs:
################################################################################
### Check that all test cases pass
###
testing:
# NOTE:
# Do *not* include macOS in *any* benchmarking/testing build matrix!
# Only include macOS in build matrices checking for compilation success.
# - macOS consumes x10 the free Linux CI minutes
# - macOS bills at x10 the paid Linux CI minute rate
#
name: 'Test: Integration'
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: 'Clone Project'
uses: actions/checkout@v4
- name: 'Setup Haskell'
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: 9.10.1
cabal-version: 3.12
cabal-update: true
- name: 'Cabal - Configure'
run: |
cabal update ${PROJECTFILE}
cabal clean ${PROJECTFILE}
cabal freeze ${PROJECTFILE}
cabal configure ${PROJECTFILE} --enable-tests --enable-benchmarks --disable-documentation
cabal install ${THISMAINEXE} ${THISTESTEXE} ${PROJECTFILE} --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.
- name: 'Cabal - Cache [1]'
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: 'Cabal - 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 ${THISMAINEXE} ${THISTESTEXE} ${PROJECTFILE} --only-dependencies
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
- name: 'Cabal - Cache [2]'
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'
run: |
cabal install ${THISMAINEXE} ${PROJECTFILE}
cabal build ${THISTESTEXE} ${PROJECTFILE}
- name: 'When Failed - Rerun build to minimize output'
if: ${{ failure() }}
run: |
cabal install ${THISMAINEXE} ${PROJECTFILE}
cabal build ${THISTESTEXE} ${PROJECTFILE}
- name: 'Cabal - Integration Tests'
run: |
cabal run ${THISTESTEXE} ${PROJECTFILE} -- ${TESTOPTIONS} # ${TESTDETAILS}
# - name: 'When Failed - Send Notification Email'
# if: ${{ failure() }}
# uses: dawidd6/action-send-mail@v3
# with:
# # Mail server settings
# ignore_cert: true
# secure: true
# server_address: smtp.domain.com
# server_port: 465
#
# # Sender credentials
# username: ${{ secrets.EMAIL_USERNAME }}
# password: ${{ secrets.EMAIL_PASSWORD }}
#
# # Recipient & email information
# to: [email protected]
# cc: [email protected]
# from: PHANE ρbit
# subject: "PHANE CI Failure: Integration Test-suite - job ${{ github.job }}"
# body: "The continuous integration performed by GitHub Workflows has failed!\n\nInspect job ${{ github.job.name }} numbered ${{ github.job }} at:\n\n https://github.com/${{ github.repository }}actions.\n\n\nVigilantly,\n ~ PHANE ρbit"