Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8826f70

Browse files
author
Forest Hoffman
committed
Use encrypted file to define GCP credentials on CI
1 parent c8257e3 commit 8826f70

File tree

6 files changed

+38
-22
lines changed

6 files changed

+38
-22
lines changed

‎.travis.yml‎

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@ language: node_js
22
node_js:
33
- 10.15.1
44
env:
5+
matrix:
56
- VSCODE_VERSION="1.33.1" MAJOR_VERSION="1" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER-vsc$VSCODE_VERSION"
67
matrix:
78
include:
8-
- os: linux
9-
dist: trusty
10-
- os: osx
9+
- os: linux
10+
dist: trusty
11+
- os: osx
1112
before_install:
12-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
13-
sudo apt-get install -y libxkbfile-dev libsecret-1-dev; fi
14-
- npm install -g yarn@1.12.3
13+
- openssl aes-256-cbc -K $encrypted_31e0a178b4fd_key -iv $encrypted_31e0a178b4fd_iv
14+
-in test/.coder-gcp-credentials.json.enc -out test/.coder-gcp-credentials.json -d
15+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
16+
sudo apt-get install -y libxkbfile-dev libsecret-1-dev; fi
17+
- npm install -g yarn@1.12.3
1518
script:
16-
- scripts/build.sh
19+
- scripts/build.sh
1720
before_deploy:
18-
- echo "$VERSION" "$TRAVIS_COMMIT"
19-
- git config --local user.name "$USER_NAME"
20-
- git config --local user.email "$USER_EMAIL"
21-
- git tag "$VERSION" "$TRAVIS_COMMIT"
22-
- yarn task package "$VERSION"
21+
- echo "$VERSION" "$TRAVIS_COMMIT"
22+
- git config --local user.name "$USER_NAME"
23+
- git config --local user.email "$USER_EMAIL"
24+
- git tag "$VERSION" "$TRAVIS_COMMIT"
25+
- yarn task package "$VERSION"
2326
deploy:
2427
provider: releases
2528
file_glob: true
@@ -31,13 +34,13 @@ deploy:
3134
api_key:
3235
secure: YL/x24KjYjgYXPcJWk3FV7FGxI79Mh6gBECQEcdlf3fkLEoKFVgzHBoUNWrFPzyR4tgLyWNAgcpD9Lkme1TRWTom7UPjXcwMNyLcLa+uec7ciSAnYD9ntLTpiCuPDD1u0LtRGclSi/EHQ+F8YVq+HZJpXTsJeAmOmihma3GVbGKSZr+BRum+0YZSG4w+o4TOlYzw/4bLWS52MogZcwpjd+hemBbgXLuGU2ziKv2vEKCZFbEeA16II4x1WLI4mutDdCeh7+3aLzGLwDa49NxtsVYNjyNFF75JhCTCNA55e2YMiLz9Uq69IXe/mi5F7xUaFfhIqqLNyKBnKeEOzu3dYnc+8n3LjnQ+00PmkF05nx9kBn3UfV1kwQGh6QbyDmTtBP07rtUMyI14aeQqHjxsaVRdMnwj9Q2DjXRr8UDqESZF0rmK3pHCXS2fBhIzLE8tLVW5Heiba2pQRFMHMZW+KBE97FzcFh7is90Ait3T8enfcd/PWFPYoBejDAdjwxwOkezh5N5ZkYquEfDYuWrFi6zRFCktsruaAcA+xGtTf9oilBBzUqu8Ie+YFWH5me83xakcblJWdaW/D2rLJAJH3m6LFm8lBqyUgDX5t/etob6CpDuYHu5D1J3XINOj/+aLAcadq6qlh70PMZS3zYffUu3JlzaD2amlSHIT8b5YXFc=
3336
file:
34-
- release/*.tar.gz
35-
- release/*.zip
37+
- release/*.tar.gz
38+
- release/*.zip
3639
on:
3740
repo: codercom/code-server
3841
branch: master
3942
cache:
4043
yarn: true
4144
timeout: 1000
4245
directories:
43-
- .cache
46+
- ".cache"

‎test/.coder-gcp-credentials.json.enc‎

2.22 KB
Binary file not shown.

‎test/.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
tmp/
1+
tmp/
2+
.*credentials.json

‎test/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
"jest": "^24.7.1",
5151
"node-fetch": "^2.3.0"
5252
}
53-
}
53+
}

‎test/src/index.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,20 @@ export class TestPage {
155155
const img = await this.rootPage.screenshot(options);
156156
this.screenshotCount++;
157157

158+
// If this is a Travis CI build, store the screenshots
159+
// for later.
158160
if (process.env.TRAVIS_OS_NAME && process.env.TRAVIS_BUILD_NUMBER) {
159161
const bucketPath = `Travis-${process.env.TRAVIS_BUILD_NUMBER}/${fileName}`;
160162
let buf: Buffer = typeof img === "string" ? Buffer.from(img as string) : img;
161163
try {
162164
const url = await bucket.write(bucketPath, buf);
163-
logger.info("captured screenshot",
165+
logger.info("stored screenshot",
164166
field("localPath", options.path),
165167
field("bucketPath", bucketPath),
166168
field("url", url),
167169
);
168170
} catch (ex) {
169-
logger.warn("failed to capture screenshot",
171+
logger.warn("failed to store screenshot",
170172
field("exception", ex),
171173
field("targetPath", bucketPath),
172174
);

‎test/storage/gcloud.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import * as Storage from "@google-cloud/storage";
22
import { File, Bucket, IMetadata } from "./bucket";
3+
import * as path from "path";
4+
import { existsSync } from "fs";
35

4-
const ScreenshotBucketName = "coder-dev-1-ci-screenshots";
6+
const screenshotBucketName = "coder-dev-1-ci-screenshots";
7+
// The path to the credentials must be relative to the environment in
8+
// which the tests are being run, because the gcloud package
9+
// relies on the session's $GOOGLE_APPLICATION_CREDENTIALS.
10+
// Otherwise, this could be statically defined in the CI config.
11+
const gcpCredentialsPath = path.resolve(__dirname, "../.coder-gcp-credentials.json");
512

613
/**
714
* GCP Storage Bucket Wrapper.
@@ -14,7 +21,10 @@ export class GoogleCloudBucket extends Bucket {
1421
const storage = new Storage.Storage({
1522
projectId: "coder-dev-1",
1623
});
17-
this.bucket = storage.bucket(ScreenshotBucketName);
24+
if (!process.env.GOOGLE_APPLICATION_CREDENTIALS && existsSync(gcpCredentialsPath)) {
25+
process.env.GOOGLE_APPLICATION_CREDENTIALS = gcpCredentialsPath;
26+
}
27+
this.bucket = storage.bucket(screenshotBucketName);
1828
}
1929

2030
/**
@@ -93,7 +103,7 @@ export class GoogleCloudBucket extends Bucket {
93103
return;
94104
}
95105
}
96-
resolve(makePublic ? `https://storage.googleapis.com/${ScreenshotBucketName}${path}` : undefined);
106+
resolve(makePublic ? `https://storage.googleapis.com/${screenshotBucketName}${path}` : undefined);
97107
});
98108

99109
stream.end(data);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /