Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
28 changes: 26 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ jobs:

test:
name: Test
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
Expand All @@ -47,18 +51,38 @@ jobs:
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0

- name: Test dependencies
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
# Don't waste time on man-db updates
sudo apt-get remove --purge man-db
# Needed for tty-tests
sudo apt install -y expect

- name: Determine test features
id: features
shell: bash
run: |
FEATURES="crater-tests,tty-tests,schema"
if [ "${IS_LINUX}" != "true" ]; then
# tty-tests only get run on Linux, for now.
FEATURES="crater-tests,schema"
fi

echo "features=$FEATURES" >> $GITHUB_OUTPUT
env:
IS_LINUX: ${{ matrix.os == 'ubuntu-latest' }}

- name: Test
run: cargo test --features crater-tests,tty-tests,schema
shell: bash
run: cargo test --features "${TEST_FEATURES}"
env:
TEST_FEATURES: ${{ steps.features.outputs.features }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Test snippets
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
make snippets
git diff --exit-code
Expand Down
6 changes: 5 additions & 1 deletion crates/yamlpath/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ fn run_testcase(path: &Path) {

match feature {
Some(feature) => {
assert_eq!(document.extract_with_leading_whitespace(&feature), expected)
assert_eq!(
document.extract_with_leading_whitespace(&feature),
expected,
"testcase: {path:?}, query: {query:?}"
);
}
None => assert_eq!(expected, "<<empty>>"),
}
Expand Down
8,166 changes: 4,083 additions & 4,083 deletions crates/zizmor/data/context-capabilities.csv

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly related to this PR, but this file was CRLF.

Large diffs are not rendered by default.

70 changes: 42 additions & 28 deletions crates/zizmor/src/models/workflow/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -385,8 +386,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -426,8 +428,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -467,8 +470,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -508,8 +512,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -549,8 +554,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -590,8 +596,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -634,8 +641,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -678,8 +686,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -722,8 +731,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -766,8 +776,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -810,8 +821,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -854,8 +866,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down Expand Up @@ -901,8 +914,9 @@ jobs:
group: Group(
"fakegroup",
),
given_path: "test.yml",
best_relative_path: "test.yml",
verbatim_path: "test.yml",
native_path: "test.yml",
best_identifier: "test.yml",
},
),
annotation: "this expansion",
Expand Down
9 changes: 3 additions & 6 deletions crates/zizmor/src/output/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::collections::HashMap;

use anyhow::{Context as _, Result};
use camino::Utf8PathBuf;
use camino::Utf8Path;
use owo_colors::OwoColorize as _;

use crate::{
Expand Down Expand Up @@ -80,7 +80,7 @@ pub fn apply_fixes(
};

let input = registry.get_input(input_key);
let file_path = &local.given_path;
let file_path = local.path();

let mut file_applied_fixes = Vec::new();
let mut current_document = input.as_document().clone();
Expand Down Expand Up @@ -127,10 +127,7 @@ pub fn apply_fixes(
})
}

fn print_summary(
applied_fixes: &[(&Utf8PathBuf, usize)],
failed_fixes: &[(&str, &Utf8PathBuf, String)],
) {
fn print_summary(applied_fixes: &[(&Utf8Path, usize)], failed_fixes: &[(&str, &Utf8Path, String)]) {
anstream::eprintln!("\n{}", "Fix Summary".green().bold());

if !applied_fixes.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion crates/zizmor/src/output/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Finding<'_> {
// NOTE: We intentionally only use the start line, since our spans
// sometimes end at EOF and GitHub's annotations don't handle that
// gracefully.
let filepath = primary.symbolic.key.best_relative_path();
let filepath = primary.symbolic.key.best_identifier();
let start_line = primary.concrete.location.start_point.row + 1;
let title = self.ident;

Expand Down
2 changes: 1 addition & 1 deletion crates/zizmor/src/output/sarif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn build_result(finding: &Finding<'_>) -> SarifResult {
fn build_physical_location(location: &Location<'_>) -> PhysicalLocation {
PhysicalLocation {
artifact_location: ArtifactLocation {
uri: location.symbolic.key.best_relative_path().into(),
uri: location.symbolic.key.best_identifier().into(),
},
region: Region {
// NOTE: SARIF lines/columns are 1-based.
Expand Down
Loading
Loading