Skip to content

Commit

Permalink
WIP: Manually run E2E tests on CI?
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Jul 11, 2023
1 parent 99a0864 commit 16afed9
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 12 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ jobs:
yarn test:integration:ci
job_e2e_tests:
name: E2E (Shard ${{ matrix.shard }}) Tests
name: E2E Test ${{ matrix.test-application }}
# We only run E2E tests for non-fork PRs because the E2E tests require secrets to work and they can't be accessed from forks
# Dependabot PRs sadly also don't have access to secrets, so we skip them as well
if:
Expand All @@ -742,7 +742,7 @@ jobs:
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
test-application: ['node-express-app', 'create-react-app']

steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
Expand All @@ -765,18 +765,31 @@ jobs:
id: versions
run: |
echo "echo node=$(jq -r '.volta.node' package.json)" >> $GITHUB_OUTPUT
- name: Run E2E tests
- name: Validate Verdaccio
run: yarn test:validate
working-directory: packages/e2e-tests

- name: Prepare Verdaccio
run: yarn test:prepare
working-directory: packages/e2e-tests
env:
E2E_TEST_PUBLISH_SCRIPT_NODE_VERSION: ${{ steps.versions.outputs.node }}
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks'
E2E_TEST_SENTRY_TEST_PROJECT: 'sentry-javascript-e2e-tests'
E2E_TEST_SHARD: ${{ matrix.shard }}
E2E_TEST_SHARD_AMOUNT: 4

- name: Run E2E test
env:
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks'
E2E_TEST_SENTRY_TEST_PROJECT: 'sentry-javascript-e2e-tests'
working-directory: packages/e2e-tests/test-applications/${{ matrix.test-application }}
run: |
cd packages/e2e-tests
yarn test:e2e
yarn test:build
yarn test:assert
job_required_tests:
name: All required tests passed or skipped
Expand Down
2 changes: 2 additions & 0 deletions packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"test:run": "ts-node run.ts",
"test:validate-configuration": "ts-node validate-verdaccio-configuration.ts",
"test:validate-test-app-setups": "ts-node validate-test-app-setups.ts",
"test:prepare": "ts-node prepare.ts",
"test:validate": "run-s test:validate-configuration test:validate-test-app-setups",
"clean": "rimraf tmp test-applications/**/node_modules test-applications/**/dist"
},
"devDependencies": {
Expand Down
24 changes: 24 additions & 0 deletions packages/e2e-tests/prepare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-disable max-lines */
/* eslint-disable no-console */
import * as dotenv from 'dotenv';

import { validate } from './lib/validate';
import { registrySetup } from './registrySetup';

async function run(): Promise<void> {
// Load environment variables from .env file locally
dotenv.config();

if (!validate()) {
process.exit(1);
}

try {
registrySetup();
} catch (error) {
console.error(error);
process.exit(1);
}
}

void run();
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"test:build": "pnpm install && pnpm build",
"test:assert": "yarn -v"
},
"eslintConfig": {
"extends": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"scripts": {
"build": "tsc",
"start": "node dist/app.js",
"test": "playwright test"
"test": "playwright test",
"test:build": "pnpm install && pnpm build",
"test:assert": "pnpm test"
},
"dependencies": {
"@sentry/integrations": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const config: PlaywrightTestConfig = {
/* Run your local dev server before starting the tests */
webServer: {
command: 'pnpm start',
port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO),
port: 9000,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ declare global {

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN,
dsn: process.env.E2E_TEST_DSN,
integrations: [new Integrations.HttpClient()],
debug: true,
tracesSampleRate: 1,
});

const app = express();
const port = Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO);
const port = 8000;

app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
Expand Down

0 comments on commit 16afed9

Please sign in to comment.