Skip to content

Commit

Permalink
Merge pull request #5645 from gooddata/pb-minor-fixes
Browse files Browse the repository at this point in the history
fix: e2e tests from pr improvements
  • Loading branch information
ivanmjartan authored Dec 3, 2024
2 parents 0ba2181 + 68e1bf3 commit 65a4627
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 9 deletions.
29 changes: 21 additions & 8 deletions .github/workflows/pull-request-comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,30 @@ on:
types:
- created
jobs:
guard:
get-pr-info:
if: github.event.issue.pull_request != null && startsWith(github.event.comment.body, 'extended test')
runs-on:
group: infra1-runners-arc
labels: runners-small
outputs:
sha: ${{ steps.get-sha.outputs.sha }}
steps:
- name: Set changed components from command
id: command
- uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- name: get-sha
id: get-sha
run: |
echo "COMMENT=$COMMENT"
SHA=$(git log -1 --format='%H')
echo "Comment is $COMMENT"
echo "Exporting ${{ github.event.issue.number }} as $SHA"
echo "sha=$SHA" >> $GITHUB_OUTPUT
env:
COMMENT: ${{ github.event.comment.body }}

command-started:
needs: [guard]
if: ${{ startsWith(github.event.comment.body, 'extended test - isolated') }}
needs: [get-pr-info]
if: ${{ startsWith(github.event.comment.body, 'extended test') }}
permissions:
pull-requests: write
runs-on:
Expand All @@ -43,23 +52,27 @@ jobs:
COMMENT: ${{ github.event.comment.body }}

e2e-run:
needs: [guard]
needs: [get-pr-info]
if: ${{ github.event.comment.body == 'extended test - isolated' }}
permissions:
id-token: write
contents: read
pull-requests: read
uses: ./.github/workflows/rw-rush-build-e2e-tests.yml
with:
source-ref: ${{ needs.get-pr-info.outputs.sha }}
secrets: inherit

e2e-record:
needs: [guard]
needs: [get-pr-info]
if: ${{ github.event.comment.body == 'extended test - record' }}
permissions:
id-token: write
contents: read
pull-requests: read
uses: ./.github/workflows/rw-rush-build-e2e-tests-record.yml
with:
source-ref: ${{ needs.get-pr-info.outputs.sha }}
secrets: inherit


Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/rw-rush-build-e2e-tests-record.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
required: false
description: "List of spec files to filter"
type: string
source-ref:
required: false
description: "source ref of the current code"
type: string

jobs:
warm-up-cache:
Expand All @@ -14,6 +18,9 @@ jobs:
labels: runners-cxa-xlarge
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.source-ref }}
fetch-depth: 2
- name: Git config user
uses: snow-actions/[email protected]
with:
Expand All @@ -31,6 +38,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.source-ref }}
fetch-depth: 2
- name: Git config user
uses: snow-actions/[email protected]
Expand All @@ -54,6 +62,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.source-ref }}
fetch-depth: 2
- name: Git config user
uses: snow-actions/[email protected]
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/rw-rush-build-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
required: false
description: "List of spec files to filter"
type: string
source-ref:
required: false
description: "source ref of the current code"
type: string

jobs:
warm-up-cache:
Expand All @@ -14,6 +18,10 @@ jobs:
labels: runners-cxa-xlarge
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.source-ref }}
fetch-depth: 2

- name: Git config user
uses: snow-actions/[email protected]
with:
Expand All @@ -31,6 +39,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.source-ref }}
fetch-depth: 2
- name: Git config user
uses: snow-actions/[email protected]
Expand Down Expand Up @@ -91,6 +100,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.source-ref }}
fetch-depth: 2
- name: Git config user
uses: snow-actions/[email protected]
Expand Down
4 changes: 3 additions & 1 deletion libs/sdk-ui-tests-e2e/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// (C) 2022 GoodData Corporation
// (C) 2022-2024 GoodData Corporation
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import cypressGrepPlugin from "@cypress/grep/src/plugin";
import { defineConfig } from "cypress";
import axios from "axios";
import readPdf from "./cypress/plugins/readPdf";
import parseXlsx from "./cypress/plugins/parseXlsx";
import removePassingTestVideosPlugin from "./cypress/plugins/removePassingTestVideos";

export default defineConfig({
e2e: {
excludeSpecPattern: "*.js",
supportFile: "cypress/support/index.ts",
setupNodeEvents(on, _config) {
removePassingTestVideosPlugin(on, _config);
cypressGrepPlugin(_config);
on("task", {
async resetRecordingsScenarios(mockServerUrl: string) {
Expand Down
19 changes: 19 additions & 0 deletions libs/sdk-ui-tests-e2e/cypress/plugins/removePassingTestVideos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// (C) 2021-2024 GoodData Corporation
import { unlink } from "fs";
import { promisify } from "util";

const rm = promisify(unlink);

export default ((on, _config) => {
const filesToDelete: string[] = [];
on("after:spec", (_spec, results) => {
if (results.stats.failures === 0 && results.video) {
filesToDelete.push(results.video);
}
});
on("after:run", async () => {
// eslint-disable-next-line no-console
console.log("Deleting %d videos from successful specs", filesToDelete.length);
await Promise.all(filesToDelete.map((videoFile) => rm(videoFile)));
});
}) as Cypress.PluginConfig;

0 comments on commit 65a4627

Please sign in to comment.