Skip to content

CI

CI #1557

Workflow file for this run

---
name: CI
on: [push, workflow_dispatch]
jobs:
tests:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
# - "3.12"
# Service containers to run
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history
- name: Apt update
run: sudo apt-get update
- name: Apt install
run: sudo apt-get install -y libxmlsec1-dev
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Pin python-version ${{ matrix.python-version }}
run: uv python pin ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync
- name: Tests
run: uv run pytest
- name: Changelog
if: ${{ !contains(github.event.head_commit.author, 'renovate') }}
run: PYTHONPATH=build-support/bin uv run build changelog check
# - name: Upload coverage to CodeCov
# uses: codecov/codecov-action@v1
# with:
# directory: ${{ matrix.app-name }}/coverage/
# flags: ${{ matrix.app-name }}
release:
needs: tests
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
# extract the app name out of the tag's ref value
- id: get-app-name
uses: actions/github-script@v7
with:
script: |
const appName = context.ref.match(/refs\/tags\/([a-z\-]+)\/v\S+$/)[1]
core.setOutput('app-name', appName)
core.setOutput('app-package', appName.replace("mitol-django-", "").replace(/-/g, "_"))
- name: Build
run: PYTHONPATH=build-support/bin uv build "src/${{steps.get-app-name.outputs.app-package}}"
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}