Updated CI.

Signed-off-by: Pavel Kirilin <win10@list.ru>
This commit is contained in:
2021-08-07 01:34:25 +04:00
parent 6579ddd90b
commit ec0f672090
12 changed files with 204 additions and 92 deletions

View File

@ -1,70 +1,78 @@
stages:
- tools
- test
- cleanup_tests
- build
- deploy
build_test:
stage: tools
variables:
APP_VERSION: ${CI_COMMIT_REF_SLUG}
.test-template:
image: python:3.9-buster
stage: test
tags:
- bots-deployer
script:
- make build-test
- kube
except:
- tags
before_script:
- echo "${DOCKER_REGISTRY}"
- pip install poetry==1.1.6
- poetry config virtualenvs.create false
- poetry install
flake8:
stage: test
tags:
- bots-deployer
extends:
- .test-template
script:
- make flake8
- flake8 --count .
pytest:
stage: test
tags:
- bots-deployer
extends:
- .test-template
script:
- make pytest
- pytest -vv
black:
stage: test
tags:
- bots-deployer
extends:
- .test-template
script:
- make black
- black --check .
mypy:
stage: test
tags:
- bots-deployer
extends:
- .test-template
script:
- make mypy
- mypy .
cleanup_tests:
stage: cleanup_tests
tags:
- bots-deployer
when: always
script:
- make clear-test
build:
image-builder:
stage: build
only:
- master
- tags
image:
name: gcr.io/kaniko-project/executor:v1.6.0-debug
entrypoint: [ "" ]
tags:
- bots-deployer
- kube
only:
- tags
script:
- make build push
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$DOCKER_REGISTRY\":{\"username\":\"$DOCKER_USER\",\"password\":\"$DOCKER_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context .
--dockerfile deploy/Dockerfile
--destination "$IMAGE_NAME:$APP_VERSION"
--force
deploy:
stage: deploy
only:
- master
- tags
when: manual
image: dtzar/helm-kubectl:3.6.3
tags:
- bots-deployer
- kube
only:
- tags
script:
- make deploy-prod
- export KUBECONFIG=$KUBE_CONF
- env | grep "^LENOCHKA_" > .deploy-env
- kubectl delete configmap --namespace "$NAMESPACE" "$ENVCONF" || true
- kubectl create configmap --namespace "$NAMESPACE" "$ENVCONF" --from-env-file=.deploy-env
- envsubst < "$HELM_VALUES" > deploy-values.yml
- helm upgrade lenocka deploy/charts/lenocka/ -f deploy-values.yml --namespace "$NAMESPACE"