-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloudbuild-ci.yaml
139 lines (120 loc) · 4.24 KB
/
cloudbuild-ci.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
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
steps:
#== BUILD
# Kaniko 0.17.0 fixes chrome install bug: https://github.com/GoogleContainerTools/kaniko/issues/769
# Kaniko 0.17.1 fixes /var/run issue in Google Cloud: https://github.com/GoogleContainerTools/kaniko/issues/1001
# OPEN: Kaniko 0.17.x produces invalid images (whiteout?): https://github.com/GoogleContainerTools/kaniko/issues/1039
# CLOSED?: New Kaniko version SHOULD fix this, pinning tot he debug tag mentioned here: https://github.com/GoogleContainerTools/kaniko/issues/1039#issuecomment-590954787
# Closing again, since latest Kaniko works on Staging branches.
- name: 'gcr.io/kaniko-project/executor'
id: Build Container
args:
- --destination=gcr.io/$PROJECT_ID/refsheet-site-ci:$REVISION_ID
- --cache=true
- --dockerfile=./Dockerfile.dev
#== SETUP
- name: 'gcr.io/cloud-builders/docker'
id: Postgres
args:
- run
- -d
- --name=postgres
- --network=cloudbuild
- -e
- POSTGRES_PASSWORD=fishsticks
- postgres
# Wait for Postgres to become available
- name: 'jwilder/dockerize:0.6.1'
id: Postgres Start
args:
- dockerize
- -timeout=60s
- -wait=tcp://postgres:5432
waitFor:
- Postgres
# Setup Database
- name: 'gcr.io/$PROJECT_ID/refsheet-site-ci:$REVISION_ID'
id: Migrate
dir: /app
args: ['bundle', 'exec', 'rake', 'db:migrate']
waitFor:
- Build Container
- Postgres Start
#== TEST
- name: 'gcr.io/$PROJECT_ID/refsheet-site-ci:$REVISION_ID'
id: RSpec Unit
dir: /app
args: ['bin/entrypoint.ci.sh', 'bundle', 'exec', 'rspec', '--exclude-pattern', '**/{features,requests,integration}/**/*_spec.rb']
secretEnv:
- CODECOV_TOKEN
waitFor:
- Migrate
# Can't run both Rails tests at the same time, since they'll cause some not so fun database concurrency issues.
# This is related to the issue of db cleaner, and there's nothing we can do but partition the database or something.
- name: 'gcr.io/$PROJECT_ID/refsheet-site-ci:$REVISION_ID'
id: RSpec Integration
dir: /app
args: ['bin/entrypoint.ci.sh', 'bundle', 'exec', 'rspec', '--pattern', '**/{features,requests,integration}/**/*_spec.rb']
secretEnv:
- CODECOV_TOKEN
env:
- NODE_ENV=development
- RAILS_ENV=test
waitFor:
- RSpec Unit
- Migrate
# Karma is hopelessly broken and I don't know why.
# - name: 'gcr.io/$PROJECT_ID/refsheet-site-ci:$REVISION_ID'
# id: Karma
# dir: /app
# args: ['bin/entrypoint.ci.sh', 'yarn', 'run', 'test']
# waitFor:
# - Build Container
- name: 'gcr.io/$PROJECT_ID/refsheet-site-ci:$REVISION_ID'
id: Prettier Check
dir: /app
args: ['bin/entrypoint.ci.sh', 'yarn', 'run', 'prettier-check']
waitFor:
- Build Container
- name: 'gcr.io/$PROJECT_ID/refsheet-site-ci:$REVISION_ID'
id: ESLint
dir: /app
args: ['bin/entrypoint.ci.sh', 'yarn', 'run', 'eslint']
waitFor:
- Build Container
- name: 'gcr.io/$PROJECT_ID/refsheet-site-ci:$REVISION_ID'
id: Jest
dir: /app
args: [ 'bin/entrypoint.ci.sh', 'yarn', 'run', 'test' ]
waitFor:
- Build Container
#== TEARDOWN
- name: 'gcr.io/cloud-builders/docker'
id: Stop Postgres
args: ['rm', '--force', 'postgres']
waitFor:
- RSpec Unit
- RSpec Integration
options:
env:
- RAILS_ENV=test
- RACK_ENV=test
- DB_HOST=postgres
- DB_USERNAME=postgres
- DB_PASSWORD=fishsticks
- DB_DATABASE=postgres
- CI=true
- CI_NAME=codeship
- CI_BRANCH=$BRANCH_NAME
- CI_COMMIT_ID=$COMMIT_SHA
- CI_BUILD_NUMBER=$BUILD_ID
- CI_BUILD_URL=https://console.cloud.google.com/cloud-build/builds/${BUILD_ID}?project=${PROJECT_ID}&organizationId=183290543501
machineType: 'N1_HIGHCPU_8'
# Create Secrets with:
# printf "value" | gcloud kms encrypt --plaintext-file=- --ciphertext-file=- --location=global --keyring=refsheet-ci \
# --key=refsheet-ci | base64 -w0
secrets:
- kmsKeyName: projects/refsheet-239409/locations/global/keyRings/refsheet-ci/cryptoKeys/refsheet-ci
secretEnv:
CODECOV_TOKEN: CiQA5Rk5QxccJ1JM+r6g/OJkGe+2xDp1GXSf8CRjvHCc3bNiXU8STQBhT4yKrD63EFjNRI0SGS5BxvxSq48q0UWA3l5QXo5Pj31DpNWl8Fi6Yf3mNumRImTSVMCBgnU/jWd0HQU8p31HTDlJHj5Z/zIS+JsU
timeout: 3600s
tags: ['ci']