From 380fcb447fbb309f1037064baa79815622fdfc3d Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Mon, 30 Oct 2023 13:54:56 +0100 Subject: [PATCH] DRAFT: Make integration-tests setup Mac compatible --- .github/workflows/run-integration-tests.yml | 5 +++- integration-tests/checkstyle-10.12.4.sh | 30 ++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index a51bba27068..66d1b454053 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -14,9 +14,12 @@ permissions: jobs: run-integration-tests: name: On-demand integration test + strategy: + matrix: + os: [ ubuntu-22.04, macos-12 ] + runs-on: ${{ matrix.os }} if: | github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') - runs-on: ubuntu-22.04 steps: - name: Check out code uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 diff --git a/integration-tests/checkstyle-10.12.4.sh b/integration-tests/checkstyle-10.12.4.sh index a6bf87bd195..c8df4e5712e 100755 --- a/integration-tests/checkstyle-10.12.4.sh +++ b/integration-tests/checkstyle-10.12.4.sh @@ -2,7 +2,10 @@ set -e -u -o pipefail -integration_test_root="$(readlink -f "$(dirname "${0}")")" +integration_test_root="$(cd `dirname -- $0` && pwd)" +integration_test_root_2="$(readlink -f "$(dirname "${0}")")" +echo "1: ${integration_test_root}" +echo "2: ${integration_test_root_2}" error_prone_support_root="${integration_test_root}/.." repos_root="${integration_test_root}/.repos" @@ -25,6 +28,21 @@ else trap 'rm -rf -- "${report_directory}"' INT TERM HUP EXIT fi +case "$(uname -s)" in + Linux*) + grep_command=grep + sed_command=sed + ;; + Darwin*) + grep_command=ggrep + sed_command=gsed + ;; + *) + echo "Unsupported distribution $(uname -s) for this script." + exit 1 + ;; +esac + # XXX: Configure Renovate to manage the AssertJ version declared here. shared_build_flags=" -Perror-prone-compile,error-prone-test-compile @@ -48,14 +66,14 @@ error_prone_shared_flags='-XepExcludedPaths:(\Q${project.basedir}${file.separato error_prone_patch_flags="${error_prone_shared_flags} -XepPatchLocation:IN_PLACE -XepPatchChecks:$( find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \ - | xargs -0 grep -hoP '[^.]+$' \ + | xargs -0 ${grep_command} -hoP '[^.]+$' \ | paste -s -d ',' )" error_prone_validation_flags="${error_prone_shared_flags} -XepDisableAllChecks $( find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \ - | xargs -0 grep -hoP '[^.]+$' \ - | sed -r 's,(.*),-Xep:\1:WARN,' \ + | xargs -0 ${grep_command} -hoP '[^.]+$' \ + | ${sed_command} -r 's,(.*),-Xep:\1:WARN,' \ | paste -s -d ' ' )" @@ -151,12 +169,12 @@ mvn ${shared_build_flags} \ # Collect the applied changes. expected_changes="${integration_test_root}/${test_name}-expected-changes.patch" actual_changes="${report_directory}/${test_name}-changes.patch" -(git diff "${diff_base}"..HEAD | grep -vP '^(diff|index)' || true) > "${actual_changes}" +(git diff "${diff_base}"..HEAD | ${grep_command} -vP '^(diff|index)' || true) > "${actual_changes}" # Collect the warnings reported by Error Prone Support checks. expected_warnings="${integration_test_root}/${test_name}-expected-warnings.txt" actual_warnings="${report_directory}/${test_name}-validation-build-warnings.txt" -(grep -oP "(?<=^\\Q[WARNING] ${PWD}/\\E).*" "${validation_build_log}" | grep -P '\] \[' || true) | LC_ALL=C sort > "${actual_warnings}" +(${grep_command} -oP "(?<=^\\Q[WARNING] ${PWD}/\\E).*" "${validation_build_log}" | ${grep_command} -P '\] \[' || true) | LC_ALL=C sort > "${actual_warnings}" # Persist or validate the applied changes and reported warnings. if [ -n "${do_sync}" ]; then