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

ACS-6300 Add a static-name flag for reportportal-prepare action #386

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a9bcf95
ACS-6300 Extend report-portal prepare with rp-static-name flag
wojtekswieton Nov 23, 2023
3eeb5ab
ACS-6300 Add to README info about rp-static-name flag
wojtekswieton Nov 23, 2023
b13cf8f
Merge branch 'master' into feature/ACS-6300_Prepeare_Report_Portal_St…
wojtekswieton Nov 23, 2023
26d6d39
Update .github/actions/reportportal-prepare/action.yml
wojtekswieton Nov 23, 2023
49cade2
Update .github/actions/reportportal-prepare/action.yml
wojtekswieton Nov 23, 2023
c0b193d
Update .github/actions/reportportal-prepare/action.yml
wojtekswieton Nov 23, 2023
0f3597a
Update .github/actions/reportportal-prepare/get-rp-input.sh
wojtekswieton Nov 23, 2023
9e7be04
ACS-6300 Update in README.md
wojtekswieton Nov 23, 2023
3ac1244
Update docs/README.md
wojtekswieton Nov 23, 2023
7fd6659
ACS-6300 Update in README.md
wojtekswieton Nov 23, 2023
38806a8
Update .github/actions/reportportal-prepare/action.yml
wojtekswieton Nov 23, 2023
1b530ec
Update .github/actions/reportportal-prepare/action.yml
wojtekswieton Nov 23, 2023
2ac2c91
Update .github/actions/reportportal-prepare/get-rp-input.sh
wojtekswieton Nov 23, 2023
249d338
Update docs/README.md
wojtekswieton Nov 23, 2023
a067ae0
ACS-6300 Check tests update
wojtekswieton Nov 23, 2023
cc28eb4
Merge remote-tracking branch 'origin/feature/ACS-6300_Prepeare_Report…
wojtekswieton Nov 23, 2023
198b43d
ACS-6300 Check tests update
wojtekswieton Nov 23, 2023
3553d9c
ACS-6300 Check tests update
wojtekswieton Nov 23, 2023
b760375
ACS-6300 Bump version
wojtekswieton Nov 23, 2023
e8bf141
add test for static launch key
atchertchian Nov 23, 2023
ea348a7
fix summarize when using static launch key
atchertchian Nov 23, 2023
e4722c6
support spaces on launch key
atchertchian Nov 25, 2023
9abae23
ACS-6300 Bump version
wojtekswieton Nov 26, 2023
839ff46
Merge branch 'master' into feature/ACS-6300_Prepeare_Report_Portal_St…
wojtekswieton Nov 27, 2023
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
5 changes: 5 additions & 0 deletions .github/actions/reportportal-prepare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ inputs:
rp-extra-attributes:
description: Extra attributes for Report Portal
required: false
rp-use-static-launch-name:
description: If set, the rp-launch-prefix will be used as the full launch name in Report Portal
required: false
default: "false"
auto-configure:
description: >-
Enables automated default configuration (adds default GitHub context
Expand Down Expand Up @@ -54,4 +58,5 @@ runs:
RP_PROJECT: ${{ inputs.rp-project }}
RP_EXTRA_ATTRIBUTES: ${{ inputs.rp-extra-attributes }}
AUTO: ${{ inputs.auto-configure }}
USE_STATIC_LAUNCH_NAME: ${{ inputs.rp-use-static-launch-name }}
run: ${{ github.action_path }}/get-rp-input.sh
6 changes: 4 additions & 2 deletions .github/actions/reportportal-prepare/get-rp-input.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if [[ -n "$RP_LAUNCH_PREFIX" && -n "$RP_TOKEN" && -n "$RP_URL" && -n "$RP_PROJEC
echo "enabled=true" >> $GITHUB_OUTPUT

RP_LAUNCH_KEY="$RP_LAUNCH_PREFIX"
if [[ "$AUTO" == "true" ]]; then
if [[ "$AUTO" == "true" && "$USE_STATIC_LAUNCH_NAME" == "false" ]]; then
RP_LAUNCH_KEY="$RP_LAUNCH_PREFIX-$GITHUB_EVENT_NAME-$GITHUB_RUN_ID"
fi
echo "key=$RP_LAUNCH_KEY" >> $GITHUB_OUTPUT
Expand All @@ -23,7 +23,9 @@ if [[ -n "$RP_LAUNCH_PREFIX" && -n "$RP_TOKEN" && -n "$RP_URL" && -n "$RP_PROJEC
OPTS+=' "'-Drp.project="$RP_PROJECT"'"'
if [[ "$AUTO" == "true" ]]; then
OPTS+=' "'-Drp.description=["$RUN_TITLE"]\("$RUN_URL"\)'"'
OPTS+=' "'-Drp.attributes='branch:'"$BRANCH_NAME"';event:'"$GITHUB_EVENT_NAME"';repository:'"$GITHUB_REPOSITORY"';run:'"$RP_LAUNCH_KEY$RP_EXTRA_ATTRIBUTES"'"'
OPTS+=' "'-Drp.attributes='branch:'"$BRANCH_NAME"';event:'"$GITHUB_EVENT_NAME"';repository:'"$GITHUB_REPOSITORY"';ghrun:'"$GITHUB_RUN_ID"';run:'"$RP_LAUNCH_KEY$RP_EXTRA_ATTRIBUTES"'"'
else
OPTS+=' "'-Drp.attributes='ghrun:'"$GITHUB_RUN_ID$RP_EXTRA_ATTRIBUTES"'"'
fi

echo "mvn-opts=$OPTS" >> $GITHUB_OUTPUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ setup() {
export RP_URL=https://rpserver:8080
export RP_PROJECT=my-project
export AUTO=true
export USE_STATIC_LAUNCH_NAME=false

export BRANCH_NAME=main
export GITHUB_SERVER_URL=https://github.com
Expand Down Expand Up @@ -74,14 +75,34 @@ teardown() {
enabled=true
key=my-tests-push-3665876492
url=https://rpserver:8080/ui/#my-project/launches/all
mvn-opts="-Drp.launch=my-tests-push-3665876492" "-Drp.uuid=tok" "-Drp.endpoint=https://rpserver:8080" "-Drp.project=my-project" "-Drp.description=[Run on GitHub Actions 3665876492](https://github.com/mygh/repo/actions/runs/3665876492)" "-Drp.attributes=branch:main;event:push;repository:mygh/repo;run:my-tests-push-3665876492"
mvn-opts="-Drp.launch=my-tests-push-3665876492" "-Drp.uuid=tok" "-Drp.endpoint=https://rpserver:8080" "-Drp.project=my-project" "-Drp.description=[Run on GitHub Actions 3665876492](https://github.com/mygh/repo/actions/runs/3665876492)" "-Drp.attributes=branch:main;event:push;repository:mygh/repo;ghrun:3665876492;run:my-tests-push-3665876492"
BATS
)
echo "$(< $GITHUB_OUTPUT)"
[ "$(< $GITHUB_OUTPUT)" = "$expected" ]
[ "$output" = "$ECHO_ENABLED" ]
}

@test "rp enabled static" {
export USE_STATIC_LAUNCH_NAME="true"

run get-rp-input.sh
[ "$status" -eq 0 ]

expected=$(cat << BATS
enabled=true
key=my-tests
url=https://rpserver:8080/ui/#my-project/launches/all
mvn-opts="-Drp.launch=my-tests" "-Drp.uuid=tok" "-Drp.endpoint=https://rpserver:8080" "-Drp.project=my-project" "-Drp.description=[Run on GitHub Actions 3665876492](https://github.com/mygh/repo/actions/runs/3665876492)" "-Drp.attributes=branch:main;event:push;repository:mygh/repo;ghrun:3665876492;run:my-tests"
BATS
)
echo "$(< $GITHUB_OUTPUT)"
[ "$(< $GITHUB_OUTPUT)" = "$expected" ]
expected_echo="Report Portal key=my-tests, url=https://rpserver:8080/ui/#my-project/launches/all"
echo "$output"
[ "$output" = "$expected_echo" ]
}

@test "rp enabled extra" {
export RP_EXTRA_ATTRIBUTES=";metafilter:+smoke"

Expand All @@ -92,7 +113,7 @@ BATS
enabled=true
key=my-tests-push-3665876492
url=https://rpserver:8080/ui/#my-project/launches/all
mvn-opts="-Drp.launch=my-tests-push-3665876492" "-Drp.uuid=tok" "-Drp.endpoint=https://rpserver:8080" "-Drp.project=my-project" "-Drp.description=[Run on GitHub Actions 3665876492](https://github.com/mygh/repo/actions/runs/3665876492)" "-Drp.attributes=branch:main;event:push;repository:mygh/repo;run:my-tests-push-3665876492;metafilter:+smoke"
mvn-opts="-Drp.launch=my-tests-push-3665876492" "-Drp.uuid=tok" "-Drp.endpoint=https://rpserver:8080" "-Drp.project=my-project" "-Drp.description=[Run on GitHub Actions 3665876492](https://github.com/mygh/repo/actions/runs/3665876492)" "-Drp.attributes=branch:main;event:push;repository:mygh/repo;ghrun:3665876492;run:my-tests-push-3665876492;metafilter:+smoke"
BATS
)
echo "$(< $GITHUB_OUTPUT)"
Expand All @@ -112,7 +133,7 @@ BATS
enabled=true
key=my-tests-with-id
url=https://rpserver:8080/ui/#my-project/launches/all
mvn-opts="-Drp.launch=my-tests-with-id" "-Drp.uuid=tok" "-Drp.endpoint=https://rpserver:8080" "-Drp.project=my-project"
mvn-opts="-Drp.launch=my-tests-with-id" "-Drp.uuid=tok" "-Drp.endpoint=https://rpserver:8080" "-Drp.project=my-project" "-Drp.attributes=ghrun:3665876492;metafilter:+smoke"
BATS
)
echo "$(< $GITHUB_OUTPUT)"
Expand All @@ -137,7 +158,7 @@ BATS
enabled=true
key=my launch prefix with spaces-weird event-3665876492
url=https://rpserver:8080 with spaces too/ui/#my project with spaces/launches/all
mvn-opts="-Drp.launch=my launch prefix with spaces-weird event-3665876492" "-Drp.uuid=with some more spaces" "-Drp.endpoint=https://rpserver:8080 with spaces too" "-Drp.project=my project with spaces" "-Drp.description=[Run on GitHub Actions 3665876492](https://github.com/mygh/repo/actions/runs/3665876492)" "-Drp.attributes=branch:main;event:weird event;repository:mygh/repo;run:my launch prefix with spaces-weird event-3665876492"
mvn-opts="-Drp.launch=my launch prefix with spaces-weird event-3665876492" "-Drp.uuid=with some more spaces" "-Drp.endpoint=https://rpserver:8080 with spaces too" "-Drp.project=my project with spaces" "-Drp.description=[Run on GitHub Actions 3665876492](https://github.com/mygh/repo/actions/runs/3665876492)" "-Drp.attributes=branch:main;event:weird event;repository:mygh/repo;ghrun:3665876492;run:my launch prefix with spaces-weird event-3665876492"
BATS
)
echo "$(< $GITHUB_OUTPUT)"
Expand Down
13 changes: 11 additions & 2 deletions .github/actions/reportportal-summarize/get-rp-output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
CONTENT=''
URL=''

# support spaces on launch key
urlEncode() {
echo $1 | curl -Gso /dev/null -w %{url_effective} --data-urlencode @- "" | sed -E 's/..(.*).../\1/'
}

if [[ -n "$RP_LAUNCH_KEY" && -n "$RP_TOKEN" && -n "$RP_URL" && -n "$RP_PROJECT" ]]
then
echo "enabled=true" >> $GITHUB_OUTPUT

SEARCH_URL="$RP_URL/api/v1/$RP_PROJECT/launch?filter.cnt.name=$RP_LAUNCH_KEY&page.sort=startTime%2Cnumber%2CDESC"
CONTENT=$(curl -s -X GET "$SEARCH_URL" -H "accept: */*" -H "Authorization: bearer $RP_TOKEN") || CONTENT=''
CONTENT=$(curl -s -G -X GET "$RP_URL/api/v1/$RP_PROJECT/launch" \
-d "filter.cnt.name=$(urlEncode "$RP_LAUNCH_KEY")" \
-d "filter.has.compositeAttribute=ghrun:$GITHUB_RUN_ID" \
-d "page.sort=startTime,number,DESC" \
-H "Authorization: bearer $RP_TOKEN" \
) || CONTENT=''

URL="$RP_URL/ui/#$RP_PROJECT/launches/all"
else
Expand Down
7 changes: 5 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -949,16 +949,19 @@ This action is usually used in combination with [reportportal-summarize](#report
In particular, this prepares maven command line options for Report Portal integration, building the endpoint, authentication, launch key, description.
Default context information is also added (launch attributes), unless the `auto-configure` input is set to `false`.

By using the `rp-use-static-launch-name` flag, you can determine whether the launch name in Report Portal should be static or unique for each execution. By default, it is set to `false`.
Setting it to `true` means that the value from 'rp-launch-prefix' will be used as the full launch name.

Sample options with auto-configuration:

```bash
"-Drp.launch=short-run-push-3674979523" "-Drp.uuid=***" "-Drp.endpoint=http://localhost:8080" "-Drp.project=my-project" "-Drp.description=[Run on GitHub Actions 3674979523](https://github.com/Alfresco/alfresco-build-tools/actions/runs/3674979523)" "-Drp.attributes=branch:my-branch;event:push;repository:Alfresco/alfresco-build-tools;run:short-run-push-3674979523;myattribute:my-filter"
"-Drp.launch=short-run-push-3674979523" "-Drp.uuid=***" "-Drp.endpoint=http://localhost:8080" "-Drp.project=my-project" "-Drp.description=[Run on GitHub Actions 3674979523](https://github.com/Alfresco/alfresco-build-tools/actions/runs/3674979523)" "-Drp.attributes=branch:my-branch;event:push;repository:Alfresco/alfresco-build-tools;ghrun:3674979523;run:short-run-push-3674979523;myattribute:my-filter"
```

Sample options without auto-configuration:

```bash
"-Drp.launch=short-run-push" "-Drp.uuid=***" "-Drp.endpoint=http://localhost:8080" "-Drp.project=my-project"
"-Drp.launch=short-run-push" "-Drp.uuid=***" "-Drp.endpoint=http://localhost:8080" "-Drp.project=my-project" "-Drp.attributes=ghrun:3674979523"
```

Sample usage:
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v5.0.1
v5.1.0
Loading