Skip to content

feat: add support for GitLab CI again #309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions template/{% if ci == 'gitlab' %}.gitlab-ci.yml{% endif %}.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
stages:
- build
- test

variables:
DOCKER_TLS_CERTDIR: "/certs"

.python_matrix:
parallel:
matrix:
- PYTHON_VERSION: {% if project_type == 'package' %}["3.10", "3.12"]{% else %}["{{ python_version }}"]{% endif %}
RESOLUTION_STRATEGY: {% if project_type == 'package' %}["highest", "lowest-direct"]{% else %}["highest"]{%- endif %}

workflow:
rules:
# Run for pushes to main or master branches
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "master"'
when: always
# Run for merge requests
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
# Don't run for other cases like scheduled pipelines or tags unless specified
- when: never

build-dev-container:
extends:
- .python_matrix
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- apk add --update nodejs npm
- npm install -g @devcontainers/cli
script:
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
- IMAGE_TAG="${PYTHON_VERSION}-${RESOLUTION_STRATEGY}"
- IMAGE_NAME="${CI_REGISTRY_IMAGE}:${IMAGE_TAG}"
- devcontainer build --workspace-folder . --image-name ${IMAGE_NAME}
- docker push ${IMAGE_NAME}

test:
extends:
- .python_matrix
stage: test
image: ${CI_REGISTRY_IMAGE}:${PYTHON_VERSION}-${RESOLUTION_STRATEGY}
script:
- uv sync --python $PYTHON_VERSION --resolution $RESOLUTION_STRATEGY --all-extras
- poe lint
- poe test
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: reports/coverage.xml
junit:
- reports/mypy.xml
- reports/pytest.xml
untracked: true
when: always