Compare commits

...

1 Commits

Author SHA1 Message Date
Filip Hric
a3129114f1 run only previously failed tests when rerunning pipeline 2025-03-17 22:11:36 +01:00
3 changed files with 62 additions and 1 deletions

View File

@@ -98,6 +98,18 @@ jobs:
id: cypress-prep
uses: ./.github/actions/prepare-cypress
- name: Download failed test artifacts
uses: actions/download-artifact@v4
if: github.run_attempt != '1'
continue-on-error: true
id: failed-specs
with:
name: failed-tests-${{ inputs.name }}-${{ inputs.edition }}
- name: Get failed specs
if: github.run_attempt != '1'
run: echo "specs=$(cat failed-specs)" >> $GITHUB_ENV
- name: Run Snowplow micro
uses: ./.github/actions/run-snowplow-micro
@@ -117,19 +129,25 @@ jobs:
SPLIT_TIME_THRESHOLD: 5.0
# do not write cypress-split summary to github
SPLIT_SUMMARY: false
SPEC_PATH: ${{ env.specs || inputs.specs }}
shell: bash
run: |
echo "Running tests with specs: $SPEC_PATH"
node e2e/runner/run_cypress_ci.js e2e \
--env grepTags="-@mongo+-@flaky+-@OSS --@quarantine",grepOmitFiltered=true \
--spec "$SPEC_PATH" \
--browser ${{ steps.cypress-prep.outputs.chrome-path }}
- name: Run Tagged EE Cypress tests on ${{ inputs.name }}
if: ${{ inputs.specs }}
shell: bash
env:
SPEC_PATH: ${{ env.specs || inputs.specs }}
run: |
echo "Running tests with specs: $SPEC_PATH"
node e2e/runner/run_cypress_ci.js e2e \
--env grepTags="${{inputs.tags}} --@quarantine",grepOmitFiltered=true \
--spec '${{ inputs.specs }}' \
--spec "$SPEC_PATH" \
--browser ${{ steps.cypress-prep.outputs.chrome-path }}
- name: Upload Test Results
@@ -154,6 +172,13 @@ jobs:
./logs/test.log
if-no-files-found: ignore
- name: Upload Failed Tests
uses: actions/upload-artifact@v4
if: failure()
with:
name: failed-tests-${{ inputs.name }}-${{ inputs.edition }}
path: ./cypress/test-results
- name: Publish Summary
if: failure()
uses: actions/github-script@v7

View File

@@ -0,0 +1,34 @@
const fs = require("fs");
const path = require("path");
/**
* Collects failed test specs from the most recent Cypress test run
*
* After each run, a file will store failed spec paths as a comma-separated list
* This format matches what's needed by the GitHub workflow for retrying tests
*
* @param {*} on
* @param {*} config
* @returns
*/
const collectFailingTests = (on, config) => {
on("after:run", async results => {
const failedSpecs = results.runs
.filter(run => run.stats.failures > 0)
.map(run => run.spec.relative);
if (failedSpecs.length > 0) {
const failedTestFilePath = "../../cypress/test-results/";
fs.mkdirSync(failedTestFilePath, { recursive: true });
fs.writeFileSync(
path.join(failedTestFilePath, "failed-specs"),
failedSpecs.join(","),
);
}
});
return collectFailingTests;
};
export { collectFailingTests };

View File

@@ -4,6 +4,7 @@ import path from "node:path";
import installLogsPrinter from "cypress-terminal-report/src/installLogsPrinter";
import * as ciTasks from "./ci_tasks";
import { collectFailingTests } from "./collectFailedTests";
import {
removeDirectory,
verifyDownloadTasks,
@@ -146,6 +147,7 @@ const defaultConfig = {
if (isCI) {
cypressSplit(on, config, getSplittableSpecs);
collectFailingTests(on, config);
}
// this is an official workaround to keep recordings of the failed specs only