Skip to content

Commit

Permalink
Upload GitHub workflow artifacts even when the test fails.
Browse files Browse the repository at this point in the history
When a test in `.github/workflows/ci.yml`'s `gpu-test` fails,
ensure that it uploads the artifacts anyway. These are screenshots and
comparison images, so they're valuable in debugging the failure.
  • Loading branch information
jimblandy committed Aug 29, 2023
1 parent c20f7ec commit 4aa95c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ jobs:
done
- uses: actions/upload-artifact@v3
if: always() # We want artifacts even if the tests fail.
with:
name: comparison-images
path: |
Expand Down
25 changes: 8 additions & 17 deletions tests/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,18 @@ pub fn compare_image_output(
}

let file_stem = reference_path.file_stem().unwrap().to_string_lossy();
let renderer = format!("{}-{}-{}",
adapter_info.backend.to_str(),
sanitize_for_path(&adapter_info.name),
sanitize_for_path(&adapter_info.driver));
let renderer = format!(
"{}-{}-{}",
adapter_info.backend.to_str(),
sanitize_for_path(&adapter_info.name),
sanitize_for_path(&adapter_info.driver)
);
// Determine the paths to write out the various intermediate files
let actual_path = Path::new(&path).with_file_name(
OsString::from_str(&format!("{}-{}-actual.png", file_stem, renderer)).unwrap(),
);
let difference_path = Path::new(&path).with_file_name(
OsString::from_str(&format!(
"{}-{}-difference.png",
file_stem,
renderer,
))
.unwrap(),
OsString::from_str(&format!("{}-{}-difference.png", file_stem, renderer,)).unwrap(),
);

// Convert the error values to a false color reprensentation
Expand Down Expand Up @@ -256,13 +253,7 @@ pub fn compare_image_output(

fn sanitize_for_path(s: &str) -> String {
s.chars()
.map(|ch| {
if ch.is_ascii_alphanumeric() {
ch
} else {
'_'
}
})
.map(|ch| if ch.is_ascii_alphanumeric() { ch } else { '_' })
.collect()
}

Expand Down

0 comments on commit 4aa95c4

Please sign in to comment.