chore(deps): update actions (major) #2738
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: Test | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "*.md" | |
- ".vscode/**" | |
- "docs/**" | |
- "LICENSE" | |
- "mkdocs.yml" | |
pull_request: | |
paths-ignore: | |
- "*.md" | |
- ".vscode/**" | |
- "docs/**" | |
- "LICENSE" | |
- "mkdocs.yml" | |
jobs: | |
test: | |
name: test${{ matrix.job-description || format(' ({0}, {1})', matrix.python-version, matrix.os) }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] | |
include: | |
- os: ubuntu-latest | |
python-version: "3.10" | |
pydantic-v2: "false" | |
job-description: " (pydantic v1)" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install . -r pipelines/requirements/ci.txt | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('pipelines/requirements/*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- uses: actions/cache@v4 | |
with: | |
path: .mypy_cache | |
key: ${{ runner.os }}-mypy | |
restore-keys: | | |
${{ runner.os }}-mypy | |
- name: Setup database | |
# for some reason prisma creates the database where the schema is stored | |
# but when using the prisma query engine it uses the root directory | |
run: | | |
python -m prisma db push --schema=tests/data/schema.prisma --skip-generate | |
cp tests/data/dev.db dev.db | |
- name: Setup coverage | |
run: | | |
nox -s setup | |
- name: Run tests | |
run: | | |
python scripts/ci.py -s test --no-error-on-missing-interpreters -- --pydantic-v2=${{ matrix.pydantic-v2 }} | |
env: | |
TARGET_PYTHON: ${{ matrix.python-version }} | |
- name: Upload coverage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-data | |
path: ".cache/.coverage.*" | |
integration: | |
name: integration (${{ matrix.name }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: "prisma-schema-folder" | |
args: "-s i:prisma-schema-folder" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install . -r pipelines/requirements/ci.txt | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('pipelines/requirements/*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Run tests | |
run: | | |
nox ${{ matrix.args }} | |
env: | |
TARGET_PYTHON: "3.11" | |
typesafety: | |
name: typesafety | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- python-version: 3.9 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install . -r pipelines/requirements/ci.txt | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('pipelines/requirements/*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Run Pyright tests | |
run: | | |
nox -s typesafety-pyright | |
- name: Run mypy tests | |
run: | | |
nox -s typesafety-mypy | |
lint: | |
name: lint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -U . -r pipelines/requirements/ci.txt | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('pipelines/requirements/*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
# TODO: add coverage for our mypy plugin | |
- name: Check linters | |
run: | | |
nox -s lint | |
# Ensure that all Prisma Schema files are up to date | |
- name: Check formatting | |
run: | | |
nox -s format | |
git diff --exit-code | |
mypy: | |
name: mypy | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.11] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -U . -r pipelines/requirements/ci.txt | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('pipelines/requirements/*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- uses: actions/cache@v4 | |
with: | |
path: .mypy_cache | |
key: ${{ runner.os }}-mypy | |
restore-keys: | | |
${{ runner.os }}-mypy | |
# TODO: figure out how to get coverage for the mypy plugin | |
- name: Check Mypy | |
run: | | |
nox -s mypy | |
databases: | |
name: ${{ matrix.name }} ${{ matrix.version }} / ${{ matrix.python }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: MySQL | |
version: "8.0" | |
env: MYSQL_URL | |
url: mysql://prisma:prisma@localhost:3307/prisma | |
python: "3.10" | |
- name: SQLite | |
version: "" | |
env: SQLITE_URL | |
url: file:dev.db | |
python: "3.10" | |
- name: PostgreSQL | |
version: "10" | |
env: POSTGRESQL_URL | |
url: postgresql://postgres:prisma@localhost:5432/postgres | |
python: "3.10" | |
- name: PostgreSQL | |
version: "15" | |
env: POSTGRESQL_URL | |
url: postgresql://postgres:prisma@localhost:5438/postgres | |
python: "3.10" | |
- name: PostgreSQL | |
version: "15" | |
env: POSTGRESQL_URL | |
url: postgresql://postgres:prisma@localhost:5438/postgres | |
python: "3.9" | |
- name: PostgreSQL | |
version: "15" | |
env: POSTGRESQL_URL | |
url: postgresql://postgres:prisma@localhost:5438/postgres | |
python: "3.11" | |
- name: CockroachDB | |
version: "22" | |
env: COCKROACHDB_URL | |
url: postgresql://prisma@localhost:26257/postgres | |
python: "3.10" | |
- name: MariaDB | |
version: "10.0" | |
env: MARIADB_URL | |
url: mysql://root:prisma@localhost:3308/prisma?connect_timeout=20&socket_timeout=60 | |
python: "3.10" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -U . -r pipelines/requirements/ci.txt | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('pipelines/requirements/*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Start ${{ matrix.name }} | |
if: matrix.name != 'SQLite' | |
run: | | |
coverage run -m nox -s databases -- serve ${{ matrix.name }} --version=${{ matrix.version }} | |
- name: Run async tests | |
run: | | |
coverage run -m nox -s databases -- test --coverage --databases=${{ matrix.name }} | |
env: | |
${{ matrix.env }}: ${{ matrix.url }} | |
COVERAGE_FILE: .cache/.coverage.databases | |
# these tests ensure that unsupported features, e.g. enums on SQLite actually fail | |
- name: Run inverse async tests | |
run: | | |
coverage run -m nox -s databases -- test-inverse --coverage --databases=${{ matrix.name }} | |
env: | |
${{ matrix.env }}: ${{ matrix.url }} | |
COVERAGE_FILE: .cache/.coverage.databases | |
- name: Run sync tests | |
run: | | |
coverage run -m nox -s databases -r -- test --coverage --databases=${{ matrix.name }} --for-async=false | |
env: | |
${{ matrix.env }}: ${{ matrix.url }} | |
COVERAGE_FILE: .cache/.coverage.databases | |
- name: Run inverse sync tests | |
run: | | |
coverage run -m nox -s databases -r -- test-inverse --coverage --databases=${{ matrix.name }} --for-async=false | |
env: | |
${{ matrix.env }}: ${{ matrix.url }} | |
COVERAGE_FILE: .cache/.coverage.databases | |
- name: Run pydantic v1 tests | |
run: | | |
coverage run -m nox -s databases -- test --coverage --databases=${{ matrix.name }} --no-pydantic-v2 | |
env: | |
${{ matrix.env }}: ${{ matrix.url }} | |
COVERAGE_FILE: .cache/.coverage.databases | |
- name: Upload coverage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-data | |
path: ".cache/.coverage*" | |
coverage: | |
name: coverage | |
runs-on: ubuntu-latest | |
needs: [databases, test] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -U . -r pipelines/requirements/ci.txt | |
- name: Download coverage data. | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-data | |
path: .cache/ | |
- name: Check coverage requirements | |
run: | | |
nox -s report-strict | |
- name: Upload coverage report | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: htmlcov | |
path: htmlcov | |
- name: Update static coverage | |
if: (success() || failure()) && github.ref == 'refs/heads/main' && github.repository == 'RobertCraigie/prisma-client-py' | |
run: | | |
nox -s push-coverage | |
# delete the temporary coverage artifacts to save on unnecessary cloud storage usage | |
- uses: geekyeggo/delete-artifact@v5 | |
with: | |
name: coverage-data | |
docker: | |
name: docker | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
docker-platform: [linux/amd64, linux/arm64] | |
python-os-distro: [slim-bullseye, alpine] | |
exclude: | |
# Dockerfile is currently broken for alpine / arm64 | |
# https://github.com/RobertCraigie/prisma-client-py/issues/581 | |
- docker-platform: linux/arm64 | |
python-os-distro: alpine | |
steps: | |
- uses: actions/checkout@v4 | |
# https://github.com/docker/build-push-action/ | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker Build | |
uses: docker/build-push-action@v6 | |
# https://github.com/docker/build-push-action/#inputs | |
# Test each platform individually for easier testing | |
with: | |
context: . | |
file: tests/Dockerfile | |
platforms: "${{ matrix.docker-platform }}" | |
build-args: OS_DISTRO=${{ matrix.python-os-distro }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Note: Windows does not play well with the standard GH Docker + buildx | |
# actions | |
docker-windows: | |
name: docker (windows) | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Docker Build | |
# Use --% to allow double hyphen | |
# Caching not currently working since we don't use buildx yet, windows | |
# support seems poor because of interactions with --privileged | |
# --cache-from=type=gha --cache-to=type=gha,mode=max | |
run: | | |
docker build --% -f tests/windows.Dockerfile -t prisma-client-py . | |
tests_status: | |
if: always() | |
needs: | |
- test | |
- typesafety | |
- lint | |
- mypy | |
- databases | |
- coverage | |
- docker | |
runs-on: ubuntu-latest | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@release/v1 | |
with: | |
jobs: ${{ toJSON(needs) }} |