Skip to content

Commit 4007dba

Browse files
committed
ci(markdown): migrate renderer, editor to new CI
1 parent 9a866b8 commit 4007dba

File tree

11 files changed

+60
-28
lines changed

11 files changed

+60
-28
lines changed

.github/config/nodejs-prod.jsonc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
"iam/deny", // PERMISSION_DENIED: Permission iam.googleapis.com/denypolicies.create denied on resource cloudresourcemanager.googleapis.com/projects/long-door-651
100100
"recaptcha_enterprise/snippets", // Cannot use import statement outside a module
101101
"run/idp-sql", // (untested) Error: Invalid contents in the credentials file
102-
"run/markdown-preview/editor", // (untested) Error: could not create an identity token: Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file
103102
"scheduler", // SyntaxError: Cannot use import statement outside a module
104103
"storagetransfer", // CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
105104
"video-intelligence", // PERMISSION_DENIED: The caller does not have permission
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"env": {
3+
"SERVICE_NAME": "markdown-renderer-$RUN_ID",
4+
"SAMPLE_VERSION": "$RUN_ID"
5+
}
6+
}

run/markdown-preview/editor/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"main": "main.js",
1616
"scripts": {
1717
"start": "node index.js",
18-
"test": "c8 mocha -p -j 2 test/app.test.js --timeout=10000 --exit",
18+
"test": "npm -- run all-test",
19+
"all-test": "npm run unit-test && npm run system-test",
20+
"unit-test": "c8 mocha -p -j 2 test/app.test.js --timeout=10000 --exit",
1921
"system-test": "c8 mocha -p -j 2 test/system.test.js --timeout=480000 --exit"
2022
},
2123
"dependencies": {

run/markdown-preview/editor/test/e2e_test_cleanup.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,23 @@ steps:
99
./test/retry.sh "gcloud container images describe gcr.io/${PROJECT_ID}/renderer-${_SERVICE}:${_VERSION}" \
1010
"gcloud container images delete gcr.io/${PROJECT_ID}/renderer-${_SERVICE}:${_VERSION} --quiet"
1111
12-
./test/retry.sh "gcloud run services describe renderer-${_SERVICE} --region ${_REGION} --platform ${_PLATFORM}" \
13-
"gcloud run services delete renderer-${_SERVICE} --region ${_REGION} --platform ${_PLATFORM} --quiet"
12+
./test/retry.sh "gcloud run services describe renderer-${_SERVICE} --region ${_REGION}" \
13+
"gcloud run services delete renderer-${_SERVICE} --region ${_REGION} --quiet"
1414
1515
./test/retry.sh "gcloud container images describe gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION}" \
1616
"gcloud container images delete gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION} --quiet"
1717
18-
./test/retry.sh "gcloud run services describe ${_SERVICE} --region ${_REGION} --platform ${_PLATFORM}" \
19-
"gcloud run services delete ${_SERVICE} --region ${_REGION} --platform ${_PLATFORM} --quiet"
18+
./test/retry.sh "gcloud run services describe ${_SERVICE} --region ${_REGION}" \
19+
"gcloud run services delete ${_SERVICE} --region ${_REGION} --quiet"
2020
2121
substitutions:
2222
_SERVICE: editor
2323
_VERSION: manual
2424
_REGION: us-central1
2525
_PLATFORM: managed
26+
_SERVICE_ACCOUNT: ${PROJECT_NUMBER}@cloudbuild.gserviceaccount.com
27+
28+
serviceAccount: 'projects/${PROJECT_ID}/serviceAccounts/${_SERVICE_ACCOUNT}'
29+
options:
30+
logging: CLOUD_LOGGING_ONLY
31+
dynamicSubstitutions: true

run/markdown-preview/editor/test/e2e_test_setup.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ steps:
1717
- |
1818
echo $(gcloud run services describe renderer-${_SERVICE} \
1919
--region ${_REGION} \
20-
--format='value(status.url)' \
21-
--platform ${_PLATFORM}) > _service_url
20+
--format='value(status.url)') > _service_url
2221
2322
./test/retry.sh "gcloud run deploy ${_SERVICE} \
2423
--image gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION} \
2524
--no-allow-unauthenticated \
2625
--region ${_REGION} \
27-
--platform ${_PLATFORM} \
2826
--set-env-vars EDITOR_UPSTREAM_RENDER_URL=$(cat _service_url)"
2927
3028
images:
@@ -35,3 +33,9 @@ substitutions:
3533
_VERSION: manual
3634
_REGION: us-central1
3735
_PLATFORM: managed
36+
_SERVICE_ACCOUNT: ${PROJECT_NUMBER}@cloudbuild.gserviceaccount.com
37+
38+
serviceAccount: 'projects/${PROJECT_ID}/serviceAccounts/${_SERVICE_ACCOUNT}'
39+
options:
40+
logging: CLOUD_LOGGING_ONLY
41+
dynamicSubstitutions: true

run/markdown-preview/editor/test/system.test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ describe('End-to-End Tests', () => {
2929
console.log('"SERVICE_NAME" env var not found. Defaulting to "editor"');
3030
SERVICE_NAME = 'editor';
3131
}
32+
const {ID_TOKEN} = process.env;
33+
if (!ID_TOKEN) throw Error('ID token not in envvar');
3234
const {SAMPLE_VERSION} = process.env;
3335
const PLATFORM = 'managed';
3436
const REGION = 'us-central1';
3537

36-
let BASE_URL, ID_TOKEN;
38+
let BASE_URL;
3739
before(async () => {
3840
// Deploy Renderer service
3941
let buildRendererCmd =
@@ -60,15 +62,10 @@ describe('End-to-End Tests', () => {
6062
// Retrieve URL of Cloud Run service
6163
const url = execSync(
6264
`gcloud run services describe ${SERVICE_NAME} --project=${GOOGLE_CLOUD_PROJECT} ` +
63-
`--platform=${PLATFORM} --region=${REGION} --format='value(status.url)'`
65+
`--region=${REGION} --format='value(status.url)'`
6466
);
6567
BASE_URL = url.toString('utf-8').trim();
6668
if (!BASE_URL) throw Error('Cloud Run service URL not found');
67-
68-
const client = await auth.getIdTokenClient(BASE_URL);
69-
const clientHeaders = await client.getRequestHeaders();
70-
ID_TOKEN = clientHeaders['Authorization'];
71-
if (!ID_TOKEN) throw Error('ID token could not be created');
7269
});
7370

7471
after(() => {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"env": {
3+
"SERVICE_NAME": "markdown-renderer-$RUN_ID",
4+
"SAMPLE_VERSION": "$RUN_ID"
5+
}
6+
}

run/markdown-preview/renderer/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"main": "index.js",
1515
"scripts": {
1616
"start": "node index.js",
17-
"test": "c8 mocha -p -j 2 test/app.test.js --exit",
17+
"test": "npm -- run all-test",
18+
"all-test": "npm run unit-test && npm run system-test",
19+
"unit-test": "c8 mocha -p -j 2 test/app.test.js --exit",
1820
"system-test": "c8 mocha -p -j 2 test/system.test.js --timeout=360000 --exit"
1921
},
2022
"dependencies": {

run/markdown-preview/renderer/test/e2e_test_cleanup.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ steps:
99
./test/retry.sh "gcloud container images describe gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION}" \
1010
"gcloud container images delete gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION} --quiet"
1111
12-
./test/retry.sh "gcloud run services describe ${_SERVICE} --region ${_REGION} --platform ${_PLATFORM}" \
13-
"gcloud run services delete ${_SERVICE} --region ${_REGION} --platform ${_PLATFORM} --quiet"
12+
./test/retry.sh "gcloud run services describe ${_SERVICE} --region ${_REGION}" \
13+
"gcloud run services delete ${_SERVICE} --region ${_REGION} --quiet"
1414
1515
substitutions:
1616
_SERVICE: renderer
1717
_VERSION: manual
1818
_REGION: us-central1
1919
_PLATFORM: managed
20+
_SERVICE_ACCOUNT: ${PROJECT_NUMBER}@cloudbuild.gserviceaccount.com
21+
22+
serviceAccount: 'projects/${PROJECT_ID}/serviceAccounts/${_SERVICE_ACCOUNT}'
23+
options:
24+
logging: CLOUD_LOGGING_ONLY
25+
dynamicSubstitutions: true

run/markdown-preview/renderer/test/e2e_test_setup.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ steps:
2626
--image gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION} \
2727
--no-allow-unauthenticated \
2828
--region ${_REGION} \
29-
--platform ${_PLATFORM}"
29+
--add-custom-audiences="https://action.test/" "
3030
3131
images:
3232
- gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION}
@@ -35,4 +35,10 @@ substitutions:
3535
_SERVICE: renderer
3636
_VERSION: manual
3737
_REGION: us-central1
38-
_PLATFORM: managed
38+
_SERVICE_ACCOUNT: ${PROJECT_NUMBER}@cloudbuild.gserviceaccount.com
39+
40+
serviceAccount: 'projects/${PROJECT_ID}/serviceAccounts/${_SERVICE_ACCOUNT}'
41+
options:
42+
logging: CLOUD_LOGGING_ONLY
43+
dynamicSubstitutions: true
44+

0 commit comments

Comments
 (0)