Co-authored-by: GideonBear <87426140+GideonBear@users.noreply.github.com>
This commit is contained in:
45
.github/workflows/ci.yml
vendored
45
.github/workflows/ci.yml
vendored
@@ -28,8 +28,8 @@ jobs:
|
||||
rustup component add rustfmt
|
||||
cargo fmt --all -- --check
|
||||
|
||||
step-enum-sorted:
|
||||
name: Step enum sorted
|
||||
custom-checks:
|
||||
name: Custom checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -45,13 +45,6 @@ jobs:
|
||||
sort original.txt > sorted.txt
|
||||
diff original.txt sorted.txt
|
||||
|
||||
step-match-sorted:
|
||||
name: Step match sorted
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5.0.0
|
||||
|
||||
- name: Check if `Step::run()`'s match is sorted
|
||||
run: |
|
||||
FILE="src/step.rs"
|
||||
@@ -59,8 +52,40 @@ jobs:
|
||||
sort original.txt > sorted.txt
|
||||
diff original.txt sorted.txt
|
||||
|
||||
- name: Check if `default_steps` contains every step
|
||||
run: |
|
||||
# Extract all variants from enum Step
|
||||
all_variants=$(sed -n '/^pub enum Step {/,/^}/p' src/step.rs | grep -Po '^\s*\K[A-Z][A-Za-z0-9_]*' | sort)
|
||||
|
||||
# Extract variants used inside default_steps
|
||||
used_variants=$(sed -n '/^pub(crate) fn default_steps()/,/^}/p' src/step.rs | \
|
||||
grep -Po '\b[A-Z][A-Za-z0-9_]*\b' | \
|
||||
grep -Fx -f <(echo "$all_variants") | \
|
||||
sort)
|
||||
|
||||
# Check for missing variants
|
||||
missing=$(comm -23 <(echo "$all_variants") <(echo "$used_variants"))
|
||||
if [[ -z "$missing" ]]; then
|
||||
echo "All variants are used."
|
||||
else
|
||||
echo "Missing variants:"
|
||||
echo "$missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for duplicates
|
||||
duplicates=$(echo "$used_variants" | uniq -c | awk '$1 > 1 {print $2}')
|
||||
if [[ -z "$duplicates" ]]; then
|
||||
echo "No duplicates found."
|
||||
else
|
||||
echo "Duplicates found:"
|
||||
echo "$duplicates"
|
||||
# We allow duplicates, but lets keep this check for potential future usefulness
|
||||
# exit 1
|
||||
fi
|
||||
|
||||
main:
|
||||
needs: [ fmt, step-enum-sorted, step-match-sorted ]
|
||||
needs: [ fmt, custom-checks ]
|
||||
name: ${{ matrix.target_name }} (check, clippy)
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
|
||||
Reference in New Issue
Block a user