-
Notifications
You must be signed in to change notification settings - Fork 2
/
.drone.yml
213 lines (189 loc) · 5.04 KB
/
.drone.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
---
kind: pipeline
type: kubernetes
name: build
environment:
NAME: microcosm_fastapi
trigger:
event:
- push
services:
- name: database
image: postgres:11-bullseye
environment:
POSTGRES_USER: test_project
POSTGRES_PASSWORD: password
POSTGRES_DB: test_project_db
steps:
- name: lint-and-type-check
image: python:3.11-slim
environment:
AWS_ACCOUNT_ID:
from_secret: AWS_ACCOUNT_ID
AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
EXTRA_INDEX_URL:
from_secret: EXTRA_INDEX_URL
commands:
- pip install -U pip==24.0
- pip install awscli
- aws codeartifact login --tool pip --repository globality-pypi-local --domain globality --domain-owner $AWS_ACCOUNT_ID --region us-east-1
- ./entrypoint.sh lint
- ./entrypoint.sh typehinting
- name: test-py311-latest
image: python:3.11-slim
environment:
AWS_ACCOUNT_ID:
from_secret: AWS_ACCOUNT_ID
AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
EXTRA_INDEX_URL:
from_secret: EXTRA_INDEX_URL
commands:
- pip install -U pip==24.0
- pip install awscli
- aws codeartifact login --tool pip --repository globality-pypi-local --domain globality --domain-owner $AWS_ACCOUNT_ID --region us-east-1
- apt update
- apt install -y postgresql-client
- createdb -h database -U test_project -O test_project test_project_test_db
- ./entrypoint.sh test
- name: sonar-scanner
image: sonarsource/sonar-scanner-cli:latest
environment:
SONARQUBE_TOKEN:
from_secret: SONARQUBE_TOKEN
commands:
- >-
sonar-scanner
-Dsonar.login=$SONARQUBE_TOKEN
-Dsonar.projectBaseDir=/drone/src
-Dsonar.host.url=https://sonarqube.globality.cloud
-Dsonar.branch.name=${DRONE_BRANCH}
depends_on:
- lint-and-type-check
- test-py311-latest
- name: release-python-library-codeartifact
image: python:3.11-slim
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
AWS_ACCOUNT_ID:
from_secret: AWS_ACCOUNT_ID
EXTRA_INDEX_URL:
from_secret: EXTRA_INDEX_URL
depends_on:
- sonar-scanner
commands:
- pip install -U pip==24.0
- pip install --quiet awscli twine==4.0.2 packaging==24.0
- export version=$(cat .bumpversion.cfg | awk '/current_version / {print $3}')
- aws codeartifact login --tool pip --repository globality-pypi-local --domain globality --domain-owner $AWS_ACCOUNT_ID --region us-east-1
- python setup.py sdist bdist_wheel
- aws codeartifact login --tool twine --domain globality --repository globality-pypi-local --region us-east-1 && twine upload --repository codeartifact dist/microcosm_fastapi-${version}* --verbose
when:
branch:
- master
- name: publish_library_to_pypi
image: python:3.11-slim
depends_on:
- release-python-library-codeartifact
environment:
TWINE_USERNAME: __token__
TWINE_PASSWORD:
from_secret: PYPI_TOKEN
TWINE_REPOSITORY: https://upload.pypi.org/legacy/
commands:
- pip install -U pip==24.0
- pip install --quiet awscli twine==4.0.2
- export version=$(cat .bumpversion.cfg | awk '/current_version / {print $3}')
- echo "Publishing ${version}"
- python setup.py sdist bdist_wheel
- twine upload --repository pypi dist/microcosm_fastapi-${version}* --non-interactive --verbose
when:
branch:
- master
---
kind: pipeline
type: kubernetes
name: pr
trigger:
event:
- pull_request
steps:
- name: dependency-validation-dummy
pull: always
image: python:3.11-slim
commands:
- echo "Dummy step to trigger dependency-validation"
---
kind: secret
name: SONARQUBE_TOKEN
get:
path: secrets/dev/drone
name: DRONE_SONARQUBE_TOKEN
---
kind: secret
name: AWS_ACCOUNT_ID
get:
path: secrets/dev/drone
name: AWS_ACCOUNT_ID
---
kind: secret
name: PYPI_TOKEN
get:
path: secrets/dev/drone
name: PYPI_TOKEN
---
kind: secret
name: ARTIFACTORY_USERNAME
get:
path: secrets/dev/drone
name: DRONE_ARTIFACTORY_USERNAME
---
kind: secret
name: ARTIFACTORY_PASSWORD
get:
path: secrets/dev/drone
name: DRONE_ARTIFACTORY_PASSWORD
---
kind: secret
name: GITHUB_PRIVATE_KEY
get:
path: secrets/dev/drone
name: DRONE_GITHUB_PRIVATE_KEY
---
kind: secret
name: DRONE_API_TOKEN
get:
path: secrets/dev/drone
name: DRONE_API_TOKEN
---
kind: secret
name: CFGR_GITHUB_PRIVATE_KEY
get:
path: secrets/dev/drone
name: CFGR_GITHUB_PRIVATE_KEY
---
kind: secret
name: AWS_ACCESS_KEY_ID
get:
path: secrets/dev/drone
name: DRONE_AWS_ACCESS_KEY
---
kind: secret
name: AWS_SECRET_ACCESS_KEY
get:
path: secrets/dev/drone
name: DRONE_AWS_ACCESS_SECRET_KEY
---
kind: secret
name: EXTRA_INDEX_URL
get:
path: secrets/dev/drone
name: DRONE_EXTRA_INDEX_URL