Skip to content

Commit 903da2b

Browse files
1 parent 0ab0260 commit 903da2b

File tree

7 files changed

+48
-45
lines changed

7 files changed

+48
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
steps:
77
- command: npm test
88
plugins:
9-
- check-run-reporter/check-run-reporter#v2.3.0:
9+
- check-run-reporter/check-run-reporter#v2.4.0:
1010
report: 'reports/junit/**/*.xml'
1111
token: '<your repo token>'
1212
```

bin/crr-linux

39 MB
Binary file not shown.

bin/crr-macos

44.8 MB
Binary file not shown.

bin/crr-windows.exe

33 MB
Binary file not shown.

hooks/post-command

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
set -euo pipefail
44
shopt -s globstar nullglob
55

6+
HOOKS_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
7+
PATH="$PATH:$HOOKS_DIR/../bin"
8+
69
find_root () {
710
if echo "$BUILDKITE_PLUGINS" | grep -q docker-compose-buildkite-plugin; then
811
log 'It looks like this step was run via Docker Compose.'
@@ -52,24 +55,21 @@ log "LABEL=$LABEL"
5255
log "ROOT=$ROOT"
5356
log "SHA=$SHA"
5457

55-
CMD="curl -v $URL"
56-
CMD="$CMD --user token:'$TOKEN'"
57-
CMD="$CMD -F label'=$LABEL'"
58-
CMD="$CMD -F root='$ROOT'"
59-
CMD="$CMD -F sha='$SHA'"
60-
61-
for FILE in $REPORT_DIR; do
62-
echo "Preparing to upload '$FILE' to Check Run Reporter"
63-
CMD="$CMD -F 'report=@$(pwd)/$FILE'"
64-
done
65-
6658
echo "Uploading reports to Check Run Reporter"
67-
OUT=$(eval "$CMD")
6859

69-
if [[ $OUT =~ code ]]; then
70-
echo 'Failed to upload to Check Run Reporter'
71-
echo "$OUT"
72-
exit 1
60+
BIN=
61+
if [ "$(uname)" == "Darwin" ]; then
62+
BIN=crr-macos
63+
else
64+
BIN=crr-linux
7365
fi
7466

67+
$BIN submit \
68+
--label="$LABEL" \
69+
--report="$REPORT_DIR" \
70+
--root="$ROOT" \
71+
--sha="$SHA" \
72+
--token="$TOKEN" \
73+
--url="$URL"
74+
7575
echo "Uploaded reports to Check Run Reporter"

plugin.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Check Run Reporter
22
description: Uploads test reports to check-run-reporter.com
33
author: https://github.com/check-run-reporter
4-
requirements:
5-
- curl
6-
- jq
4+
requirements: []
75
configuration:
86
properties:
97
report:

tests/post-command.bats

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bats
22

3+
EXAMPLE_REPO_COMMIT=6cbf0c4fed8f2f48ff1bbd0b537a14b6832eee0f
4+
EXAMPLE_REPO_TOKEN=a329b944-6856-4bd0-8a16-2b4a96baf76b
5+
36
setup() {
47
load 'test_helper/bats-support/load'
58
load 'test_helper/bats-assert/load'
@@ -11,42 +14,42 @@ setup() {
1114
PATH="$DIR/../hooks:$PATH"
1215
}
1316

14-
# @test "Uploads a single report" {
15-
# # Mock the environment for when we're running tests outside of buildkite
16-
# export BUILDKITE_LABEL=${BUILDKITE_LABEL:-bats}
17-
# export BUILDKITE_COMMIT=${BUILDKITE_COMMIT:-$(git rev-parse --verify HEAD)}
18-
# export BUILDKITE_PLUGINS=''
17+
@test "Uploads a single report" {
18+
# Mock the environment for when we're running tests outside of buildkite
19+
export BUILDKITE_LABEL=${BUILDKITE_LABEL:-bats}
20+
export BUILDKITE_COMMIT=$EXAMPLE_REPO_COMMIT
21+
export BUILDKITE_PLUGINS=''
1922

20-
# export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_LABEL='BATS: Single Report Upload'
21-
# export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_TOKEN=42bbb14a-ef66-4e88-8bdb-1507d6e7adc0
22-
# export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_REPORT="$DIR/success.xml"
23+
export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_LABEL='BATS: Single Report Upload'
24+
export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_TOKEN=$EXAMPLE_REPO_TOKEN
25+
export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_REPORT="$DIR/success.xml"
2326

24-
# run "post-command"
27+
run "post-command"
2528

26-
# assert_success
27-
# assert_output --partial 'Uploaded reports to Check Run Reporter'
28-
# }
29+
assert_success
30+
assert_output --partial 'Uploaded reports to Check Run Reporter'
31+
}
2932

30-
# @test "Uploads a glob of reports" {
31-
# # Mock the environment for when we're running tests outside of buildkite
32-
# export BUILDKITE_LABEL=${BUILDKITE_LABEL:-bats}
33-
# export BUILDKITE_COMMIT=${BUILDKITE_COMMIT:-$(git rev-parse --verify HEAD)}
34-
# export BUILDKITE_PLUGINS=''
33+
@test "Uploads a glob of reports" {
34+
# Mock the environment for when we're running tests outside of buildkite
35+
export BUILDKITE_LABEL=${BUILDKITE_LABEL:-bats}
36+
export BUILDKITE_COMMIT=$EXAMPLE_REPO_COMMIT
37+
export BUILDKITE_PLUGINS=''
3538

36-
# export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_LABEL='BATS: Multi Report Upload'
37-
# export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_TOKEN=42bbb14a-ef66-4e88-8bdb-1507d6e7adc0
38-
# export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_REPORT="$DIR/**/*.xml"
39+
export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_LABEL='BATS: Multi Report Upload'
40+
export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_TOKEN=$EXAMPLE_REPO_TOKEN
41+
export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_REPORT="$DIR/**/*.xml"
3942

40-
# run "post-command"
43+
run "post-command"
4144

42-
# assert_success
43-
# assert_output --partial 'Uploaded reports to Check Run Reporter'
44-
# }
45+
assert_success
46+
assert_output --partial 'Uploaded reports to Check Run Reporter'
47+
}
4548

4649
@test "Reports API errors" {
4750
# Mock the environment for when we're running tests outside of buildkite
4851
export BUILDKITE_LABEL=${BUILDKITE_LABEL:-bats}
49-
export BUILDKITE_COMMIT='${BUILDKITE_COMMIT:-$(git rev-parse --verify HEAD)}'
52+
export BUILDKITE_COMMIT='$EXAMPLE_REPO_COMMIT'
5053
export BUILDKITE_PLUGINS=''
5154

5255
export BUILDKITE_PLUGIN_CHECK_RUN_REPORTER_LABEL='BATS: Single Report Upload'
@@ -56,4 +59,6 @@ setup() {
5659
run "post-command"
5760

5861
assert_failure
62+
assert_output --partial 'code: 401'
63+
assert_output --partial 'Could not find repo token in Authorization header'
5964
}

0 commit comments

Comments
 (0)