Skip to content

Commit

Permalink
Merge pull request #16686 from opf/chore/version-check-fallback
Browse files Browse the repository at this point in the history
Fall back empty versions to "not set"
  • Loading branch information
oliverguenther authored Sep 10, 2024
2 parents e14dad2 + dadb0c9 commit bcd9552
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- name: Verify linked version matches core version
id: version-check
run: ./script/ci/version_check.sh ${{ github.event.pull_request.body }}
run: ./script/ci/version_check.sh "${{ github.event.pull_request.body }}"

- name: Add comment if versions differ
if: steps.version-check.outputs.version_mismatch == 'true'
Expand Down
15 changes: 7 additions & 8 deletions script/ci/version_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ set -e

# script/ci/version_check

PR_BODY="$1"
PR_BODY="$@"

# Extract URL from PR description
WP_URL=$(echo "${PR_BODY}" | grep -oE 'https://community.openproject.org/(wp|work_packages|projects/[^/]+/work_packages)/[0-9]+')
WP_URL=$(echo "$PR_BODY" | grep -oE 'https://community.openproject.org/(wp|work_packages|projects/[^/]+/work_packages)/[0-9]+' || true)

if [ -z "$WP_URL" ]; then
echo "::warning::PR description does not contain a valid URL to an OpenProject ticket."
Expand All @@ -56,7 +56,7 @@ if [ "$HTTP_STATUS" -ne 200 ]; then
exit 0
fi

VERSION_FROM_API=$(jq -r '._links.version.title // empty' response.json)
VERSION_FROM_API=$(jq -r '._links.version.title // "not set"' response.json)
if [ -z "$VERSION_FROM_API" ]; then
echo "::warning::Failed to extract version from API response."
exit 0
Expand All @@ -73,11 +73,10 @@ echo "Version from file: $VERSION_FROM_FILE"
if [[ "$VERSION_FROM_API" != "$VERSION_FROM_FILE" ]]; then
echo "Version mismatch detected."


echo "version_mismatch=true" >> $GITHUB_OUTPUT
echo "wp_url=${WP_URL}" >> $GITHUB_OUTPUT
echo "wp_version=${VERSION_FROM_API}" >> $GITHUB_OUTPUT
echo "core_version=${VERSION_FROM_FILE}" >> $GITHUB_OUTPUT
echo "version_mismatch=true" >> "$GITHUB_OUTPUT"
echo "wp_url=${WP_URL}" >> "$GITHUB_OUTPUT"
echo "wp_version=${VERSION_FROM_API}" >> "$GITHUB_OUTPUT"
echo "core_version=${VERSION_FROM_FILE}" >> "$GITHUB_OUTPUT"
else
echo "Version from the work package ${WORK_PACKAGE_ID} matches the version in the version file this PR targets."
fi

0 comments on commit bcd9552

Please sign in to comment.