Skip to content

Merge pull request #1040 from Fuitad/main #1370

Merge pull request #1040 from Fuitad/main

Merge pull request #1040 from Fuitad/main #1370

Workflow file for this run

---
name: Zou CI
on:
push:
branches: [main]
tags: ["*"]
pull_request:
env:
PYTHON_REF: "3.12"
PG_REF: "18"
PYTHON_VERSIONS: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
PG_VERSIONS: '["12", "14", "15", "16", "17", "18"]'
INDEXER_KEY: testkey0123456789
PGPASSWORD: mysecretpassword
jobs:
setup:
name: Build test matrices 🔧
runs-on: ubuntu-latest
outputs:
full-matrix: ${{ steps.matrix.outputs.full }}
steps:
- name: Generate matrices
id: matrix
run: |
python3 -c "
import json, os
py_ref = os.environ['PYTHON_REF']
pg_ref = os.environ['PG_REF']
py_all = json.loads(os.environ['PYTHON_VERSIONS'])
pg_all = json.loads(os.environ['PG_VERSIONS'])
full = []
for py in py_all:
full.append({'python-version': py, 'pg-version': pg_ref})
for pg in pg_all:
if pg != pg_ref:
full.append({'python-version': py_ref, 'pg-version': pg})
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(f'full={json.dumps({\"include\": full})}\n')
"
# --- PR and main: full matrix ---
test:
name: >-
Test Python ${{ matrix.python-version }} / PG ${{ matrix.pg-version }} 🐍
needs: setup
if: "!startsWith(github.ref, 'refs/tags')"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.setup.outputs.full-matrix) }}
services:
postgres:
image: "postgres:${{ matrix.pg-version }}"
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: ${{ env.PGPASSWORD }}
meilisearch:
image: getmeili/meilisearch:v1.1
ports:
- 7700:7700
env:
MEILI_MASTER_KEY: ${{ env.INDEXER_KEY }}
steps:
- uses: actions/checkout@v6
- name: Cache APT packages
uses: actions/cache@v4
id: apt-cache
with:
path: ~/apt-cache
key: apt-ffmpeg-${{ runner.os }}
- name: Install ffmpeg
run: |
if [ -d ~/apt-cache ] && ls ~/apt-cache/*.deb 1>/dev/null 2>&1; then
sudo dpkg -i ~/apt-cache/*.deb 2>/dev/null || (sudo apt-get update -qq && sudo apt-get install -y -f --no-install-recommends)
else
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends ffmpeg
sudo apt-get autoclean -y
mkdir -p ~/apt-cache
cp /var/cache/apt/archives/ffmpeg*.deb ~/apt-cache/ 2>/dev/null || true
cp /var/cache/apt/archives/libav*.deb ~/apt-cache/ 2>/dev/null || true
cp /var/cache/apt/archives/libsw*.deb ~/apt-cache/ 2>/dev/null || true
cp /var/cache/apt/archives/libpostproc*.deb ~/apt-cache/ 2>/dev/null || true
fi
- name: Set up Python 🐍
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Upgrade pip 📦
run: >-
pip install --upgrade pip setuptools
- name: Install packages 📦
run: >-
pip install -r requirements.txt
- name: Create database 🗄
run: >-
psql -c 'create database zoudb;' -U postgres -h 127.0.0.1
- name: Run tests 🧪
run: >-
py.test
env:
DEBUG: 1
MAIL_DEBUG_BODY: 1
MAIL_ENABLED: False
publish-test:
name: Publish to TestPyPI 📦
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
id-token: write
environment: testpypi
steps:
- uses: actions/checkout@v6
- name: Set up Python 🐍
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Append short commit hash to version
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
DEV_NUM=$(printf '%d' "0x${SHORT_SHA}")
sed -i "s/^__version__ = \"\\(.*\\)\"/__version__ = \"\\1.dev${DEV_NUM}\"/" zou/__init__.py
grep __version__ zou/__init__.py
- name: Install pypa/build
run: >-
python3 -m pip install build --user
- name: Build a binary wheel 🏗️
run: >-
python3 -m build
- name: Publish to TestPyPI 📦
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# --- Tag pipeline: gate test → publish ---
gate-test:
name: Gate test Python 3.12 / PG 18 🐍
needs: setup
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
services:
postgres:
image: "postgres:18"
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: ${{ env.PGPASSWORD }}
meilisearch:
image: getmeili/meilisearch:v1.1
ports:
- 7700:7700
env:
MEILI_MASTER_KEY: ${{ env.INDEXER_KEY }}
steps:
- uses: actions/checkout@v6
- name: Cache APT packages
uses: actions/cache@v4
id: apt-cache
with:
path: ~/apt-cache
key: apt-ffmpeg-${{ runner.os }}
- name: Install ffmpeg
run: |
if [ -d ~/apt-cache ] && ls ~/apt-cache/*.deb 1>/dev/null 2>&1; then
sudo dpkg -i ~/apt-cache/*.deb 2>/dev/null || (sudo apt-get update -qq && sudo apt-get install -y -f --no-install-recommends)
else
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends ffmpeg
sudo apt-get autoclean -y
mkdir -p ~/apt-cache
cp /var/cache/apt/archives/ffmpeg*.deb ~/apt-cache/ 2>/dev/null || true
cp /var/cache/apt/archives/libav*.deb ~/apt-cache/ 2>/dev/null || true
cp /var/cache/apt/archives/libsw*.deb ~/apt-cache/ 2>/dev/null || true
cp /var/cache/apt/archives/libpostproc*.deb ~/apt-cache/ 2>/dev/null || true
fi
- name: Set up Python 🐍
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_REF }}
cache: pip
- name: Upgrade pip 📦
run: >-
pip install --upgrade pip setuptools
- name: Install packages 📦
run: >-
pip install -r requirements.txt
- name: Create database 🗄
run: >-
psql -c 'create database zoudb;' -U postgres -h 127.0.0.1
- name: Run tests 🧪
run: >-
py.test
env:
DEBUG: 1
MAIL_DEBUG_BODY: 1
MAIL_ENABLED: False
publish:
name: Publish to PyPI 📦
needs: gate-test
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
permissions:
id-token: write
environment: pypi
steps:
- uses: actions/checkout@v6
- name: Set up Python 🐍
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m pip install build --user
- name: Build a binary wheel 🏗️
run: >-
python3 -m build
- name: Publish to PyPI 📦
uses: pypa/gh-action-pypi-publish@release/v1