Skip to content

Commit

Permalink
workflows: added / refined duplication checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Noki committed Jul 28, 2024
1 parent 1c2a30a commit 2ad9601
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 37 deletions.
32 changes: 32 additions & 0 deletions .github/checks/check-vlan-duplicates.sh
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 / vid 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 duplicates found."
fi
17 changes: 0 additions & 17 deletions .github/workflows/check-address-duplicates.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
---
name: Check for duplicate IP prefixes
name: Check for duplication errors

on: [push, pull_request] # yamllint disable-line rule:truthy

jobs:
check-ip-prefix-duplicates:
check-duplicates:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run IP prefix duplicate check
- name: Check for duplicates
run: |
./.github/checks/check-address-duplicates.sh
./.github/checks/check-hostname-duplicates.sh
./.github/checks/check-ip-prefix-duplicates.sh
./.github/checks/check-vlan-duplicates.sh
17 changes: 0 additions & 17 deletions .github/workflows/check-hostname-duplicates.yml

This file was deleted.

0 comments on commit 2ad9601

Please sign in to comment.