diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index 8e75806..b74b9ad 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -5,8 +5,13 @@ on: jobs: test: - runs-on: ubuntu-latest - + strategy: + matrix: + runs-on: + - ubuntu-latest + - macos-latest + name: Test (${{matrix.runs-on}}) + runs-on: ${{matrix.runs-on}} steps: - uses: actions/checkout@v4 - run: ./backport.functions_tests diff --git a/backport.functions b/backport.functions index 373108b..2fd3a14 100755 --- a/backport.functions +++ b/backport.functions @@ -5,5 +5,5 @@ set -e function get_pr_number() { local commit_msg=$1 - echo "$commit_msg" | grep -oP '#(\d+)' | tail -n1 | cut -c2- + echo "$commit_msg" | grep --extended-regexp --only-matching '#[0-9]+' | tail -n1 | cut -c2- } diff --git a/backport.functions_tests b/backport.functions_tests index 03cba9c..af3e1a4 100755 --- a/backport.functions_tests +++ b/backport.functions_tests @@ -4,9 +4,13 @@ set -eu SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" # Source the latest version of assert.sh unit testing library and include in current shell -assert_script_content=$(curl --silent https://raw.githubusercontent.com/hazelcast/assert.sh/main/assert.sh) +curl --silent https://raw.githubusercontent.com/hazelcast/assert.sh/main/assert.sh --output assert.sh + # shellcheck source=/dev/null -. <(echo "${assert_script_content}") +# You _should_ be able to avoid a temporary file with something like +# . <(echo "${assert_script_content}") +# But this doesn't work on the MacOS GitHub runner (but does on MacOS locally) +. assert.sh . "$SCRIPT_DIR"/backport.functions TESTS_RESULT=0 @@ -15,7 +19,7 @@ function test_get_pr_number { local commit_msg=$1 local expected_pr_number=$2 local actual_pr_number=$(get_pr_number "$commit_msg") - local MSG="Expected PR Number extracted from \"$commit_msg\"" + local MSG="Expected PR Number extracted from \"$commit_msg\" should be equal to \"$expected_pr_number\"" assert_eq "$expected_pr_number" "$actual_pr_number" "$MSG" && log_success "$MSG" || TESTS_RESULT=$? }