mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
This adds the Metalava Gradle plugin to the Gradle build. I have also generated the 0.29.0 and 0.30.0 dumps. I had originally used an existing Gradle Metalava plugin, but that didn't seem to work well for us. It especially failed at passing custom args to Metalava, which we need to do. Instead, I forked the setup from https://github.com/autonomousapps/dependency-analysis-gradle-plugin and customised it to better fit our needs: * Use the latest Metalava * Fix all the issues I found in it (no idea how it even compiles for them, even though we're on the same Gradle version) * Add a distinction between stable and experimental dumps This also: * Updates the IJ icon generator to emit a properly annotated AllIcons keys file * Updates JUnit 5 to the latest version, 5.13.4 [Gradle] * Fixes the JUnit setup for the detekt-plugin module [Gradle] * Bumps the IJP target to the latest stable (252.23892.409) [Gradle] * Removes the old Gradle-based icon generator (JEWEL-979) [Gradle] * Runs Metalava on the GitHub CI * Update GitHub CI commit validator to support multiple issues in one closes https://github.com/JetBrains/intellij-community/pull/3199 (cherry picked from commit 8255383d77be24919f91e45ccbe1340c25696429) # Conflicts: # community/platform/jewel/ui/generated/org/jetbrains/jewel/ui/icons/AllIconsKeys.java GitOrigin-RevId: 2117337c0bade7d9e439cdcc0265d378f0427eb3
80 lines
3.0 KiB
Bash
80 lines
3.0 KiB
Bash
#!/usr/bin/env bash
|
|
# Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
set -e
|
|
set -o pipefail
|
|
|
|
source "$(dirname "$0")/utils.sh"
|
|
|
|
# Precondition checks: gh tool on path, and PR_NUMBER env
|
|
check_gh_tool
|
|
check_pr_number
|
|
|
|
echo "Checking commit messages for PR #$PR_NUMBER"
|
|
|
|
# Create a temporary file to signal if a check has failed.
|
|
# This is a workaround for the subshell issue with `while` loops,
|
|
# where `exit 1` would only terminate the subshell, not the script.
|
|
fail_flag=$(mktemp)
|
|
|
|
# Ensure the fail flag file is removed when the script completes.
|
|
trap 'rm -f -- "$fail_flag"' EXIT
|
|
|
|
gh pr view "$PR_NUMBER" --json commits --jq '.commits[].messageHeadline' | while IFS= read -r message; do
|
|
# 1. Validate commit message format.
|
|
# The regex checks for a ticket ID like [JEWEL-123] followed by a space.
|
|
# Using [[:space:]] is slightly more robust than a literal space ' '.
|
|
if ! echo "$message" | grep -qE '^\[(JEWEL-[0-9]+)(,\s*JEWEL-[0-9]+)*\][ ]'; then
|
|
echoerr "ERROR: Invalid commit message format: '$message'"
|
|
echoerr "Each commit message must start with '[JEWEL-xxx] ', where xxx is a YouTrack issue number."
|
|
echoerr "You can also have multiple, comma-separated issues. E.g.: '[JEWEL-xxx,JEWEL-yyy] '"
|
|
echo "1" > "$fail_flag"
|
|
break
|
|
fi
|
|
|
|
# 2. If a secret is available, validate the issue against the YouTrack API.
|
|
if [ -n "$JEWEL_YT_TOKEN" ]; then
|
|
issue_id=${BASH_REMATCH[1]}
|
|
echo "YouTrack token is present, validating issue $issue_id..."
|
|
|
|
# Obtain the draft and resolved status of the issue, and append the HTTP status code.
|
|
# The -s flag silences progress, and -w "%{http_code}" appends the status code to the output.
|
|
response=$(curl -s -w "%{http_code}" \
|
|
-H "Authorization: Bearer $JEWEL_YT_TOKEN" \
|
|
-H "Accept: application/json" \
|
|
"https://youtrack.jetbrains.com/api/issues/$issue_id?fields=resolved,isDraft")
|
|
|
|
# Extract the HTTP status code and the JSON body from the response string.
|
|
http_code=${response: -3}
|
|
body=${response:0:$((${#response} - 3))}
|
|
|
|
if [ "$http_code" -ne 200 ]; then
|
|
fail_check "ERROR: YouTrack issue $issue_id not found or there was an API error.\n\nHTTP status: $http_code\n\nPlease check the issue ID and your YouTrack permissions."
|
|
echo "1" > "$fail_flag"
|
|
break
|
|
fi
|
|
|
|
# Use jq to parse the JSON response.
|
|
is_resolved=$(echo "$body" | jq -r '.resolved')
|
|
if [ "$is_resolved" != "null" ]; then
|
|
fail_check "ERROR: YouTrack issue $issue_id is already resolved."
|
|
echo "1" > "$fail_flag"
|
|
break
|
|
fi
|
|
|
|
is_draft=$(echo "$body" | jq -r '.isDraft')
|
|
if [ "$is_draft" == "true" ]; then
|
|
fail_check "ERROR: YouTrack issue $issue_id is a draft."
|
|
echo "1" > "$fail_flag"
|
|
break
|
|
fi
|
|
|
|
echo "Issue $issue_id is valid and not resolved or a draft."
|
|
else
|
|
echowarn "YouTrack token is not present, skipping YouTrack validation."
|
|
fi
|
|
done
|
|
|
|
if [ -s "$fail_flag" ]; then
|
|
exit 1
|
|
fi
|