-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
95 lines (84 loc) · 1.89 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
image: canopytax/dind
stages:
- build
- test
- security
- push-to-dockerhub
- deploy-stage
- deploy-prod
variables:
REPO_NAME: canopytax/toggle-meister
CONTAINER_IMAGE: docker.io/$REPO_NAME:$CI_COMMIT_SHA
REGISTRY: docker.io
DOCKER_DRIVER: overlay
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
build:
stage: build
before_script:
- mkdir -p $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
script:
- docker build --pull -t $CONTAINER_IMAGE .
- docker push $REPO_NAME:$CI_COMMIT_SHA
lint:
image: $REPO_NAME:$CI_COMMIT_SHA
stage: test
script:
- invoke lint
test:
services:
- postgres:9.6-alpine
image: $REPO_NAME:$CI_COMMIT_SHA
stage: test
script:
- export DATABASE_URL=postgres
- export IS_LOCAL=true
- alembic upgrade head
- python3 -m pytest --cov tmeister
bandit:
allow_failure: true
only:
refs:
- merge_requests
variables:
- $CI_PROJECT_REPOSITORY_LANGUAGES =~ /python/
variables:
BANDIT_API_TOKEN: $BANDIT_API_TOKEN
stage: security
image: canopytax/python-bandit
script:
- echo
push-to-dockerhub:
stage: push-to-dockerhub
before_script:
- mkdir -p $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
script:
- docker pull $REPO_NAME:$CI_COMMIT_SHA
- docker tag $REPO_NAME:$CI_COMMIT_SHA $REPO_NAME:latest
- docker push $REPO_NAME:latest
only:
- master
.deploy: &deploy
image: canopytax/deployment
script:
- /scripts/canopy-deploy.py --docker-tag "$CI_COMMIT_SHA"
only:
- master
allow_failure: false
deploy-stage:
<<: *deploy
stage: deploy-stage
environment:
name: stage
url: https://tm.canopy.ninja
deploy-prod:
<<: *deploy
stage: deploy-prod
environment:
name: production
url: https://tm.canopytax.com
when: manual