Feature/2244 parallel migrations #2401
Workflow file for this run
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: | |
EMAIL_RATE_LIMIT: 3600 | |
MATCHER_MAX_CAPACITY: 80 | |
MYSQL_DATABASE: test_econ | |
MYSQL_ROOT_PASSWORD: password | |
services: | |
database-root: | |
image: mariadb:10.6 | |
env: | |
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }} | |
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }} | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
database-tenant: | |
image: mariadb:10.6 | |
env: | |
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }} | |
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }} | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: add commit SHA for non-production builds | |
if: github.ref_type != 'tag' | |
run: | | |
CURRENT_VERSION=$(grep -oP 'let to_string = "\K[^"]+' ./pool/version/version.ml) | |
GIT_SHA=$(git rev-parse --short HEAD) | |
sed -i "s/^let to_string = \".*\"/let to_string = \"${CURRENT_VERSION}-${GIT_SHA}\"/" ./pool/version/version.ml | |
- name: Build and test with Docker | |
uses: addnab/docker-run-action@v3 | |
env: | |
DATABASE_URL: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@database-root:3306/${{ env.MYSQL_DATABASE }} | |
DATABASE_URL_TENANT_ONE: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@database-tenant:3306/${{ env.MYSQL_DATABASE }} | |
SIHL_ENV: test | |
SMTP_SENDER: [email protected] | |
TEST_EMAIL: [email protected] | |
with: | |
image: ocaml/opam:debian-10-ocaml-4.14 | |
options: -v ${{ github.workspace }}:/app -w /app -e DATABASE_URL -e DATABASE_URL_TENANT_ONE -e TEST_EMAIL -e SMTP_SENDER -e SIHL_ENV -e EMAIL_RATE_LIMIT -e MATCHER_MAX_CAPACITY | |
run: | | |
# Reclaim required directory permissions | |
sudo chown -R opam . | |
# Build and test executable | |
/app/scripts/build.sh || exit 1 | |
# Restore directory permissions to avoid conflicts | |
sudo chown -R 1001:123 . | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: run.exe | |
path: _build/default/pool/run/run.exe | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: tests | |
path: _build/default/pool/test/ | |
- name: Notify about failure | |
if: failure() | |
uses: ./.github/actions/notify-failure | |
with: | |
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }} | |
assets: | |
name: Build assets | |
if: github.repository == 'uzh/z-pool-tool' | |
runs-on: ubuntu-latest | |
container: | |
image: node:lts | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: install yarn packages | |
run: yarn install | |
- name: build yarn package | |
run: yarn build | |
- name: move all assets to one folder | |
run: '[ "$(ls pool/public)" ] && cp -r pool/public/* public || exit 0' | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: assets | |
path: public | |
- name: Notify about failure | |
if: failure() | |
uses: ./.github/actions/notify-failure | |
with: | |
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }} | |
deploy_staging: | |
name: Trigger staging deploy | |
runs-on: ubuntu-latest | |
needs: [build, assets] | |
if: github.ref_name == 'main' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Trigger deploy | |
uses: ./.github/actions/trigger-deploy | |
with: | |
url: ${{ secrets.ECON_DEPLOY_TRIGGER_URL }} | |
token: ${{ secrets.ECON_DEPLOY_TRIGGER_TOKEN }} | |
release: | |
name: Release a new version | |
runs-on: ubuntu-latest | |
needs: [build, assets] | |
if: github.ref_type == 'tag' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v4 | |
- name: Extract version changelog | |
run: sed -nr "/^## .?v?${GITHUB_REF_NAME}/,/^## /p" CHANGELOG.md | sed '1d;2d;$d' > changes.md | |
- name: Compress assets | |
run: | | |
tar -zcf assets.tar.gz assets | |
tar -zcf executable.tar.gz run.exe/run.exe | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body_path: changes.md | |
files: | | |
assets.tar.gz | |
executable.tar.gz | |
- name: Notify about failure | |
if: failure() | |
uses: ./.github/actions/notify-failure | |
with: | |
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }} | |
deploy_production: | |
name: Trigger production deploy | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Trigger deploy | |
uses: ./.github/actions/trigger-deploy | |
with: | |
url: ${{ secrets.ECON_DEPLOY_TRIGGER_URL }} | |
token: ${{ secrets.ECON_DEPLOY_TRIGGER_TOKEN }} | |
target: production |