Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix grep: invalid option -- P error on Mac #9

Merged
merged 8 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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