Skip to content

Commit

Permalink
chore: reverted code
Browse files Browse the repository at this point in the history
  • Loading branch information
albertolive committed Oct 18, 2024
1 parent 99bb5c2 commit faf540d
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions .circleci/scripts/check_mmi_trigger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ PR_NUMBER=$(echo "$CIRCLE_PULL_REQUEST" | awk -F'/' '{print $NF}')
REPO_OWNER="$CIRCLE_PROJECT_USERNAME"
REPO_NAME=$(basename "$CIRCLE_REPOSITORY_URL" .git)

# Fetch PR details and reviews using GitHub API
API_URL="https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER"
PR_DETAILS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$API_URL")
REVIEWS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$API_URL/reviews")

# Check if the API requests were successful
if [[ -z "$PR_DETAILS" || -z "$REVIEWS" ]]; then
echo "Error: Unable to fetch PR details or reviews from GitHub API."
exit 1
fi
# Fetch PR details using GitHub API
PR_DETAILS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER")

# Fetch submitted reviews
SUBMITTED_REVIEWS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/reviews")

# Check for label 'team-mmi'
LABEL_EXISTS=$(jq -r '.labels[]? | select(.name == "team-mmi") | length > 0' <<< "$PR_DETAILS")
Expand All @@ -34,21 +31,28 @@ REVIEWER_REQUESTED=$(jq -r '.requested_reviewers[]? | select(.login == "mmi") |
# Check for team reviewer 'mmi'
TEAM_REQUESTED=$(jq -r '.requested_teams[]? | select(.slug == "mmi") | length > 0' <<< "$PR_DETAILS")

# Check if 'mmi' has submitted a review
REVIEWER_SUBMITTED=$(jq -r '.[]? | select(.user.login == "mmi") | length > 0' <<< "$REVIEWS")
# Check if 'mmi' submitted a review
REVIEWER_SUBMITTED=$(jq -r '.[]? | select(.user.login == "mmi") | length > 0' <<< "$SUBMITTED_REVIEWS")

# Evaluate whether to run MMI tests
# Determine which condition was met and trigger tests if needed
if [[ "$LABEL_EXISTS" == "true" || "$REVIEWER_REQUESTED" == "true" || "$TEAM_REQUESTED" == "true" || "$REVIEWER_SUBMITTED" == "true" ]]; then
echo "run_mmi_tests=true" > mmi_trigger.env

# Log exactly which condition was met
echo "Conditions met:"
[[ "$LABEL_EXISTS" == "true" ]] && echo "- Label 'team-mmi' found."
[[ "$REVIEWER_REQUESTED" == "true" ]] && echo "- Reviewer 'mmi' requested."
[[ "$TEAM_REQUESTED" == "true" ]] && echo "- Team 'mmi' requested."
[[ "$REVIEWER_SUBMITTED" == "true" ]] && echo "- Reviewer 'mmi' submitted a review."

if [[ "$LABEL_EXISTS" == "true" ]]; then
echo "- Label 'team-mmi' found."
fi
if [[ "$REVIEWER_REQUESTED" == "true" ]]; then
echo "- Reviewer 'mmi' requested."
fi
if [[ "$TEAM_REQUESTED" == "true" ]]; then
echo "- Team 'mmi' requested."
fi
if [[ "$REVIEWER_SUBMITTED" == "true" ]]; then
echo "- Reviewer 'mmi' submitted a review."
fi
else
echo "run_mmi_tests=false" > mmi_trigger.env
echo "Skipping MMI tests: No 'team-mmi' label found, and no 'MetaMask/mmi' reviewer assigned or review submitted."
echo "Skipping MMI tests: Neither the 'team-mmi' label was found nor a reviewer from the 'MetaMask/mmi' team was assigned."
fi

0 comments on commit faf540d

Please sign in to comment.