Skip to content

Fix pipeline tests #654

Fix pipeline tests

Fix pipeline tests #654

Workflow file for this run

name: GHC (build, test, haddock)
# Controls when the workflow will run
on:
push:
branches: [master]
tags: [v*]
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: write # to submit Haddock documentation to GitHub Pages
jobs:
check:
name: "Run static checks"
runs-on: ubuntu-latest
steps:
- name: πŸ“₯ Checkout repository
uses: actions/checkout@v4
with:
submodules: true
ref: ${{ github.ref }}
- uses: haskell-actions/run-fourmolu@v10
with:
version: "0.14.0.0"
pattern: |
eo-phi-normalizer/**/*.hs
!eo-phi-normalizer/src/Language/EO/Phi/Syntax/**/*.hs
!eo-phi-normalizer/Setup.hs
- uses: haskell-actions/hlint-setup@v2
- name: Get hlint-bin
id: get-hlint-bin
run: |
chmod +x scripts/run-hlint.sh
echo "hlint-bin=$(realpath scripts/run-hlint.sh)" >> $GITHUB_OUTPUT
- uses: haskell-actions/hlint-run@v2
with:
hlint-bin: ${{ steps.get-hlint-bin.outputs.hlint-bin }}
tests:
name: Run tests
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-12]
fail-fast: false
env:
syntax-path: "eo-phi-normalizer/src/Language/EO/Phi/Syntax"
steps:
- name: πŸ“₯ Checkout repository
uses: actions/checkout@v4
with:
submodules: true
ref: ${{ github.ref }}
- name: Set codepage on Windows
if: ${{ runner.os == 'Windows' }}
run: chcp 65001
- name: Restore Syntax files
id: restore-syntax-files
uses: actions/cache/restore@v4
with:
key: syntax-files-${{ runner.os }}-${{ hashFiles(format('{0}.cf', env.syntax-path), 'stack.yaml.lock') }}
path: |
${{ env.syntax-path }}/Lex.hs
${{ env.syntax-path }}/Par.hs
- name: Check Syntax files exist
if: steps.restore-syntax-files.outputs.cache-hit == 'true'
shell: bash
id: check-syntax-files
run: |
if [[ -f ${{ env.syntax-path }}/Lex.hs && -f ${{ env.syntax-path }}/Par.hs ]]; then
printf "SYNTAX_FILES_EXIST=true\n" >> $GITHUB_OUTPUT
fi
- name: 🧰 Setup Stack
uses: freckle/stack-action@v5
with:
stack-build-arguments: --pedantic
stack-build-arguments-build: --dry-run
stack-build-arguments-test: --ghc-options -O2 ${{ steps.check-syntax-files.outputs.SYNTAX_FILES_EXIST == 'true' && ' ' || '--reconfigure --force-dirty --ghc-options -fforce-recomp' }}
- name: Save Syntax files
uses: actions/cache/save@v4
if: steps.restore-syntax-files.outputs.cache-hit != 'true'
with:
key: syntax-files-${{ runner.os }}-${{ hashFiles(format('{0}.cf', env.syntax-path), 'stack.yaml.lock') }}
path: |
${{ env.syntax-path }}/Lex.hs
${{ env.syntax-path }}/Par.hs
pipeline:
name: Run pipeline
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-12]
fail-fast: false
env:
syntax-path: "eo-phi-normalizer/src/Language/EO/Phi/Syntax"
permissions:
contents: write
pull-requests: write
steps:
- name: πŸ“₯ Checkout repository
uses: actions/checkout@v4
with:
submodules: true
ref: ${{ github.ref }}
- name: Set codepage on Windows
if: ${{ runner.os == 'Windows' }}
run: chcp 65001
- name: Restore Syntax files
id: restore-syntax-files
uses: actions/cache/restore@v4
with:
key: syntax-files-${{ runner.os }}-${{ hashFiles(format('{0}.cf', env.syntax-path), 'stack.yaml.lock') }}
path: |
${{ env.syntax-path }}/Lex.hs
${{ env.syntax-path }}/Par.hs
- name: Check Syntax files exist
if: steps.restore-syntax-files.outputs.cache-hit == 'true'
shell: bash
id: check-syntax-files
run: |
if [[ -f ${{ env.syntax-path }}/Lex.hs && -f ${{ env.syntax-path }}/Par.hs ]]; then
printf "SYNTAX_FILES_EXIST=true\n" >> $GITHUB_OUTPUT
fi
- name: 🧰 Setup Stack
uses: freckle/stack-action@v5
with:
stack-build-arguments: --pedantic --ghc-options -O2 --copy-bins ${{ steps.check-syntax-files.outputs.SYNTAX_FILES_EXIST == 'true' && ' ' || '--reconfigure --force-dirty --ghc-options -fforce-recomp' }}
test: false
- name: Save Syntax files
uses: actions/cache/save@v4
if: steps.restore-syntax-files.outputs.cache-hit != 'true'
with:
key: syntax-files-${{ runner.os }}-${{ hashFiles(format('{0}.cf', env.syntax-path), 'stack.yaml.lock') }}
path: |
${{ env.syntax-path }}/Lex.hs
${{ env.syntax-path }}/Par.hs
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: 21
# TODO #340:10m switch to chrisdickinson/setup-yq after https://github.com/chrisdickinson/setup-yq/pull/14 is merged
- uses: deemp/setup-yq@latest
with:
yq-version: v4.44.1
yq-url: ${{ format('https://github.com/mikefarah/yq/releases/download/{{version}}/yq_{{platform}}_{{arch}}{0}', runner.os == 'Windows' && '.exe' || '') }}
- name: Check pipeline lock
id: check-pipeline-lock
shell: bash
run: |
source scripts/lib.sh
write_pipeline_lock
printf "Pipeline lock changed: $PIPELINE_LOCK_CHANGED\n"
printf "PIPELINE_LOCK_CHANGED=$PIPELINE_LOCK_CHANGED\n" >> $GITHUB_OUTPUT
printf "PIPELINE_LOCK_FILE_NEW_RELATIVE=$PIPELINE_LOCK_FILE_NEW_RELATIVE" >> $GITHUB_OUTPUT
- name: Restore pipeline files
id: pipeline-files
if: steps.check-pipeline-lock.outputs.PIPELINE_LOCK_CHANGED
uses: actions/cache/restore@v4
with:
key: pipeline-files-${{ runner.os }}-${{ hashFiles(steps.check-pipeline-lock.outputs.PIPELINE_LOCK_FILE_NEW_RELATIVE) }}
path: pipeline
- name: Run pipeline
shell: bash
env:
PIPELINE_LOCK_CHANGED: ${{ (steps.check-pipeline-lock.outputs.PIPELINE_LOCK_CHANGED == 'true') || (steps.pipeline-files.outputs.cache-hit != 'true') }}
NORMALIZER_INSTALLED: "true"
run: ./scripts/pipeline.sh
- name: Save pipeline files
if: steps.check-pipeline-lock.outputs.PIPELINE_LOCK_CHANGED
uses: actions/cache/save@v4
with:
key: pipeline-files-${{ runner.os }}-${{ hashFiles(steps.check-pipeline-lock.outputs.PIPELINE_LOCK_FILE_NEW_RELATIVE) }}
path: pipeline
- name: Configure git
if: always() && runner.os == 'Linux'
env:
# required for gh
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
${{ github.head_ref && format('gh pr checkout {0}', github.event.pull_request.number) || ''}}
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Commit and push changes in pipeline lock
if: always() && runner.os == 'Linux' && steps.check-pipeline-lock.outputs.PIPELINE_LOCK_CHANGED
run: |
source scripts/lib.sh
commit_and_push_if_changed "$PIPELINE_LOCK_FILE_RELATIVE" "$PIPELINE_LOCK_FILE_RELATIVE"
- name: Commit and push changes in normalizer data files
if: always() && runner.os == 'Linux'
run: |
source scripts/lib.sh
data_directory="eo-phi-normalizer/data"
commit_and_push_if_changed "$data_directory" "normalizer data files"
- name: Install mdsh
if: runner.os == 'Linux'
uses: baptiste0928/cargo-install@v3.1.0
with:
crate: mdsh
git: https://github.com/zimbatm/mdsh
branch: main
- name: Update Markdown files
if: runner.os == 'Linux'
run: ./scripts/update-markdown.sh
- name: Commit and push changes in Markdown files
if: runner.os == 'Linux'
run: |
source scripts/lib.sh
files="site proposals README.md"
commit_and_push_if_changed "$files" "Markdown files"
- name: Upload pipeline artifact
id: pipeline-artifact
if: always()
uses: actions/upload-artifact@v4
with:
# we can't have multiple artifact versions
# because we need to restore the most recent version in the docs job
#
# we can't use caches because we can't overwrite them
name: pipeline-files-${{ runner.os }}
overwrite: true
path: |
pipeline
!pipeline/**/.eoc
!pipeline/yaml
pipeline/phi/.eoc/4-pull/org
pipeline/phi/.eoc/phi/org
pipeline/phi/.eoc/print/org
report
- name: Write about the artifact in the job summary
if: always()
shell: bash
run: |
cat << EOF >> $GITHUB_STEP_SUMMARY
<h2>Artifact</h2>
<p>
The
<a href="${{ steps.pipeline-artifact.outputs.artifact-url }}">
artifact
</a> contains files used or produced during the pipeline run:
</p>
<ul>
<li>EO and PHI programs</li>
<li>Reports</li>
</ul>
EOF
- name: Write the report in the job summary
shell: bash
run: |
cat << EOF >> $GITHUB_STEP_SUMMARY
<h2>Report</h2>
<details>
<summary>Click to expand</summary>
$(cat report/report.md)
</details>
EOF
docs:
needs: [pipeline, tests]
if: ${{ github.ref_name == 'master' }}
name: "Build and upload site (master)"
runs-on: ubuntu-latest
steps:
- name: πŸ“₯ Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: 🧰 Setup Stack
uses: freckle/stack-action@v5
with:
test: false
stack-build-arguments: --fast --haddock
cache-prefix: docs-
- name: Download pipeline artifact
uses: actions/download-artifact@v4
with:
pattern: pipeline-files-${{ runner.os }}
merge-multiple: true
- name: Setup mdBook
uses: jontze/action-mdbook@v3
with:
token: ${{secrets.GITHUB_TOKEN}}
mdbook-version: "~0.4.37"
use-linkcheck: true
- name: Add haddock
run: |
mkdir -p dist/haddock
mv $(stack path --local-doc-root)/* dist/haddock
- name: Add docs
run: |
cd site/docs
mdbook build
mv docs/html ../../dist/docs
- name: Add report
run: |
mkdir -p dist/report
cp report/report.html dist/report/index.html
- name: Add index.html
run: mv site/index.html dist
- name: πŸš€ Publish Site
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
folder: dist
single-commit: true