From 02a5f1553593a6e2d6810dcc5d70b2b50fcf864d Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 6 Sep 2025 14:43:21 -0400 Subject: [PATCH] Make the MSRV lint more robust The prior version would fail if the last entry in the final array was not originally the last entry. --- .github/workflows/lint.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index de77c8c9..9b604577 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -144,14 +144,15 @@ jobs: function check_workspace { # Get the members array from the workspace's `Cargo.toml` cargo_toml_lines=$(cat ./Cargo.toml | wc -l) + # Keep all lines after the start of the array, then keep all lines before the next "]" members=$(cat Cargo.toml | grep "members\ \=\ \[" -m1 -A$cargo_toml_lines | grep "]" -m1 -B$cargo_toml_lines) - # Parse out any comments, including comments post-fixed on the same line as an entry - members=$(echo "$members" | grep -Ev "^[[:space:]]+#" | grep -Ev "^[[:space:]]?$" | awk -F',' '{print $1","}') # Prune `members = [` to `[` by replacing the first line with just `[` members=$(echo "$members" | sed "1s/.*/\[/") - # Remove the trailing comma by replacing the last line's "," with "" - members=$(echo "$members" | sed "$(($(echo "$members" | wc -l) - 1))s/\,//") - # Correct the last line, which was malleated to "]," when pruning comments + + # Parse out any comments, whitespace, including comments post-fixed on the same line as an entry + # We accomplish the latter by pruning all characters after the entry's "," + members=$(echo "$members" | grep -Ev "^[[:space:]]*(#|$)" | awk -F',' '{print $1","}') + # Correct the last line, which was malleated to "]," members=$(echo "$members" | sed "$(echo "$members" | wc -l)s/\]\,/\]/") # Don't check the patches @@ -174,6 +175,9 @@ jobs: members=$(echo "$members" | grep -v "mini\"") members=$(echo "$members" | grep -v "tests/") + # Remove the trailing comma by replacing the last line's "," with "" + members=$(echo "$members" | sed "$(($(echo "$members" | wc -l) - 1))s/\,//") + echo $members | jq -r ".[]" | while read -r member; do check_msrv $member correct=$?