Skip to content

Commit 7d692d3

Browse files
committed
Unify issue search
1 parent 161a3d9 commit 7d692d3

File tree

1 file changed

+39
-20
lines changed

1 file changed

+39
-20
lines changed

.github/workflows/verify-new-library-version-compatibility.yml

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,22 @@ jobs:
9494
9595
readarray -t VERSIONS < <(echo '${{ toJson(matrix.item.versions) }}' | jq -r '.[]')
9696
FIRST_TESTING_VERSION="${VERSIONS[0]}"
97+
GAV_COORDINATES="$GROUP_ID:$ARTIFACT_ID:$FIRST_TESTING_VERSION"
98+
TITLE_END="${{ env.ISSUE_TITLE_MIDDLE }}$GAV_COORDINATES"
9799
98-
TITLE_SEARCH="${{ env.ISSUE_TITLE_MIDDLE }}$GROUP_ID:$ARTIFACT_ID:$FIRST_TESTING_VERSION"
99-
100-
ISSUE_NUMBER=$(gh issue list --repo "${{ github.repository }}" --state open --search "in:title $TITLE_SEARCH" --json number,title --jq \
101-
'.[] | select(.title | endswith("'"$TITLE_SEARCH"'")) | .number')
100+
ISSUE_NUMBER=$(
101+
gh issue list \
102+
--repo "${{ github.repository }}" \
103+
--state open \
104+
--search "\"$TITLE_END\" in:title" \
105+
--json number,title \
106+
--jq ".[] | select(.title | (startswith(\"${{ env.ISSUE_TITLE_PREFIX }}\") and endswith(\"$TITLE_END\"))) | .number"
107+
)
102108
109+
echo "Found the issue(s) $ISSUE_NUMBER"
103110
if [[ -n "$ISSUE_NUMBER" ]]; then
104111
echo "skip=true" >> "$GITHUB_OUTPUT"
105-
echo "There is no progress since last time this version was tested. Skipping further steps."
112+
echo "There is no progress since last time for the $GAV_COORDINATES. Skipping further testing!"
106113
else
107114
echo "skip=false" >> "$GITHUB_OUTPUT"
108115
fi
@@ -146,7 +153,7 @@ jobs:
146153
# Fetch the job URL
147154
JOB_ID=$(
148155
gh run view "${{ github.run_id }}" --repo "${{ github.repository }}" --json jobs \
149-
| jq -r --arg name "$CURRENT_JOB_NAME" '.jobs[] | select(.name | startswith($name)) | .databaseId' \
156+
--jq ".jobs[] | select(.name | startswith(\"$CURRENT_JOB_NAME\")) | .databaseId" \
150157
| head -n1
151158
)
152159
if [ -z "$JOB_ID" ] || [ "$JOB_ID" = "null" ]; then
@@ -218,9 +225,26 @@ jobs:
218225
219226
FAILED_VERSION="${{ steps.runtests.outputs.failed_version }}"
220227
REPO="${{ github.repository }}"
221-
TITLE="${{ env.ISSUE_TITLE_PREFIX }}${{ steps.runtests.outputs.failure_type }}${{ env.ISSUE_TITLE_MIDDLE }}${{ matrix.item.name }}:$FAILED_VERSION"
228+
GAV_COORDINATES="${{ matrix.item.name }}:$FAILED_VERSION"
229+
TITLE_END="${{ env.ISSUE_TITLE_MIDDLE }}$GAV_COORDINATES"
230+
TITLE="${{ env.ISSUE_TITLE_PREFIX }}${{ steps.runtests.outputs.failure_type }}$TITLE_END"
222231
FAILURE_LABEL="fails-$(echo "${{ steps.runtests.outputs.failure_type }}" | sed 's/ /-/g')"
223232
233+
echo "Searching for an issue that ends with: $TITLE_END"
234+
ISSUE_NUMBER=$(
235+
gh issue list \
236+
--repo "${{ github.repository }}" \
237+
--state open \
238+
--search "\"$TITLE_END\" in:title" \
239+
--json number,title \
240+
--jq ".[] | select(.title | (startswith(\"${{ env.ISSUE_TITLE_PREFIX }}\") and endswith(\"$TITLE_END\"))) | .number"
241+
)
242+
if [ -n "$ISSUE_NUMBER" ]; then
243+
echo "Must not reach here as the issue already exists: $ISSUE_NUMBER"
244+
echo "The previous stage should of failed before."
245+
exit 1
246+
fi
247+
224248
BODY_FILE=$(mktemp)
225249
# Use single-quoted here-doc to disable any shell expansion of log content
226250
cat > "$BODY_FILE" <<'EOF'
@@ -233,19 +257,14 @@ jobs:
233257
```
234258
EOF
235259
236-
ISSUE_NUMBER=$(gh issue list --repo "$REPO" --state open --search "$TITLE" --json number,title --jq '.[] | select(.title | startswith("'"$TITLE"'")) | .number')
237-
if [ -n "$ISSUE_NUMBER" ]; then
238-
echo "Updating existing issue #$ISSUE_NUMBER"
239-
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --body-file "$BODY_FILE"
240-
else
241-
echo "Creating a new issue"
242-
gh issue create \
243-
--repo "$REPO" \
244-
--title "$TITLE" \
245-
--body-file "$BODY_FILE" \
246-
--label "library-unsupported-version" \
247-
--label "$FAILURE_LABEL"
248-
fi
260+
echo "Creating a new issue"
261+
gh issue create \
262+
--repo "$REPO" \
263+
--title "$TITLE" \
264+
--body-file "$BODY_FILE" \
265+
--label "library-unsupported-version" \
266+
--label "$FAILURE_LABEL"
267+
249268
250269
rm "$BODY_FILE"
251270

0 commit comments

Comments
 (0)