From 4fba55107671b3fb92764069070b1df7eb668e4e Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Tue, 19 Nov 2024 17:11:13 +0100 Subject: [PATCH] Add traces to integration tests --- .github/workflows/gui.yml | 18 ++++++++++++++++++ .gitignore | 1 + app/ide-desktop/client/tests/electronTest.ts | 3 +++ build/build/src/ci_gen/job.rs | 13 +++++++++++++ 4 files changed, 35 insertions(+) diff --git a/.github/workflows/gui.yml b/.github/workflows/gui.yml index ddc0974c8b..636097eb90 100644 --- a/.github/workflows/gui.yml +++ b/.github/workflows/gui.yml @@ -372,6 +372,12 @@ jobs: ENSO_TEST_USER: ${{ secrets.ENSO_CLOUD_TEST_ACCOUNT_USERNAME }} ENSO_TEST_USER_PASSWORD: ${{ secrets.ENSO_CLOUD_TEST_ACCOUNT_PASSWORD }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - if: failure() + name: Upload Test Traces + uses: actions/upload-artifact@v4 + with: + name: test-traces + path: app/ide-desktop/client/test-traces - run: rm $HOME/.enso/credentials env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -444,6 +450,12 @@ jobs: ENSO_TEST_USER: ${{ secrets.ENSO_CLOUD_TEST_ACCOUNT_USERNAME }} ENSO_TEST_USER_PASSWORD: ${{ secrets.ENSO_CLOUD_TEST_ACCOUNT_PASSWORD }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - if: failure() + name: Upload Test Traces + uses: actions/upload-artifact@v4 + with: + name: test-traces + path: app/ide-desktop/client/test-traces - run: rm $HOME/.enso/credentials env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -512,6 +524,12 @@ jobs: ENSO_TEST_USER: ${{ secrets.ENSO_CLOUD_TEST_ACCOUNT_USERNAME }} ENSO_TEST_USER_PASSWORD: ${{ secrets.ENSO_CLOUD_TEST_ACCOUNT_PASSWORD }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - if: failure() + name: Upload Test Traces + uses: actions/upload-artifact@v4 + with: + name: test-traces + path: app/ide-desktop/client/test-traces - run: rm $HOME/.enso/credentials env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 2533b869dc..e4474edcef 100644 --- a/.gitignore +++ b/.gitignore @@ -180,5 +180,6 @@ test-results ########################## test-results/ +test-traces/ playwright-report/ playwright/.cache/ diff --git a/app/ide-desktop/client/tests/electronTest.ts b/app/ide-desktop/client/tests/electronTest.ts index 05ab538bac..8ee35a8e0b 100644 --- a/app/ide-desktop/client/tests/electronTest.ts +++ b/app/ide-desktop/client/tests/electronTest.ts @@ -23,13 +23,16 @@ export function electronTest( executablePath: process.env.ENSO_TEST_EXEC_PATH ?? '', args: process.env.ENSO_TEST_APP_ARGS != null ? process.env.ENSO_TEST_APP_ARGS.split(',') : [], env: { ...process.env, ['ENSO_TEST']: name }, + tracesDir: 'test-traces', }) const page = await app.firstWindow() + await app.context().tracing.start({ screenshots: true, snapshots: true, sources: true }) // Wait until page will be finally loaded: we expect login screen. // There's bigger timeout, because the page may load longer on CI machines. await expect(page.getByText('Login to your account')).toBeVisible({ timeout: LOADING_TIMEOUT }) const projectsDir = pathModule.join(os.tmpdir(), 'enso-test-projects', name) await body({ page, projectsDir }) + await app.context().tracing.stop({ path: `${name}.zip` }) await app.close() }) } diff --git a/build/build/src/ci_gen/job.rs b/build/build/src/ci_gen/job.rs index ea02973de6..05efb47b90 100644 --- a/build/build/src/ci_gen/job.rs +++ b/build/build/src/ci_gen/job.rs @@ -17,6 +17,7 @@ use crate::ide::web::env::VITE_ENSO_MAPBOX_API_TOKEN; use ide_ci::actions::workflow::definition::cancel_workflow_action; use ide_ci::actions::workflow::definition::shell; +use ide_ci::actions::workflow::definition::step::Argument; use ide_ci::actions::workflow::definition::Access; use ide_ci::actions::workflow::definition::Job; use ide_ci::actions::workflow::definition::JobArchetype; @@ -555,6 +556,18 @@ impl JobArchetype for PackageIde { ); steps.push(test_step); + let upload_test_traces_step = Step { + r#if: Some("failure()".into()), + name: Some("Upload Test Traces".into()), + uses: Some("actions/upload-artifact@v4".into()), + with: Some(Argument::Other(BTreeMap::from_iter([ + ("name".into(), "test-traces".into()), + ("path".into(), "app/ide-desktop/client/test-traces".into()), + ]))), + ..Default::default() + }; + steps.push(upload_test_traces_step); + // After the E2E tests run, they create a credentials file in user home directory. // If that file is not cleaned up, future runs of our tests may randomly get // authenticated into Enso Cloud. We want to run tests as an authenticated