-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflows: added VID / VLAN name duplication check
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# Change to the locations directory | ||
cd locations || exit 1 | ||
|
||
# Variable to accumulate duplicate findings | ||
all_duplicates="" | ||
|
||
# Iterate over each file in the directory | ||
for file in ./*; do | ||
# Check if it is a file | ||
if [ -f "$file" ]; then | ||
# Extract VIDs / VLAN names, sort, and find duplicates | ||
duplicates_vid=$(yq 'select(.networks != null) | .networks[].vid' "$file" | grep -v 'null' | sed 's/["'\'']//g' | sort | uniq -cd) | ||
duplicates_name=$(yq 'select(.networks != null) | .networks[].name' "$file" | grep -v 'null' | sed 's/["'\'']//g' | sort | uniq -cd) | ||
# Accumulate duplicates if found | ||
if [ -n "$duplicates_vid" ]; then | ||
all_duplicates+="\nDuplicate VIDs found in $file:\n$duplicates_vid" | ||
fi | ||
if [ -n "$duplicates_name" ]; then | ||
all_duplicates+="\nDuplicate VLAN names found in $file:\n$duplicates_name" | ||
fi | ||
fi | ||
done | ||
|
||
# Check if there were any duplicates found | ||
if [ -n "$all_duplicates" ]; then | ||
echo -e "Duplicates VIDs or VLAN names found:$all_duplicates" | ||
exit 1 | ||
else | ||
echo "No duplicate VIDs or VLAN names found." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Check for duplicate VIDs and VLAN names | ||
|
||
on: [push, pull_request] # yamllint disable-line rule:truthy | ||
|
||
jobs: | ||
check-vlan-duplicates: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Run VID and VLAN name duplicate check | ||
run: | | ||
./.github/checks/check-vlan-duplicates.sh |