Skip to content

Commit

Permalink
Fix grep: invalid option -- P error on Mac (#9)
Browse files Browse the repository at this point in the history
Fixes
#7 (comment)

---------

Co-authored-by: Łukasz Dziedziul <[email protected]>
  • Loading branch information
JackPGreen and ldziedziul authored Aug 16, 2024
1 parent 31f5d6f commit 5961b27
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion backport.functions
Original file line number Diff line number Diff line change
Expand Up @@ -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-
}
10 changes: 7 additions & 3 deletions backport.functions_tests
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=$?
}

Expand Down

0 comments on commit 5961b27

Please sign in to comment.