2020-12-04 01:33:58 +03:00
|
|
|
{{ config_header }}
|
|
|
|
version: 2.1
|
|
|
|
|
2023-06-20 17:20:33 +03:00
|
|
|
parameters:
|
|
|
|
docker-version:
|
|
|
|
type: string
|
2024-02-29 18:31:12 +03:00
|
|
|
# `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
|
2023-06-20 17:20:33 +03:00
|
|
|
git-image:
|
|
|
|
type: string
|
2024-02-29 18:31:12 +03:00
|
|
|
default: docker:25.0.3-git
|
2023-06-20 17:20:33 +03:00
|
|
|
|
2020-12-04 01:33:58 +03:00
|
|
|
orbs:
|
2024-03-04 19:55:46 +03:00
|
|
|
gcp-gcr: circleci/gcp-gcr@0.16.2
|
2020-12-04 01:33:58 +03:00
|
|
|
|
|
|
|
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:
|
2023-06-20 17:20:33 +03:00
|
|
|
- image: << pipeline.parameters.git-image >>
|
2020-12-04 01:33:58 +03:00
|
|
|
steps:
|
|
|
|
- checkout
|
2021-01-27 21:35:06 +03:00
|
|
|
- run:
|
|
|
|
name: Checkout git submodules
|
|
|
|
command: git submodule update --init --recursive
|
2020-12-04 01:33:58 +03:00
|
|
|
- setup_remote_docker:
|
2023-06-20 17:20:33 +03:00
|
|
|
version: << pipeline.parameters.docker-version >>
|
2020-12-04 01:33:58 +03:00
|
|
|
- run:
|
|
|
|
name: Build Docker image
|
|
|
|
command: docker build -t docker-etl:build .
|
|
|
|
- run:
|
|
|
|
name: Test Code
|
2023-06-20 17:20:33 +03:00
|
|
|
command: |
|
|
|
|
docker run docker-etl:build /bin/bash -c \
|
|
|
|
"python -m pytest docker_etl/ tests/; \
|
|
|
|
flake8 docker_etl/ tests/;\
|
|
|
|
black docker_etl/ tests/"
|
2020-12-04 01:33:58 +03:00
|
|
|
- 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) }}
|
|
|
|
|