-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
treat metadata file differently locally from CI #103
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; | ||
import { dirname, join } from 'node:path'; | ||
import { getTestInfo, PATHS } from './visual-diff-plugin.js'; | ||
import { env } from 'node:process'; | ||
import { execSync } from 'node:child_process'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
const isCI = !!env['CI']; | ||
|
||
function createData(rootDir, sessions) { | ||
function createData(rootDir, updateGoldens, sessions) { | ||
|
||
let metadata = {}; | ||
const metadataPath = join(rootDir, PATHS.METADATA); | ||
|
@@ -51,10 +53,12 @@ function createData(rootDir, sessions) { | |
}); | ||
}); | ||
|
||
metadata.browsers = Array.from(browsers.values()).map(b => { | ||
return { name: b.name, version: b.version }; | ||
}); | ||
writeFileSync(metadataPath, JSON.stringify(metadata, undefined, '\t')); | ||
if (isCI || updateGoldens) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume we're ok with the browser versions being slightly off if you're using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, but yeah not worried about it. This stuff is really only useful in CI anyway -- if you're reusing old goldens locally from an old browser... I'm not sure what you're doing. I've almost talked myself into only using this information in CI, period, haha. |
||
metadata.browsers = Array.from(browsers.values()).map(b => { | ||
return { name: b.name, version: b.version }; | ||
}); | ||
writeFileSync(metadataPath, JSON.stringify(metadata, undefined, '\t')); | ||
} | ||
|
||
return { browsers, files, numFailed, numTests }; | ||
|
||
|
@@ -99,7 +103,7 @@ function flattenResults(session, browserData, fileData) { | |
|
||
} | ||
|
||
export function visualDiffReporter({ reportResults = true } = {}) { | ||
export function visualDiffReporter({ updateGoldens } = {}) { | ||
let rootDir; | ||
return { | ||
start({ config }) { | ||
|
@@ -108,14 +112,14 @@ export function visualDiffReporter({ reportResults = true } = {}) { | |
}, | ||
stop({ sessions }) { | ||
|
||
if (!reportResults) return; | ||
|
||
const data = createData(rootDir, sessions); | ||
const data = createData(rootDir, updateGoldens, sessions); | ||
const json = JSON.stringify(data, (_key, val) => { | ||
if (val instanceof Map) return [...val.values()].sort((a, b) => a.name.localeCompare(b.name)); | ||
return val; | ||
}, '\t'); | ||
|
||
if (updateGoldens) return; | ||
|
||
const inputDir = join(__dirname, 'report'); | ||
const reportDir = join(rootDir, PATHS.VDIFF_ROOT, PATHS.REPORT_ROOT); | ||
const tempDir = join(reportDir, 'temp'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleting this for now. The first time the action runs, it'll re-create it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that, let's us verify it works as expected!