Skip to content

Commit

Permalink
Pipe percy stderr to GHA console; fix standalone index being snapshot…
Browse files Browse the repository at this point in the history
…ted by Percy
  • Loading branch information
jmuzina committed Jul 2, 2024
1 parent dd3afad commit affa6ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
13 changes: 7 additions & 6 deletions .github/actions/percy-snapshot/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,12 @@ runs:
# If PR number is set & a Percy-GHA integration is set up, this allows Percy to set status on the PR
PERCY_PULL_REQUEST: ${{ inputs.pr_number }}
run: |
set -e
# Start a percy build and capture the stdout
# Start a percy build and capture the stdout and stderr
percy_output=$(yarn percy 2>&1)
echo "$percy_output"
percy_output=$(
{
yarn percy 2>&1
} | tee /dev/stderr
)
# Fail if the Percy stdout contains "Build not created"
if echo "$percy_output" | grep -q "Build not created"; then
Expand All @@ -105,6 +104,8 @@ runs:
# Extract the build link from the stdout of the snapshot command
build_link=$(echo "$percy_output" | sed -n 's/.*Finalized build #.*: \(https:\/\/percy.io\/[^ ]*\).*/\1/p')
# Sanitize the build link to remove any newlines or spaces
build_link=$(echo "$build_link" | tr -d '\n' | tr -d ' ')
# Using '/' to split the $build_link, extract the organization and build identifiers
org_id=$(echo "$build_link" | cut -d '/' -f 4)
Expand Down
8 changes: 5 additions & 3 deletions snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ async function getExampleFiles(dir = EXAMPLES_RELATIVE_DIR) {
// Get examples from the subdirectory
files.push(...(await getExampleFiles(path.join(dir, entry.name))));
}
// Ignore partials, non-HTML files, & the examples index
} else if (entry.isFile() && entry.name.endsWith('.html') && !entry.name.startsWith('_')) {
// Ignore partials & non-HTML files
if ((dir === EXAMPLES_RELATIVE_DIR && entry.name === 'index.html') || entry.name === 'standalone.html') {
// Ignore the examples index
continue;
}
files.push(path.join(dir, entry.name));
}
}
Expand All @@ -50,9 +54,7 @@ async function getExampleFiles(dir = EXAMPLES_RELATIVE_DIR) {
function getExampleUrlsFromExamplePaths(urlPaths) {
// add standalone versions of the examples in base and patterns folders
const standaloneUrls = urlPaths.filter((file) => file.startsWith('base/') || file.startsWith('patterns/')).map((file) => path.join('standalone', file));

urlPaths = urlPaths.concat(standaloneUrls);

// map the file paths to URLs
return urlPaths.map((url) => {
url = url.replace('.html', '');
Expand Down

0 comments on commit affa6ca

Please sign in to comment.