Skip to content

board_types: tests for conflicts in CI #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions .github/workflows/check_board_conflicts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check for Board Assignment Conflicts

on:
push:
branches:
- 'main'
- 'master'
pull_request:
branches:
- '*'
jobs:
check:
name: Check for Conflicts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Run Test
run: |
./Tools/check_board_types_conflicts.txt

5 changes: 3 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ name: Build and Deploy
on:
push:
branches:
- 'master'
- 'main'
- 'master'
pull_request:
branches:
- '*'
- '*'


jobs:
Expand Down
42 changes: 42 additions & 0 deletions Tools/check_board_types_conflicts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Ensure we are running Bash 3 or newer
if ((BASH_VERSINFO[0] < 3)); then
echo "Error: This script requires Bash 3 or newer. Current version: $BASH_VERSION"
exit 1
fi

# Enable strict mode for better error handling
set -euo pipefail

# Get the project root directory (assuming the script is in ./Tools)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
FILE_PATH="$PROJECT_ROOT/board_types.txt"

# Check if the file exists
if [ ! -f "$FILE_PATH" ]; then
echo "Error: File 'board_types.txt' not found in project root: $PROJECT_ROOT"
exit 1
fi

# Process the file to detect conflicts using awk, while ignoring "# same" lines
awk '
{
# If the third column starts with "# same", ignore the line
if ($3 == "#") {
if ($4 == "same") {
next
}
}

# Check for conflicts on the second column
if ($2 in value_map && value_map[$2] != $1) {
print "Conflict detected: Value \"" $2 "\" is associated with both \"" value_map[$2] "\" and \"" $1 "\""
}

# Store the mapping
value_map[$2] = $1
}
' "$FILE_PATH"

Loading