Feature/maintenance 2502 (#21) #130
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
name: CI | |
on: | |
pull_request: | |
push: | |
branches: main | |
tags: ["**"] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build and test | |
runs-on: ubuntu-latest | |
env: | |
MYSQL_DATABASE: test | |
MYSQL_ROOT_PASSWORD: password | |
services: | |
database: | |
image: mariadb:10.6 | |
env: | |
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }} | |
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }} | |
ports: ['3306:3306'] | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
strategy: | |
fail-fast: false | |
matrix: | |
ocaml-compiler: | |
- 4.14 | |
- 5.2 | |
- 5.3 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Retrieve opam cache | |
uses: actions/cache@v4 | |
if: runner.os != 'Windows' | |
id: cache-opam | |
with: | |
path: ~/.opam | |
key: v1-${{ runner.os }}-opam-${{ matrix.ocaml-compiler }}-${{ hashFiles('*.opam.locked') }} | |
- name: Use OCaml ${{ matrix.ocaml-version }} | |
uses: ocaml/setup-ocaml@v3 | |
with: | |
ocaml-compiler: ${{ matrix.ocaml-compiler }} | |
dune-cache: true | |
opam-pin: true | |
- name: Install system dependencies | |
run: sudo apt-get update -y && sudo apt-get install -y libmariadb-dev | |
- name: Install dependencies | |
run: opam install --deps-only --with-test --with-doc -y . | |
- name: Recover from an Opam broken state | |
if: steps.cache-opam.outputs.cache-hit == 'true' | |
run: | | |
opam install -y dune | |
opam upgrade --fixup | |
- name: Build | |
run: | | |
make build | |
- name: Check formatting | |
run: | | |
opam install -y ocamlformat | |
make format | |
- name: Run tests | |
env: | |
DATABASE_URL: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@127.0.0.1:3306/${{ env.MYSQL_DATABASE }} | |
run: make test | |
- name: Build documentation | |
run: | | |
make doc | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: documentation-${{ matrix.ocaml-compiler }} | |
path: _build/default/_doc/_html | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: tests-${{ matrix.ocaml-compiler }} | |
path: _build/default/test/_build/_tests/ | |
- name: Notify about failure | |
if: failure() | |
uses: ./.github/actions/notify-failure | |
with: | |
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }} | |
deploy-doc: | |
name: Deploy documentation | |
runs-on: ubuntu-latest | |
needs: [build] | |
if: github.ref_name == 'main' | |
environment: | |
name: github-pages | |
url: ${{ steps.deploy-doc.outputs.page_url }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v4 | |
- name: Deploy odoc to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ github.token }} | |
publish_dir: documentation | |
- name: Notify about failure | |
if: failure() | |
uses: ./.github/actions/notify-failure | |
with: | |
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }} | |
release: | |
name: Release a new version | |
runs-on: ubuntu-latest | |
if: github.ref_type == 'tag' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Extract version changelog | |
run: sed -nr "/^## .?v?${GITHUB_REF_NAME}/,/^## /p" CHANGELOG.md | sed '1d;2d;$d' > changes.md | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body_path: changes.md | |
- name: Notify about failure | |
if: failure() | |
uses: ./.github/actions/notify-failure | |
with: | |
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }} |