docker-etl/.circleci/config.template.yml

74 строки
2.2 KiB
YAML
Исходник Постоянная ссылка Обычный вид История

{{ config_header }}
version: 2.1
parameters:
docker-version:
type: string
# `default` is recommended by CircleCI: https://discuss.circleci.com/t/remote-docker-image-deprecations-and-eol-for-2024/50176#what-do-i-need-to-do-2
default: default
git-image:
type: string
default: docker:25.0.3-git
orbs:
2024-03-04 19:55:46 +03:00
gcp-gcr: circleci/gcp-gcr@0.16.2
commands:
compare-branch:
description: Compare current branch with main
parameters:
pattern:
type: string
steps:
- run:
name: Compare current branch with main
command: |
if [ "$CIRCLE_BRANCH" = main ]; then
echo "Run tests because branch is main"
elif git log --format=%B --no-merges -n 1 | grep -qF '[run-tests]'; then
echo "Run tests because [run-tests] in commit message"
elif git diff --name-only ..origin | egrep -q '<< parameters.pattern >>'; then
echo "Run tests because << parameters.pattern >> was modified since branching off main"
else
echo "Skipping tests because << parameters.pattern >> was not modified"
circleci step halt
fi
jobs:
build-docker-etl:
docker:
- image: << pipeline.parameters.git-image >>
steps:
- checkout
- run:
name: Checkout git submodules
command: git submodule update --init --recursive
- setup_remote_docker:
version: << pipeline.parameters.docker-version >>
- run:
name: Build Docker image
command: docker build -t docker-etl:build .
- run:
name: Test Code
command: |
docker run docker-etl:build /bin/bash -c \
"python -m pytest docker_etl/ tests/; \
flake8 docker_etl/ tests/;\
black docker_etl/ tests/"
- run:
name: Verify jobs have required files
command: docker run docker-etl:build script/verify_files
- run:
name: Verify CI config is up-to-date
command: docker run docker-etl:build python3 -m docker_etl.ci_config --dry-run | diff -B .circleci/config.yml -
{{ jobs | indent(2, True) }}
workflows:
docker-etl:
jobs:
- build-docker-etl
{{ workflows | indent(2, True) }}