- Add pytest and pytest-cov for testing - Add niquests for modern HTTP/2 support (keep requests for hcloud compatibility) - Create 13 E2E tests covering CLI, workers, pipelines, and secrets (71% coverage) - Fix Pulumi ESC environment path (beanflows/prod) and secret key names - Update GitLab CI to run CLI tests with coverage reporting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
148 lines
3.2 KiB
YAML
148 lines
3.2 KiB
YAML
image: python:3.13
|
|
|
|
stages:
|
|
- lint
|
|
- test
|
|
- build
|
|
- deploy
|
|
|
|
variables:
|
|
UV_CACHE_DIR: "$CI_PROJECT_DIR/.uv-cache"
|
|
|
|
cache:
|
|
paths:
|
|
- .uv-cache/
|
|
|
|
.uv_setup: &uv_setup
|
|
- curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
- export PATH="$HOME/.cargo/bin:$PATH"
|
|
- source $HOME/.local/bin/env
|
|
|
|
workflow:
|
|
rules:
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
lint:
|
|
stage: lint
|
|
before_script:
|
|
- *uv_setup
|
|
script:
|
|
- uv sync
|
|
- uv run ruff check .
|
|
- uv run ruff format --check .
|
|
|
|
test:cli:
|
|
stage: test
|
|
before_script:
|
|
- *uv_setup
|
|
script:
|
|
- uv sync
|
|
- uv run pytest tests/ -v --cov=src/materia --cov-report=xml --cov-report=term
|
|
coverage: '/TOTAL.*\s+(\d+%)$/'
|
|
artifacts:
|
|
reports:
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: coverage.xml
|
|
|
|
test:sqlmesh:
|
|
stage: test
|
|
before_script:
|
|
- *uv_setup
|
|
script:
|
|
- uv sync
|
|
- cd transform/sqlmesh_materia && uv run sqlmesh test
|
|
|
|
build:extract:
|
|
stage: build
|
|
before_script:
|
|
- *uv_setup
|
|
script:
|
|
- uv sync
|
|
- mkdir -p dist
|
|
- uv build --package psdonline --out-dir dist/extract
|
|
- cd dist/extract && tar -czf ../materia-extract-latest.tar.gz .
|
|
artifacts:
|
|
paths:
|
|
- dist/materia-extract-latest.tar.gz
|
|
expire_in: 1 week
|
|
rules:
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
|
|
build:transform:
|
|
stage: build
|
|
before_script:
|
|
- *uv_setup
|
|
script:
|
|
- uv sync
|
|
- mkdir -p dist
|
|
- uv build --package sqlmesh_materia --out-dir dist/transform
|
|
- cd dist/transform && tar -czf ../materia-transform-latest.tar.gz .
|
|
artifacts:
|
|
paths:
|
|
- dist/materia-transform-latest.tar.gz
|
|
expire_in: 1 week
|
|
rules:
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
|
|
build:cli:
|
|
stage: build
|
|
before_script:
|
|
- *uv_setup
|
|
script:
|
|
- uv sync
|
|
- mkdir -p dist
|
|
- uv build --out-dir dist/cli
|
|
- cd dist/cli && tar -czf ../materia-cli-latest.tar.gz .
|
|
artifacts:
|
|
paths:
|
|
- dist/materia-cli-latest.tar.gz
|
|
expire_in: 1 week
|
|
rules:
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
|
|
deploy:r2:
|
|
stage: deploy
|
|
image: rclone/rclone:latest
|
|
before_script:
|
|
- apk add --no-cache curl unzip
|
|
- curl -fsSL https://get.pulumi.com/esc/install.sh | sh
|
|
- export PATH="$HOME/.pulumi/bin:$PATH"
|
|
- esc login --token ${PULUMI_ACCESS_TOKEN}
|
|
- eval $(esc env open beanflows/prod --format shell)
|
|
- |
|
|
mkdir -p ~/.config/rclone
|
|
cat > ~/.config/rclone/rclone.conf <<EOF
|
|
[r2]
|
|
type = s3
|
|
provider = Cloudflare
|
|
access_key_id = ${R2_ACCESS_KEY_ID}
|
|
secret_access_key = ${R2_SECRET_ACCESS_KEY}
|
|
endpoint = https://${R2_ENDPOINT}
|
|
acl = private
|
|
EOF
|
|
script:
|
|
- rclone copy dist/*.tar.gz r2:${R2_ARTIFACTS_BUCKET}/ -v
|
|
dependencies:
|
|
- build:extract
|
|
- build:transform
|
|
- build:cli
|
|
rules:
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
|
|
deploy:infra:
|
|
stage: deploy
|
|
image: pulumi/pulumi:latest
|
|
before_script:
|
|
- pulumi login --token ${PULUMI_ACCESS_TOKEN}
|
|
script:
|
|
- cd infra
|
|
- pulumi stack select prod
|
|
- pulumi up --yes
|
|
rules:
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
changes:
|
|
- infra/**/*
|