Skip to content

Commit aafe258

Browse files
scstorytelsethvargo
authored andcommitted
Merge branch 'main' into add-support-for-jobs
2 parents e3f2a65 + 016eb23 commit aafe258

File tree

11 files changed

+498
-2952
lines changed

11 files changed

+498
-2952
lines changed

.github/workflows/cleanup.yml

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,27 @@ jobs:
1414
runs-on: 'ubuntu-latest'
1515

1616
steps:
17-
- uses: 'actions/checkout@v4'
18-
19-
- uses: 'google-github-actions/auth@v2'
20-
with:
21-
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
22-
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
23-
24-
- uses: 'google-github-actions/setup-gcloud@v2'
25-
26-
- name: Delete services
27-
run: |-
28-
gcloud config set core/project "${{ vars.PROJECT_ID }}"
29-
gcloud config set run/region "us-central1"
30-
31-
# List and delete all services that were deployed 30 minutes ago or
32-
# earlier. The date math here is a little weird, but we're looking for
33-
# deployments "earlier than" 30 minutes ago, so it's less than since
34-
# time increases.
35-
(IFS=$'\n'; for NAME in $(gcloud run services list --format="value(name)" --filter="metadata.creationTimestamp < '-pt30m'"); do
36-
echo "Deleting ${NAME}..."
37-
gcloud run services delete ${NAME} --quiet --async
38-
done)
17+
- uses: 'actions/checkout@v4'
18+
19+
- uses: 'google-github-actions/auth@v2'
20+
with:
21+
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
22+
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
23+
24+
- uses: 'google-github-actions/setup-gcloud@v2'
25+
with:
26+
version: 'latest'
27+
28+
- name: 'Delete services'
29+
run: |-
30+
gcloud config set core/project "${{ vars.PROJECT_ID }}"
31+
gcloud config set run/region "us-central1"
32+
33+
# List and delete all services that were deployed 30 minutes ago or
34+
# earlier. The date math here is a little weird, but we're looking for
35+
# deployments "earlier than" 30 minutes ago, so it's less than since
36+
# time increases.
37+
(IFS=$'\n'; for NAME in $(gcloud run services list --format="value(name)" --filter="metadata.creationTimestamp < '-pt30m'"); do
38+
echo "Deleting ${NAME}..."
39+
gcloud run services delete ${NAME} --quiet --async
40+
done)

.github/workflows/integration.yml

Lines changed: 187 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -28,134 +28,200 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
include:
31-
- name: 'image'
32-
image: 'gcr.io/cloudrun/hello'
33-
- name: 'source'
34-
source: 'example-app'
31+
- name: 'image'
32+
image: 'gcr.io/cloudrun/hello'
33+
- name: 'source'
34+
source: 'example-app'
3535

3636
name: 'from_${{ matrix.name }}'
3737

3838
steps:
39-
- uses: 'actions/checkout@v4'
40-
41-
- name: 'Compute service name'
42-
run: |-
43-
echo "SERVICE_NAME=${GITHUB_JOB}-${{ matrix.name }}-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV}
44-
45-
- uses: 'actions/setup-node@v4'
46-
with:
47-
node-version: '20.x'
48-
49-
- run: 'npm ci && npm run build'
50-
51-
- uses: 'google-github-actions/auth@v2'
52-
with:
53-
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
54-
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
55-
56-
- id: 'deploy-cloudrun'
57-
name: 'Deploy'
58-
uses: './'
59-
with:
60-
image: '${{ matrix.image }}'
61-
source: '${{ matrix.source }}'
62-
service: '${{ env.SERVICE_NAME }}'
63-
env_vars: |-
64-
FOO=bar
65-
ZIP=zap
66-
env_vars_file: './tests/fixtures/env_vars.txt'
67-
secrets: |-
68-
MY_SECRET=${{ vars.SECRET_NAME }}:latest
69-
MY_SECOND_SECRET=${{ vars.SECRET_NAME }}:1
70-
labels: |-
71-
label1=value1
72-
label2=value2
73-
skip_default_labels: true
74-
flags: '--cpu=2 --concurrency=20'
75-
76-
- run: 'npm run e2e-tests'
77-
env:
78-
PROJECT_ID: ${{ vars.PROJECT_ID }}
79-
SERVICE: '${{ env.SERVICE_NAME }}'
80-
ENV: 'FOO=bar,ZIP=zap,TEXT_FOO=bar,TEXT_ZIP=zap'
81-
SECRET_ENV: MY_SECRET=${{ vars.SECRET_NAME }}:latest,MY_SECOND_SECRET=${{ vars.SECRET_NAME }}:1
82-
PARAMS: '{"cpu":2, "containerConcurrency":20}'
83-
LABELS: '{"label1":"value1", "label2":"value2"}'
84-
85-
- id: 'deploy-cloudrun-again'
86-
name: 'Deploy again'
87-
uses: './'
88-
with:
89-
image: '${{ matrix.image }}'
90-
source: '${{ matrix.source }}'
91-
service: '${{ env.SERVICE_NAME }}'
92-
env_vars: |-
93-
ABC=123
94-
DEF=456
95-
secrets: /api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest
96-
97-
- run: 'npm run e2e-tests'
98-
env:
99-
PROJECT_ID: ${{ vars.PROJECT_ID }}
100-
SERVICE: '${{ env.SERVICE_NAME }}'
101-
ENV: 'FOO=bar,ZIP=zap,TEXT_FOO=bar,TEXT_ZIP=zap,ABC=123,DEF=456'
102-
SECRET_ENV: MY_SECRET=${{ vars.SECRET_NAME }}:latest,MY_SECOND_SECRET=${{ vars.SECRET_NAME }}:1
103-
SECRET_VOLUMES: /api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest
104-
PARAMS: '{"cpu":2, "containerConcurrency":20}'
105-
LABELS: '{"label1":"value1", "label2":"value2", "commit-sha":"${{ github.sha }}", "managed-by":"github-actions"}'
106-
REVISION_COUNT: 2
39+
- uses: 'actions/checkout@v4'
40+
41+
- name: 'Compute service name'
42+
run: |-
43+
echo "SERVICE_NAME=${GITHUB_JOB}-${{ matrix.name }}-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV}
44+
45+
- uses: 'actions/setup-node@v4'
46+
with:
47+
node-version: '20.x'
48+
49+
- run: 'npm ci && npm run build'
50+
51+
- uses: 'google-github-actions/auth@v2'
52+
with:
53+
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
54+
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
55+
56+
- id: 'deploy-cloudrun'
57+
name: 'Deploy'
58+
uses: './'
59+
with:
60+
image: '${{ matrix.image }}'
61+
source: '${{ matrix.source }}'
62+
service: '${{ env.SERVICE_NAME }}'
63+
env_vars: |-
64+
FOO=bar
65+
ZIP=zap\,with|separators\,and&stuff
66+
env_vars_file: './tests/fixtures/env_vars.txt'
67+
secrets: |-
68+
MY_SECRET=${{ vars.SECRET_NAME }}:latest
69+
MY_SECOND_SECRET=${{ vars.SECRET_NAME }}:1
70+
labels: |-
71+
label1=value1
72+
label2=value2
73+
skip_default_labels: true
74+
flags: '--cpu=2 --concurrency=20'
75+
76+
- name: 'Run initial deploy tests'
77+
run: 'npm run e2e-tests'
78+
env:
79+
PROJECT_ID: ${{ vars.PROJECT_ID }}
80+
SERVICE: '${{ env.SERVICE_NAME }}'
81+
ENV: |-
82+
{
83+
"FOO": "bar",
84+
"ZIP": "zap,with|separators,and&stuff",
85+
"TEXT_FOO": "bar",
86+
"TEXT_ZIP": "zap,with|separators,and&stuff"
87+
}
88+
SECRET_ENV: |-
89+
{
90+
"MY_SECRET": "${{ vars.SECRET_NAME }}:latest",
91+
"MY_SECOND_SECRET": "${{ vars.SECRET_NAME }}:1"
92+
}
93+
PARAMS: |-
94+
{
95+
"cpu": "2",
96+
"containerConcurrency": "20"
97+
}
98+
LABELS: |-
99+
{
100+
"label1": "value1",
101+
"label2": "value2"
102+
}
103+
104+
- id: 'deploy-cloudrun-again'
105+
name: 'Deploy again'
106+
uses: './'
107+
with:
108+
image: '${{ matrix.image }}'
109+
source: '${{ matrix.source }}'
110+
service: '${{ env.SERVICE_NAME }}'
111+
env_vars: |-
112+
ABC=123
113+
DEF=456
114+
secrets: /api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest
115+
116+
- name: 'Run re-deploy tests'
117+
run: 'npm run e2e-tests'
118+
env:
119+
PROJECT_ID: ${{ vars.PROJECT_ID }}
120+
SERVICE: '${{ env.SERVICE_NAME }}'
121+
ENV: |-
122+
{
123+
"FOO": "bar",
124+
"ZIP": "zap,with|separators,and&stuff",
125+
"TEXT_FOO": "bar",
126+
"TEXT_ZIP": "zap,with|separators,and&stuff",
127+
"ABC": "123",
128+
"DEF": "456"
129+
}
130+
SECRET_ENV: |-
131+
{
132+
"MY_SECRET": "${{ vars.SECRET_NAME }}:latest",
133+
"MY_SECOND_SECRET": "${{ vars.SECRET_NAME }}:1"
134+
}
135+
SECRET_VOLUMES: |-
136+
{
137+
"/api/secrets/my-secret": "${{ vars.SECRET_NAME }}:latest"
138+
}
139+
PARAMS: |-
140+
{
141+
"cpu": "2",
142+
"containerConcurrency": "20"
143+
}
144+
LABELS: |-
145+
{
146+
"label1": "value1",
147+
"label2": "value2",
148+
"commit-sha": "${{ github.sha }}",
149+
"managed-by": "github-actions"
150+
}
151+
REVISION_COUNT: 2
107152

108153
metadata:
109154
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }}
110155
runs-on: 'ubuntu-latest'
111156

112157
steps:
113-
- uses: 'actions/checkout@v4'
114-
115-
- name: 'Compute service name'
116-
run: |-
117-
echo "SERVICE_NAME=${GITHUB_JOB}-metadata-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV}
118-
119-
- name: 'Set service name in metadata YAML'
120-
run: |-
121-
sed -i "s/run-full-yaml/${{ env.SERVICE_NAME }}/" ./tests/unit/service.yaml
122-
123-
- uses: 'actions/setup-node@v4'
124-
with:
125-
node-version: '20.x'
126-
127-
- run: 'npm ci && npm run build'
128-
129-
- uses: 'google-github-actions/auth@v2'
130-
with:
131-
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
132-
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
133-
134-
- id: 'deploy-cloudrun'
135-
name: 'Deploy'
136-
uses: './'
137-
with:
138-
metadata: './tests/unit/service.yaml'
139-
140-
- run: 'npm run e2e-tests'
141-
env:
142-
PROJECT_ID: '${{ vars.PROJECT_ID }}'
143-
SERVICE: '${{ env.SERVICE_NAME }}'
144-
PARAMS: '{"cpu":2, "memory":"1Gi", "containerConcurrency":20}'
145-
ANNOTATIONS: '{"run.googleapis.com/cloudsql-instances":"test-project:us-central1:my-test-instance"}'
146-
LABELS: '{"test_label":"test_value"}'
147-
148-
- id: 'deploy-cloudrun-again'
149-
name: 'Deploy again'
150-
uses: './'
151-
with:
152-
image: 'gcr.io/cloudrun/hello'
153-
service: '${{ env.SERVICE_NAME }}'
154-
155-
- run: 'npm run e2e-tests' # Check that config isn't overwritten
156-
env:
157-
PROJECT_ID: '${{ vars.PROJECT_ID }}'
158-
SERVICE: '${{ env.SERVICE_NAME }}'
159-
PARAMS: '{"cpu":2, "memory":"1Gi", "containerConcurrency":20}'
160-
ANNOTATIONS: '{"run.googleapis.com/cloudsql-instances":"test-project:us-central1:my-test-instance"}'
161-
REVISION_COUNT: 2
158+
- uses: 'actions/checkout@v4'
159+
160+
- name: 'Compute service name'
161+
run: |-
162+
echo "SERVICE_NAME=${GITHUB_JOB}-metadata-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV}
163+
164+
- name: 'Set service name in metadata YAML'
165+
run: |-
166+
sed -i "s/run-full-yaml/${{ env.SERVICE_NAME }}/" ./tests/unit/service.yaml
167+
168+
- uses: 'actions/setup-node@v4'
169+
with:
170+
node-version: '20.x'
171+
172+
- run: 'npm ci && npm run build'
173+
174+
- uses: 'google-github-actions/auth@v2'
175+
with:
176+
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
177+
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
178+
179+
- id: 'deploy-cloudrun'
180+
name: 'Deploy'
181+
uses: './'
182+
with:
183+
metadata: './tests/unit/service.yaml'
184+
185+
- name: 'Run initial deploy tests'
186+
run: 'npm run e2e-tests'
187+
env:
188+
PROJECT_ID: '${{ vars.PROJECT_ID }}'
189+
SERVICE: '${{ env.SERVICE_NAME }}'
190+
PARAMS: |-
191+
{
192+
"cpu": "2",
193+
"memory": "1Gi",
194+
"containerConcurrency": "20"
195+
}
196+
ANNOTATIONS: |-
197+
{
198+
"run.googleapis.com/cloudsql-instances": "test-project:us-central1:my-test-instance"
199+
}
200+
LABELS: |-
201+
{
202+
"test_label": "test_value"
203+
}
204+
205+
- id: 'deploy-cloudrun-again'
206+
name: 'Deploy again'
207+
uses: './'
208+
with:
209+
image: 'gcr.io/cloudrun/hello'
210+
service: '${{ env.SERVICE_NAME }}'
211+
212+
- name: 'Run re-deploy tests'
213+
run: 'npm run e2e-tests' # Check that config isn't overwritten
214+
env:
215+
PROJECT_ID: '${{ vars.PROJECT_ID }}'
216+
SERVICE: '${{ env.SERVICE_NAME }}'
217+
PARAMS: |-
218+
{
219+
"cpu": "2",
220+
"memory": "1Gi",
221+
"containerConcurrency": "20"
222+
}
223+
ANNOTATIONS: |-
224+
{
225+
"run.googleapis.com/cloudsql-instances": "test-project:us-central1:my-test-instance"
226+
}
227+
REVISION_COUNT: 2

0 commit comments

Comments
 (0)