ci: gate native suites with isolated browser fixtures

This commit is contained in:
Alexandre Teixeira
2026-10-29 17:40:13 +00:00
parent b4247dd0dc
commit 96cb5bdc8f
11 changed files with 433 additions and 7 deletions
+7 -2
View File
@@ -2,6 +2,7 @@ const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const { execFileSync } = require('node:child_process');
const { disposableCIArtifacts } = require('./artifact-policy');
const repoRoot = path.resolve(__dirname, '..', '..');
const defaultResultsDir = path.join(repoRoot, 'test-results');
@@ -29,6 +30,9 @@ module.exports = async (options = {}) => {
const isPlaywrightConfig = options && (options.configFile || options.rootDir);
const testOpts = (!isPlaywrightConfig && typeof options === 'object') ? options : {};
// Validate fixture ownership before removing its temporary directory.
const disposableCI = disposableCIArtifacts();
// Confine cleanup of PHOTO_EDITOR_E2E_DATA_DIR:
// Strictly require it to be within an OS temporary directory and match the expected test prefix
const dataDirectory = process.env.PHOTO_EDITOR_E2E_DATA_DIR;
@@ -100,7 +104,7 @@ module.exports = async (options = {}) => {
const isCI = Boolean(process.env.CI) || Boolean(process.env.GITHUB_ACTIONS);
const traceOptIn = !isCI && ['1', 'true'].includes(String(process.env.PLAYWRIGHT_ENABLE_TRACE || '').toLowerCase());
if (isCI || !traceOptIn) {
if ((isCI && !disposableCI) || (!traceOptIn && !disposableCI)) {
// In CI or default local runs, purge all sensitive trace archives and artifacts
purgeSensitiveArtifacts(resultsDir);
} else {
@@ -124,7 +128,8 @@ module.exports = async (options = {}) => {
if (!sanitizerSucceeded) {
// Fail closed: purge all remaining zip or tmp archives
purgeZipAndTmp(resultsDir);
if (disposableCI) purgeSensitiveArtifacts(resultsDir);
else purgeZipAndTmp(resultsDir);
}
}
}