From 1a9b93183d53f1dc77468431a6f31df7270c504c Mon Sep 17 00:00:00 2001 From: jo Date: Wed, 18 Jan 2023 23:47:17 +0100 Subject: [PATCH] ci: rework test_api job Part-of: --- .gitlab-ci.yml | 37 ++++++++++++++++++++----------------- api/pyproject.toml | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f6e15d93..18b4a389c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -172,15 +172,21 @@ lint_front: test_api: interruptible: true + retry: 1 + stage: test + rules: + - if: $CI_COMMIT_BRANCH =~ /(stable|develop)/ + - changes: [api/**/*] + + image: $CI_REGISTRY/funkwhale/ci/python-funkwhale-api:$PYTHON_VERSION + parallel: + matrix: + - PYTHON_VERSION: ["3.8", "3.9", "3.10", "3.11"] services: - postgres:15-alpine - redis:7-alpine - stage: test - retry: 1 cache: - key: "$CI_PROJECT_ID__pip_cache" - paths: - - "$PIP_CACHE_DIR" + paths: ["$PIP_CACHE_DIR"] variables: DATABASE_URL: "postgresql://postgres@postgres/postgres" FUNKWHALE_URL: "https://funkwhale.ci" @@ -189,9 +195,16 @@ test_api: CACHE_URL: "redis://redis:6379/0" before_script: - cd api - - poetry install --no-root + - poetry install script: - - poetry run pytest --cov-report xml --cov-report term-missing:skip-covered --cov=funkwhale_api --junitxml=report.xml tests/ + - > + poetry run pytest + --junitxml=report.xml + --cov + --cov-config=pyproject.toml + --cov-report=term-missing:skip-covered + --cov-report=xml + tests artifacts: expire_in: 2 weeks reports: @@ -199,17 +212,7 @@ test_api: coverage_report: coverage_format: cobertura path: api/coverage.xml - parallel: - matrix: - - PY_VER: ["3.8", "3.9", "3.10", "3.11"] - image: $CI_REGISTRY/funkwhale/backend-test-docker:$PY_VER coverage: '/TOTAL\s*\d*\s*\d*\s*(\d*%)/' - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push" - changes: - - api/**/* - - if: $CI_COMMIT_REF_PROTECTED == "true" - when: always # Those tests are disabled for now since no vitest dom emulation is providing # AudioContext, which is required for our HTML audio player diff --git a/api/pyproject.toml b/api/pyproject.toml index 458e2e21f..f99e916a4 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -175,7 +175,7 @@ env = [ [tool.coverage.run] plugins = ["django_coverage_plugin"] -include = ["funkwhale_api/*"] +source = ["funkwhale_api"] omit = [ "*migrations*", "*tests*",