From a742945e95c2e2dc379e324ecb7eedb5f581d5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 10 Sep 2024 09:49:01 +0200 Subject: [PATCH 1/2] Fall back empty versions to "not set" This way they will trigger the warning comment --- script/ci/version_check.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/script/ci/version_check.sh b/script/ci/version_check.sh index 39558a4984fd..7f35fcb2b44d 100755 --- a/script/ci/version_check.sh +++ b/script/ci/version_check.sh @@ -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 @@ -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 From dadb0c9a5c7e13f7a03ef52092860855270b547d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 10 Sep 2024 10:00:29 +0200 Subject: [PATCH 2/2] exit 0 on no URL found --- .github/workflows/version-check.yml | 2 +- script/ci/version_check.sh | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml index ae59544f94ed..0405fd47f940 100644 --- a/.github/workflows/version-check.yml +++ b/.github/workflows/version-check.yml @@ -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' diff --git a/script/ci/version_check.sh b/script/ci/version_check.sh index 7f35fcb2b44d..29eaeb3ffe6e 100755 --- a/script/ci/version_check.sh +++ b/script/ci/version_check.sh @@ -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." @@ -74,9 +74,9 @@ 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 "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