mirror of
https://gh.wpcy.net/https://github.com/WeblateOrg/weblate.git
synced 2026-04-26 22:07:26 +08:00
163 lines
5.5 KiB
YAML
163 lines
5.5 KiB
YAML
# Copyright © Michal Čihař <michal@weblate.org>
|
|
#
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
name: Test
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- renovate/**
|
|
- weblate
|
|
- dependabot/**
|
|
- copilot/**
|
|
- codex/**
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-24.04
|
|
continue-on-error: ${{ matrix.experimental }}
|
|
strategy:
|
|
matrix:
|
|
python-version:
|
|
- '3.12'
|
|
- '3.13'
|
|
- '3.14'
|
|
requirements:
|
|
- latest
|
|
experimental:
|
|
- false
|
|
include:
|
|
# Reduced testing for minimal deps
|
|
- python-version: '3.12'
|
|
requirements: minimal
|
|
experimental: false
|
|
# Reduced testing for edge deps
|
|
- python-version: '3.14'
|
|
requirements: edge
|
|
experimental: true
|
|
name: py${{ matrix.python-version }}, ${{ matrix.requirements }} deps
|
|
env:
|
|
CI_REDIS_HOST: 127.0.0.1
|
|
CI_REDIS_PORT: '6379'
|
|
CI_DB_PASSWORD: weblate
|
|
CI_DB_HOST: 127.0.0.1
|
|
CI_DB_PORT: '5432'
|
|
CI_SELENIUM: '1'
|
|
DJANGO_SETTINGS_MODULE: weblate.settings_test
|
|
PYTHONWARNINGS: default,ignore:unclosed:ResourceWarning
|
|
PYTHONUNBUFFERED: 1
|
|
services:
|
|
database:
|
|
image: postgres:18.3-alpine@sha256:4da1a4828be12604092fa55311276f08f9224a74a62dcb4708bd7439e2a03911
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: weblate
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
cache:
|
|
image: valkey/valkey:9.0.3-alpine@sha256:e1095c6c76ee982cb2d1e07edbb7fb2a53606630a1d810d5a47c9f646b708bf5
|
|
ports:
|
|
- 6379:6379
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: data-test/cache/tesseract
|
|
key: tesseract-data
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
id: setup_python
|
|
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
allow-prereleases: true
|
|
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
|
|
with:
|
|
save-cache: ${{ github.ref == 'refs/heads/main' }}
|
|
cache-suffix: ${{ steps.setup_python.outputs.python-version }}
|
|
version: 0.11.6
|
|
- name: Install apt dependencies
|
|
run: sudo ./ci/apt-install
|
|
- name: Install Python dependencies
|
|
run: ./ci/pip-install ${{ matrix.requirements }}
|
|
- name: Used versions
|
|
run: |
|
|
source .venv/bin/activate
|
|
./ci/print-versions
|
|
- name: Prepare database
|
|
run: ./ci/prepare-database
|
|
- name: Compile MO files
|
|
run: uv run coverage run ./manage.py compilemessages
|
|
- name: Collect static files
|
|
run: uv run coverage run ./manage.py collectstatic --noinput --verbosity 0
|
|
- name: Migrate database
|
|
run: uv run coverage run ./manage.py migrate --noinput --traceback
|
|
- name: Django checks
|
|
run: uv run coverage run ./manage.py check
|
|
- name: Demo import
|
|
run: |
|
|
uv run coverage run ./manage.py import_demo
|
|
# Second execution with --delete should remove and recreate
|
|
uv run coverage run ./manage.py import_demo --delete
|
|
uv run coverage run ./manage.py billing_demo
|
|
# Second execution should gracefully handle existing project
|
|
uv run coverage run ./manage.py billing_demo
|
|
- name: Keep coverage
|
|
run: |
|
|
mkdir -p build/coverage
|
|
mv .coverage.* build/coverage
|
|
- name: Test with Django
|
|
run: |
|
|
source .venv/bin/activate
|
|
uv run --all-extras pytest --junitxml=junit.xml --cov=weblate --numprocesses=auto weblate
|
|
cp .coverage .coverage.pytest
|
|
- name: Test wsgi startup
|
|
env:
|
|
PYTHONPATH: .
|
|
run: uv run coverage run weblate/wsgi.py
|
|
- name: Coverage
|
|
run: |
|
|
mv build/coverage/.coverage.* .
|
|
uv run coverage combine
|
|
uv run coverage xml
|
|
- name: Install client dependencies for Argos CI
|
|
if: matrix.python-version == '3.14' && matrix.requirements == 'latest' && github.repository_owner == 'WeblateOrg'
|
|
working-directory: ./client
|
|
run: yarn install --immutable
|
|
- name: Argos CI upload
|
|
if: matrix.python-version == '3.14' && matrix.requirements == 'latest' && github.repository_owner == 'WeblateOrg'
|
|
working-directory: ./client
|
|
env:
|
|
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }} # zizmor: ignore[secrets-outside-env]
|
|
run: yarn argos upload ../test-images/
|
|
- uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
|
|
with:
|
|
token: ${{secrets.CODECOV_TOKEN}} # zizmor: ignore[secrets-outside-env]
|
|
flags: unittests
|
|
name: Tests py${{ matrix.python-version }}, ${{ matrix.requirements }} deps
|
|
- name: Upload test results to Codecov
|
|
if: ${{ !cancelled() }}
|
|
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }} # zizmor: ignore[secrets-outside-env]
|
|
report_type: test_results
|