implement cli/infra update cicd
This commit is contained in:
144
.gitlab-ci.yml
144
.gitlab-ci.yml
@@ -4,49 +4,18 @@ stages:
|
||||
- lint
|
||||
- test
|
||||
- build
|
||||
- deploy
|
||||
|
||||
variables:
|
||||
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.pip-cache"
|
||||
UV_CACHE_DIR: "$CI_PROJECT_DIR/.uv-cache"
|
||||
|
||||
# Cache dependencies between jobs
|
||||
cache:
|
||||
paths:
|
||||
- .pip-cache/
|
||||
- .uv-cache/
|
||||
- .venv/
|
||||
|
||||
before_script:
|
||||
.uv_setup: &uv_setup
|
||||
- curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
- export PATH="$HOME/.cargo/bin:$PATH"
|
||||
- uv venv .venv
|
||||
- source .venv/bin/activate
|
||||
- uv pip install -r requirements.txt
|
||||
|
||||
lint:
|
||||
stage: lint
|
||||
script:
|
||||
- uv pip install ruff
|
||||
- ruff check .
|
||||
- ruff format --check .
|
||||
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- uv pip install pytest pytest-cov
|
||||
- pytest --cov=./ --cov-report=xml
|
||||
artifacts:
|
||||
reports:
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: coverage.xml
|
||||
|
||||
dependency-check:
|
||||
stage: lint
|
||||
script:
|
||||
- uv pip install pip-audit
|
||||
- pip-audit
|
||||
allow_failure: true
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
@@ -54,13 +23,110 @@ workflow:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
- if: $CI_COMMIT_TAG
|
||||
|
||||
build:
|
||||
stage: build
|
||||
lint:
|
||||
stage: lint
|
||||
before_script:
|
||||
- *uv_setup
|
||||
script:
|
||||
- uv pip install build
|
||||
- python -m build
|
||||
- uv sync
|
||||
- uv run ruff check .
|
||||
- uv run ruff format --check .
|
||||
|
||||
test:
|
||||
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/
|
||||
- dist/materia-extract-latest.tar.gz
|
||||
expire_in: 1 week
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
- 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 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/**/*
|
||||
|
||||
Reference in New Issue
Block a user