mattermost-mobile-upstream/detox/e2e/path_builder.js
yasser khan 93b1863b58
Some checks are pending
ci / lint-typecheck (push) Waiting to run
ci / detox-lint-typecheck (push) Waiting to run
ci / test (push) Waiting to run
ci(e2e): triage red Detox and Maestro runs against test history (#10172)
* ci(e2e): triage red Detox and Maestro runs against test history

When a Detox or Maestro lane is red, the toolkit's e2e-triage action checks
each failure against TSIO history (flaky or broken on main, the same failure on
other PRs, environment errors, or caused by this PR) and adds its verdict to the
lane's status and the job summary. Report-only unless E2E_TRIAGE_MODE is enforce.

- .github/actions/e2e-triage: the per-lane triage steps (evidence download,
  answers cache, toolkit e2e-triage) as one composite, checked out from the
  dispatch ref so the branch under test never runs with the API key.
- Each lane uploads what it saw at a failure (screenshots, the step it
  stopped at, the server's answer) as triage evidence.
- The TSIO status links name the run only when both the run id and the
  attempt are known, so triage writes only on statuses its run owns.

Toolkit pinned to bdce26e.

* ci(e2e): pin the toolkit to 24bf208; use the renamed e2e-test-* actions

The toolkit renamed e2e-triage to e2e-test-triage and e2e-status to
e2e-test-status; inputs are unchanged. Triage now holds a failure repeated on
this PR's last commits and never on the base branch as out of date (merge the
base branch and re-run) instead of clearing it, and the status line names each
kind: flaky, broken on main, caused by PR, out of date, needs investigation.

* ci(e2e): pin the toolkit to main (419b0a9)

Toolkit #5 merged; this pins its merge on main instead of the PR branch.

* ci(e2e): pin the toolkit to main (b3ca677)

Toolkit #6 merged: a run flagged as a whole now says why once instead of repeating "investigation required".

* ci(e2e): pin the toolkit to e2e-triage-judge-flagged-runs (f1f5d54, toolkit#8)

* ci(e2e): pin the toolkit to e2e-triage-judge-flagged-runs (77c3048, toolkit#8)

* ci(e2e): use the toolkit's main while triage is observed

toolkit#8 merged (b7757e9). Following review, consumers track main so
toolkit changes need no bump here; pin a hash again once stable.

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2026-10-26 10:26:45 +05:30

35 lines
1.1 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const path = require('path');
const sanitizeFilename = require('sanitize-filename');
const SANITIZE_OPTIONS = {replacement: '_'};
// `/` is illegal in filesystem paths. sanitize-filename turns it into `_`, which
// breaks TSIO screenshot linking (folder basename must match Jest fullName).
// Use U+2215 DIVISION SLASH so the folder stays unique and TSIO can reverse it.
const PATH_SEP_TOKEN = '\u2215';
const sanitize = (filename) => sanitizeFilename(
String(filename).replaceAll('/', PATH_SEP_TOKEN),
SANITIZE_OPTIONS,
);
class CustomPathBuilder {
constructor({rootDir}) {
this.rootDir = rootDir;
}
buildPathForTestArtifact(artifactName, testSummary = null) {
const fullName = (testSummary && testSummary.fullName) || '';
const segments = [this.rootDir, sanitize(fullName), sanitize(artifactName)];
return path.join(...segments.filter(Boolean));
}
}
module.exports = ({rootDir}) => {
return new CustomPathBuilder({rootDir});
};
module.exports.sanitize = sanitize;