diff --git a/.github/workflows/adj-tester.yaml b/.github/workflows/adj-tester.yaml index c6fd55d..891756a 100644 --- a/.github/workflows/adj-tester.yaml +++ b/.github/workflows/adj-tester.yaml @@ -24,4 +24,20 @@ jobs: - name: Run ADJ validation run: | - python3 .github/workflows/scripts/adj-tester/main.py + python3 .github/workflows/scripts/adj-tester/main.py > /dev/null 2>&1 + + - name: Notify Slack on failure + if: failure() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} + run: | + jq -n \ + --arg repo "${{ github.repository }}" \ + --arg branch "${{ github.ref_name }}" \ + --arg actor "${{ github.actor }}" \ + --arg run_url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ + '{ + text: " ❌ ADJ Validator Failed\n\nRepository: \($repo)\nBranch: \($branch)\nActor: \($actor)\n\nWorkflow run:\n\($run_url)" + }' | curl -X POST -H "Content-type: application/json" \ + --data @- \ + $SLACK_WEBHOOK diff --git a/.github/workflows/scripts/adj-tester/main.py b/.github/workflows/scripts/adj-tester/main.py index b59ab1d..dc25c9b 100755 --- a/.github/workflows/scripts/adj-tester/main.py +++ b/.github/workflows/scripts/adj-tester/main.py @@ -448,6 +448,26 @@ def check_packet_json( ) is_valid = False + # Ensure that if one of period_type, period, socket is present, all must be present + has_period_type = "period_type" in pkt + has_period = "period" in pkt + has_socket = "socket" in pkt + + # Count how many of the three fields are present + fields_present = sum([has_period_type, has_period, has_socket]) + + # If any field is present, all three must be present + if fields_present > 0 and fields_present < 3: + error_list.append( + logError( + path, + f"id {pkt_id}", + f"Fields 'period_type', 'period', and 'socket' must all be present together or all be absent. " + f"Found: period_type={has_period_type}, period={has_period}, socket={has_socket}", + ) + ) + is_valid = False + except RuntimeError as e: error_list.append(logError(path, "", str(e))) is_valid = False