MCPcopy Create free account
hub / github.com/angular/dev-infra / main

Function main

github-actions/bazel/configure-remote/index.ts:18–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16import {exportVariable, getBooleanInput, getInput} from '@actions/core';
17
18async function main() {
19 const isWindows = os.platform() === 'win32';
20 const bazelRcPath = getInput('bazelrc', {required: false, trimWhitespace: true});
21 const allowWindowsRbe = getBooleanInput('allow_windows_rbe', {required: true});
22 const trustedBuild = getBooleanInput('trusted_build', {required: false});
23 const credential =
24 getInput('google_credential', {required: false, trimWhitespace: true}) ||
25 getEmbeddedCredential();
26
27 const destPath = isWindows
28 ? path.join(process.env.APPDATA!, 'gcloud/application_default_credentials.json')
29 : path.join(process.env.HOME!, '.config/gcloud/application_default_credentials.json');
30
31 await fs.promises.mkdir(path.dirname(destPath), {recursive: true});
32 await fs.promises.writeFile(destPath, credential, 'utf8');
33
34 const configMode = isWindows && !allowWindowsRbe ? 'remote-cache' : 'remote';
35
36 if (bazelRcPath) {
37 let content = await readFileGracefully(bazelRcPath);
38 content += ['', `build --config=${configMode}`, 'test --flaky_test_attempts=3'].join('\n');
39 if (trustedBuild) {
40 content += `\nbuild --config=trusted-build`;
41 }
42 await fs.promises.writeFile(bazelRcPath, content, 'utf8');
43 }
44
45 // Expose application credentials as variable. This may not be necessary with the default
46 // path being used for credentials, but it's helpful when we cross boundaries with e.g. WSL.
47 exportVariable('GOOGLE_APPLICATION_CREDENTIALS', destPath);
48}
49
50async function readFileGracefully(filePath: string): Promise<string> {
51 try {

Callers 1

index.tsFile · 0.70

Calls 5

getInputFunction · 0.85
getBooleanInputFunction · 0.85
getEmbeddedCredentialFunction · 0.70
readFileGracefullyFunction · 0.70
exportVariableFunction · 0.70

Tested by

no test coverage detected