# ============================================= # GitLab CI for fst_data_pipeline # ============================================= workflow: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_PIPELINE_SOURCE == "web" - if: $CI_COMMIT_TAG - if: $CI_PIPELINE_SOURCE == "schedule" variables: GIT_SUBMODULE_STRATEGY: recursive GIT_DEPTH: 0 REGISTRY: "artifacts.swf.i.mercedes-benz.com" IMAGE_NAME: "${REGISTRY}/panguprod-docker/fst_data_pipeline/root_db_api" DOCKER_CLI_EXPERIMENTAL: "enabled" default: tags: - shared-xsmall-x86-linux # ------------------------------------------------------------------ stages: - check-code-jobs - build-docker-image # ------------------------------------------------------------------ # 1️⃣ 代码格式 & lint 检查 # ------------------------------------------------------------------ python-lint-format: stage: check-code-jobs image: ${REGISTRY}/panguprod-docker/perception-3d/code-format:v1 script: - ./infra/tencent/docker_ci/entrypoint_python_format.sh --check --no-lint --fetch rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_PIPELINE_SOURCE == "web" # ------------------------------------------------------------------ # pytest + 覆盖率 # ------------------------------------------------------------------ root-db-api-pytest-coverage: stage: check-code-jobs image: ${REGISTRY}/panguprod-docker/fst_data_pipeline/python:3.12-slim-bookworm needs: ["python-lint-format"] before_script: - python -m pip install --user uv - export PATH=$HOME/.local/bin:$PATH - cd fst_data_pipeline/apps/root_db_api - uv sync --dev script: - mkdir -p tests/results - > uv run pytest --cov=fst_data_pipeline/apps/root_db_api --cov-report=term-missing --cov-report=xml:tests/results/coverage.xml --cov-report=html:tests/results/htmlcov --junitxml=tests/results/report.xml coverage: '/TOTAL.*\s+(\d+%)$/' artifacts: when: always paths: - fst_data_pipeline/apps/root_db_api/tests/results/htmlcov/ reports: junit: fst_data_pipeline/apps/root_db_api/tests/results/report.xml coverage_report: coverage_format: cobertura path: fst_data_pipeline/apps/root_db_api/tests/results/coverage.xml rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_PIPELINE_SOURCE == "web" # ------------------------------------------------------------------ # 2️⃣ 构建并推送 Docker 镜像 (Kaniko) # ------------------------------------------------------------------ build-docker-image: stage: build-docker-image image: name: gcr.io/kaniko-project/executor:v1.23.0-debug entrypoint: [""] variables: DOCKER_CONFIG: /kaniko/.docker before_script: - mkdir -p /kaniko/.docker - cp "$DOCKER_AUTH_CONFIG" /kaniko/.docker/config.json script: - | if [[ -n "$CI_COMMIT_TAG" ]]; then IMAGE_TAG="${IMAGE_NAME}:${CI_COMMIT_TAG}" else IMAGE_TAG="${IMAGE_NAME}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" fi /kaniko/executor \ --context "${CI_PROJECT_DIR}" \ --dockerfile "${CI_PROJECT_DIR}/infra/tencent/docker_ci/Dockerfile.root_db" \ --destination "${IMAGE_TAG}" needs: - job: python-lint-format optional: true rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" changes: - fst_data_pipeline/apps/root_db_api/**/* - fst_data_pipeline/apps/root_db_api/pyproject.toml - fst_data_pipeline/apps/root_db_api/uv.lock - infra/tencent/docker_ci/Dockerfile.root_db - pyproject.toml - uv.lock - if: $CI_COMMIT_TAG - if: $CI_PIPELINE_SOURCE == "web"