-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcloudbuild.yaml
73 lines (65 loc) · 2.12 KB
/
cloudbuild.yaml
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
steps:
- id: "Run Unit Tests"
name: "python:3.11-slim"
entrypoint: "bash"
args:
- "-c"
- |
pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-tests.txt
pytest -s -v --durations=10 --reruns 3 --reruns-delay 5 tests/unit/
- id: "Run Integration Tests"
name: "python:3.11-slim"
entrypoint: "bash"
args:
- "-c"
- |
pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-tests.txt
# We use rerun since tests are flaky
pytest -s -v --durations=10 --reruns 3 --reruns-delay 10 tests/integration/ --oid=${_OID} --key=${_KEY}
- id: "Get Version"
name: "python:3.11-slim"
entrypoint: "bash"
args:
- "-c"
- |
_VERSION=$(python setup.py --version 2> /dev/null)
[ -n "$$_VERSION" ] || { echo "ERROR: _VERSION is empty or not set"; exit 1; };
echo $$_VERSION > version.txt
echo "Using Docker tag version: $$_VERSION"
- id: "Login to DockerHub"
name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker login --username=$$USERNAME --password=$$PASSWORD']
secretEnv: ['USERNAME', 'PASSWORD']
- id: "Build Docker Image"
name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- "-c"
- |
_VERSION=$(cat version.txt)
[ -n "$$_VERSION" ] || { echo "ERROR: _VERSION is empty or not set"; exit 1; };
docker build -f ./Dockerfile \
-t refractionpoint/limacharlie:latest \
-t refractionpoint/limacharlie:$$_VERSION \
.
- id: "Push Image to Docker Hub"
name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- "-c"
- |
_VERSION=$(cat version.txt)
[ -n "$$_VERSION" ] || { echo "ERROR: _VERSION is empty or not set"; exit 1; };
docker push refractionpoint/limacharlie:latest
docker push refractionpoint/limacharlie:$$_VERSION || true
availableSecrets:
secretManager:
- versionName: projects/${PROJECT_ID}/secrets/DOCKERHUB/versions/latest
env: 'PASSWORD'
- versionName: projects/${PROJECT_ID}/secrets/DOCKERHUB_USERNAME/versions/latest
env: 'USERNAME'