Loading .gitlab-ci.yml +53 −52 Original line number Diff line number Diff line default: image: python:3.12-slim cache: paths: - .cache/uv before_script: - . "$CI_PROJECT_DIR/scripts/ci/setup-proxy.sh" - . "$CI_PROJECT_DIR/scripts/ci/setup-extra-ca.sh" - cd "$CI_PROJECT_DIR/${BACKEND_DIR:-.}" - pip install uv - export UV_SYSTEM_CERTS=1 - uv sync --locked --extra dev - . .venv/bin/activate tags: - docker stages: - type - architecture - lint - format - type - architecture - test - build - push variables: UV_CACHE_DIR: "$CI_PROJECT_DIR/.cache/uv" PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" type: stage: type script: - mypy open_exposure_gateway/app/ open_exposure_gateway/test/ cache: paths: - .cache/pip architecture: stage: architecture script: - lint-imports .python_job: image: python:3.12-slim before_script: - python --version - python -m pip install --upgrade pip - python -m pip install -e ".[dev,postgres]" lint: stage: lint extends: .python_job script: - ruff check open_exposure_gateway/ format: stage: format extends: .python_job script: - ruff format --check open_exposure_gateway/ test: stage: test # TODO: add integration tests when we move this to ETSI gitlab # Scoped to test/unit explicitly (not just -m deselection): pytest must still # import every collected module to read its markers, and test/conformance's # module-level schemathesis schema loading is expensive — collecting it here # would cost minutes on every pipeline even though none of its tests run. type: stage: type extends: .python_job script: - mypy open_exposure_gateway/app/ open_exposure_gateway/test/ architecture: stage: architecture extends: .python_job script: - pytest open_exposure_gateway/test/unit || [ $? -eq 5 ] #bypass no tests found error. - lint-imports conformance: test: stage: test allow_failure: true extends: .python_job script: - pytest open_exposure_gateway/test/conformance - pytest || [ $? -eq 5 ] build: build_test_image: stage: build image: docker:29.3.0 services: - docker:29.3.0-dind tags: - shell before_script: - . "$CI_PROJECT_DIR/scripts/ci/setup-proxy.sh" - . "$CI_PROJECT_DIR/scripts/ci/setup-extra-ca.sh" - cd "$CI_PROJECT_DIR/${BACKEND_DIR:-.}" - docker info script: - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA . - | docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE:latest" docker push "$CI_REGISTRY_IMAGE:latest" - | if [ -n "$CI_COMMIT_TAG" ]; then docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" fi - export TEST_IMAGE_TAG="ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" - docker build --network=host -t "$CI_REGISTRY_IMAGE:$TEST_IMAGE_TAG" . rules: - if: '$CI_COMMIT_BRANCH' only: - main push_test_image: stage: push tags: - shell needs: - build_test_image before_script: - docker info script: - export TEST_IMAGE_TAG="ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin - docker push "$CI_REGISTRY_IMAGE:$TEST_IMAGE_TAG" - docker logout "$CI_REGISTRY" rules: - if: '$CI_COMMIT_BRANCH' No newline at end of file Loading
.gitlab-ci.yml +53 −52 Original line number Diff line number Diff line default: image: python:3.12-slim cache: paths: - .cache/uv before_script: - . "$CI_PROJECT_DIR/scripts/ci/setup-proxy.sh" - . "$CI_PROJECT_DIR/scripts/ci/setup-extra-ca.sh" - cd "$CI_PROJECT_DIR/${BACKEND_DIR:-.}" - pip install uv - export UV_SYSTEM_CERTS=1 - uv sync --locked --extra dev - . .venv/bin/activate tags: - docker stages: - type - architecture - lint - format - type - architecture - test - build - push variables: UV_CACHE_DIR: "$CI_PROJECT_DIR/.cache/uv" PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" type: stage: type script: - mypy open_exposure_gateway/app/ open_exposure_gateway/test/ cache: paths: - .cache/pip architecture: stage: architecture script: - lint-imports .python_job: image: python:3.12-slim before_script: - python --version - python -m pip install --upgrade pip - python -m pip install -e ".[dev,postgres]" lint: stage: lint extends: .python_job script: - ruff check open_exposure_gateway/ format: stage: format extends: .python_job script: - ruff format --check open_exposure_gateway/ test: stage: test # TODO: add integration tests when we move this to ETSI gitlab # Scoped to test/unit explicitly (not just -m deselection): pytest must still # import every collected module to read its markers, and test/conformance's # module-level schemathesis schema loading is expensive — collecting it here # would cost minutes on every pipeline even though none of its tests run. type: stage: type extends: .python_job script: - mypy open_exposure_gateway/app/ open_exposure_gateway/test/ architecture: stage: architecture extends: .python_job script: - pytest open_exposure_gateway/test/unit || [ $? -eq 5 ] #bypass no tests found error. - lint-imports conformance: test: stage: test allow_failure: true extends: .python_job script: - pytest open_exposure_gateway/test/conformance - pytest || [ $? -eq 5 ] build: build_test_image: stage: build image: docker:29.3.0 services: - docker:29.3.0-dind tags: - shell before_script: - . "$CI_PROJECT_DIR/scripts/ci/setup-proxy.sh" - . "$CI_PROJECT_DIR/scripts/ci/setup-extra-ca.sh" - cd "$CI_PROJECT_DIR/${BACKEND_DIR:-.}" - docker info script: - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA . - | docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE:latest" docker push "$CI_REGISTRY_IMAGE:latest" - | if [ -n "$CI_COMMIT_TAG" ]; then docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" fi - export TEST_IMAGE_TAG="ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" - docker build --network=host -t "$CI_REGISTRY_IMAGE:$TEST_IMAGE_TAG" . rules: - if: '$CI_COMMIT_BRANCH' only: - main push_test_image: stage: push tags: - shell needs: - build_test_image before_script: - docker info script: - export TEST_IMAGE_TAG="ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin - docker push "$CI_REGISTRY_IMAGE:$TEST_IMAGE_TAG" - docker logout "$CI_REGISTRY" rules: - if: '$CI_COMMIT_BRANCH' No newline at end of file