Skip to content

Commit ebde58f

Browse files
committed
chore: use ada auth for viewing e2e artifacts
1 parent b6113bd commit ebde58f

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
"cloud-e2e": "source scripts/cloud-utils.sh && cloudE2E",
4141
"cloud-e2e-beta": "source scripts/cloud-utils.sh && cloudE2EBeta",
4242
"split-e2e-tests": "yarn ts-node ./scripts/split-e2e-tests.ts && git add .codebuild/e2e_workflow.yml",
43-
"view-test-artifacts": "yarn ts-node ./scripts/view-test-artifacts.ts",
44-
"cloud-e2e-debug": "source scripts/cloud-utils.sh && cloudE2EDebug"
43+
"view-test-artifacts": "yarn authenticate-e2e-profile && yarn ts-node ./scripts/view-test-artifacts.ts",
44+
"cloud-e2e-debug": "source scripts/cloud-utils.sh && cloudE2EDebug",
45+
"authenticate-e2e-profile": "source scripts/cloud-utils.sh && authenticateWithE2EProfile"
4546
},
4647
"bugs": {
4748
"url": "https://github.com/aws-amplify/amplify-codegen/issues"

scripts/cloud-utils.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,9 @@ function generatedDebugSpecForFailedTests {
134134
fi
135135
echo $failed_tests | xargs yarn ts-node ./scripts/split-e2e-tests.ts --debug
136136
}
137+
138+
function authenticateWithE2EProfile {
139+
E2E_ROLE_NAME=CodebuildDeveloper
140+
E2E_PROFILE_NAME=AmplifyAPIE2EProd
141+
authenticate $E2E_ACCOUNT_PROD $E2E_ROLE_NAME $E2E_PROFILE_NAME
142+
}

scripts/view-test-artifacts.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
/**
22
* Usage: `yarn view-test-artifacts <buildBatchId>`
3-
*
4-
* N.B. It is important to have your local environment configured for the correct codebuild account before running the script.
5-
* This script caches resources, but in the case the local resource state is out of sync, you may need to wipe the asset directory
6-
* that is printed when the script begins.
73
*/
84

95
import * as process from 'process';
106
import * as path from 'path';
117
import * as os from 'os';
128
import * as fs from 'fs-extra';
139
// eslint-disable-next-line import/no-extraneous-dependencies
14-
import { CodeBuild, S3 } from 'aws-sdk';
10+
import { CodeBuild, S3, SharedIniFileCredentials } from 'aws-sdk';
1511
// eslint-disable-next-line import/no-extraneous-dependencies
1612
import { SingleBar, Presets } from 'cli-progress';
1713
import * as execa from 'execa';
1814

19-
const s3 = new S3();
15+
const E2E_PROFILE_NAME = 'AmplifyAPIE2EProd';
16+
const credentials = new SharedIniFileCredentials({ profile: E2E_PROFILE_NAME });
17+
const s3 = new S3({ credentials });
18+
const codeBuild = new CodeBuild({ credentials, region: 'us-east-1' });
2019
const progressBar = new SingleBar({}, Presets.shades_classic);
2120

2221
type BuildStatus = 'FAILED' | 'FAULT' | 'IN_PROGRESS' | 'STOPPED' | 'SUCCEEDED' | 'TIMED_OUT';
@@ -82,7 +81,6 @@ const generateIndexFile = (directory: string, artifacts: TestArtifact[]): void =
8281
* @param batchId the batch to look up.
8382
*/
8483
const retrieveArtifactsForBatch = async (batchId: string): Promise<TestArtifact[]> => {
85-
const codeBuild = new CodeBuild({ region: 'us-east-1' });
8684
const { buildBatches } = await codeBuild.batchGetBuildBatches({ ids: [batchId] }).promise();
8785
return (buildBatches || [])
8886
.flatMap((batch) =>

0 commit comments

Comments
 (0)