Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDEnYO committed Aug 23, 2024
1 parent 4862328 commit f545ac6
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions .github/workflows/checkAuditRequired.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,42 +86,39 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GIT_ACTIONS_BOT_PAT_CLASSIC }}
run: |
set -x # Enable debug mode
echo "A"
##### get all labels that are assigned to this PR
assigned_labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
echo "Fetching currently assigned labels..."
# Fetch all labels assigned to this PR and store them in a variable
assigned_labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels | map(.name) | .[]')
echo "Assigned labels: $assigned_labels" # Debugging output
echo "B"
##### check if 'AuditRequired' is assigned
audit_required_assigned=$(echo "$assigned_labels" | grep -c "AuditRequired")
echo "AuditRequired assigned: $audit_required_assigned" # Debugging output
echo "C"
##### check if 'AuditNotRequired' is assigned
echo "$assigned_labels"
echo "C1"
echo "$(echo "AuditRequired" | grep -c "AuditNotRequired")"
echo "C2"
echo "$(echo "$assigned_labels" | grep -c "AuditNotRequired")"
echo "C3"
# Initialize counters for labels of interest
audit_required_assigned=0
audit_not_required_assigned=0
echo "C4"
audit_not_required_assigned=$(echo "$assigned_labels" | grep -c "AuditNotRequired")
echo "C5"
echo "AuditNotRequired assigned: $audit_not_required_assigned" # Debugging output
echo "D"
##### make sure that exactly one of the two labels is assigned
# Loop through assigned labels and count occurrences of the specific labels
for label in $assigned_labels; do
if [[ "$label" == "AuditRequired" ]]; then
((audit_required_assigned++))
elif [[ "$label" == "AuditNotRequired" ]]; then
((audit_not_required_assigned++))
fi
done
echo "AuditRequired assigned: $audit_required_assigned"
echo "AuditNotRequired assigned: $audit_not_required_assigned"
# Calculate total labels assigned that are of interest
total_labels_assigned=$((audit_required_assigned + audit_not_required_assigned))
echo "Total labels assigned: $total_labels_assigned" # Debugging output
echo "Total labels assigned: $total_labels_assigned"
echo "E"
# Check that exactly one of the two labels is assigned
if [[ "$total_labels_assigned" -ne 1 ]]; then
echo -e "\033[31mError: Exactly one of the two labels should be assigned but found $total_labels_assigned assigned labels.\033[0m"
exit 1
else
echo -e "\033[32mVerified that exactly one label is assigned.\033[0m"
echo -e "\033[32mAll good :)\033[0m"
fi

0 comments on commit f545ac6

Please sign in to comment.