Skip to content

Commit 018bccc

Browse files
committed
Simplify auth token handling and inject DSN via env var
1 parent 6eaff53 commit 018bccc

File tree

7 files changed

+25
-49
lines changed

7 files changed

+25
-49
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ jobs:
643643
env:
644644
E2E_TEST_PUBLISH_SCRIPT_NODE_VERSION: ${{ env.DEFAULT_NODE_VERSION }}
645645
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
646+
E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
646647
run: |
647648
cd packages/e2e-tests
648649
yarn test:e2e

packages/e2e-tests/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
auth-token.json
1+
.env

packages/e2e-tests/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
"lint": "run-s lint:prettier lint:eslint",
1414
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
1515
"lint:prettier": "prettier --config ../../.prettierrc.json --check .",
16-
"test:e2e": "run-s test:validate-configuration test:validate-test-app-setups test:validate-auth-token test:run",
16+
"test:e2e": "run-s test:validate-configuration test:validate-test-app-setups test:run",
1717
"test:run": "ts-node run.ts",
1818
"test:validate-configuration": "ts-node validate-verdaccio-configuration.ts",
19-
"test:validate-test-app-setups": "ts-node validate-test-app-setups.ts",
20-
"test:validate-auth-token": "ts-node validate-auth-token.ts"
19+
"test:validate-test-app-setups": "ts-node validate-test-app-setups.ts"
2120
},
2221
"devDependencies": {
2322
"@types/glob": "8.0.0",

packages/e2e-tests/run.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,24 @@ const publishScriptNodeVersion = process.env.E2E_TEST_PUBLISH_SCRIPT_NODE_VERSIO
1616
const DEFAULT_BUILD_TIMEOUT_SECONDS = 60;
1717
const DEFAULT_TEST_TIMEOUT_SECONDS = 60;
1818

19-
let authToken = process.env.E2E_TEST_AUTH_TOKEN;
19+
if (!process.env.E2E_TEST_AUTH_TOKEN) {
20+
console.log(
21+
"No auth token configured! Please configure the E2E_TEST_AUTH_TOKEN environment variable with an auth token that has the scope 'project:read'!",
22+
);
23+
}
2024

21-
try {
22-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-var-requires
23-
authToken = require(path.resolve(__dirname, 'auth-token.json')).authToken;
24-
} catch (e) {
25-
console.log('Failed to parse auth-token.json');
25+
if (!process.env.E2E_TEST_DSN) {
26+
console.log('No DSN configured! Please configure the E2E_TEST_DSN environment variable with a DSN!');
2627
}
2728

28-
if (!authToken) {
29-
console.log('No auth token configured!');
29+
if (!process.env.E2E_TEST_AUTH_TOKEN || !process.env.E2E_TEST_DSN) {
3030
process.exit(1);
3131
}
3232

33+
const envVarsToInject = {
34+
REACT_APP_E2E_TEST_DSN: process.env.E2E_TEST_DSN,
35+
};
36+
3337
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
3438
function groupCIOutput(groupTitle: string, fn: () => void): void {
3539
if (process.env.CI) {
@@ -159,6 +163,10 @@ const recipeResults: RecipeResult[] = recipePaths.map(recipePath => {
159163
encoding: 'utf8',
160164
shell: true, // needed so we can pass the build command in as whole without splitting it up into args
161165
timeout: (recipe.buildTimeoutSeconds ?? DEFAULT_BUILD_TIMEOUT_SECONDS) * 1000,
166+
env: {
167+
...process.env,
168+
...envVarsToInject,
169+
},
162170
});
163171

164172
// Prepends some text to the output build command's output so we can distinguish it from logging in this script
@@ -190,11 +198,11 @@ const recipeResults: RecipeResult[] = recipePaths.map(recipePath => {
190198
cwd: path.dirname(recipePath),
191199
timeout: (test.timeoutSeconds ?? DEFAULT_TEST_TIMEOUT_SECONDS) * 1000,
192200
encoding: 'utf8',
201+
shell: true, // needed so we can pass the test command in as whole without splitting it up into args
193202
env: {
194203
...process.env,
195-
E2E_TEST_AUTH_TOKEN: authToken,
204+
...envVarsToInject,
196205
},
197-
shell: true, // needed so we can pass the test command in as whole without splitting it up into args
198206
});
199207

200208
// Prepends some text to the output test command's output so we can distinguish it from logging in this script

packages/e2e-tests/test-applications/standard-frontend-react/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
2424

25-
!*.d.ts
2625
/test-results/
2726
/playwright-report/
2827
/playwright/.cache/
28+
29+
!*.d.ts

packages/e2e-tests/test-applications/standard-frontend-react/src/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import Index from './pages/Index';
1515
import User from './pages/User';
1616

1717
Sentry.init({
18-
// DSN belongs to "e2e-javascript-standard-frontend-react" project in "sentry-sdks" org
19-
dsn: 'https://[email protected]/4503941750587392',
18+
dsn: process.env.REACT_APP_E2E_TEST_DSN,
2019
integrations: [
2120
new BrowserTracing({
2221
routingInstrumentation: Sentry.reactRouterV6Instrumentation(

packages/e2e-tests/validate-auth-token.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)