Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: buildkite-plugins/test-collector-buildkite-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5.0
Choose a base ref
...
head repository: buildkite-plugins/test-collector-buildkite-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.6.0
Choose a head ref
  • 6 commits
  • 4 files changed
  • 2 contributors

Commits on Jan 30, 2023

  1. Copy the full SHA
    34e26cf View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1d500e8 View commit details
  3. Copy the full SHA
    1356ae2 View commit details
  4. Copy the full SHA
    e848018 View commit details
  5. Copy the full SHA
    3478933 View commit details

Commits on Feb 20, 2023

  1. Copy the full SHA
    f753eb1 View commit details
Showing with 41 additions and 7 deletions.
  1. +10 −6 README.md
  2. +2 −1 hooks/pre-exit
  3. +2 −0 plugin.yml
  4. +27 −0 tests/pre-exit-success.bats
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -30,6 +30,10 @@ Default value: `BUILDKITE_ANALYTICS_TOKEN`

Full URL for the API to upload to. Defaults to `https://analytics-api.buildkite.com/v1/uploads`

#### `base-path` (string)

Where to search for files to upload. Defaults to the working directory `.`

#### `branches` (string)

String containing a regex to only do an upload in branches that match it (using the case-insensitive bash `=~` operator against the `BUILDKITE_BRANCH` environment variable).
@@ -83,7 +87,7 @@ steps:
- label: "🔨 Test"
command: "make test"
plugins:
- test-collector#v1.5.0:
- test-collector#v1.6.0:
files: "test/junit-*.xml"
format: "junit"
```
@@ -97,7 +101,7 @@ steps:
- label: "🔨 Test"
command: "make test"
plugins:
- test-collector#v1.5.0:
- test-collector#v1.6.0:
files: "test-data-*.json"
format: "json"
```
@@ -118,7 +122,7 @@ steps:
- label: "🔍 Test Analytics"
command: buildkite-agent artifact download tests-*.xml
plugins:
- test-collector#v1.5.0:
- test-collector#v1.6.0:
files: "tests-*.xml"
format: "junit"
```
@@ -132,7 +136,7 @@ steps:
- label: "🔨 Test"
command: "make test"
plugins:
- test-collector#v1.5.0:
- test-collector#v1.6.0:
files: "test-data-*.json"
format: "json"
branches: "-qa$"
@@ -145,7 +149,7 @@ steps:
- label: "🔨 Test"
command: "make test"
plugins:
- test-collector#v1.5.0:
- test-collector#v1.6.0:
files: "test-data-*.json"
format: "json"
exclude-branches: "^legacy$"
@@ -158,7 +162,7 @@ steps:
- label: "🔨 Test"
command: "make test"
plugins:
- test-collector#v1.5.0:
- test-collector#v1.6.0:
files: "test-data-*.json"
format: "json"
branches: "^stage-"
3 changes: 2 additions & 1 deletion hooks/pre-exit
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ TOKEN_ENV_NAME="${BUILDKITE_PLUGIN_TEST_COLLECTOR_API_TOKEN_ENV_NAME:-BUILDKITE_
FILES_PATTERN="${BUILDKITE_PLUGIN_TEST_COLLECTOR_FILES:-}"
FORMAT="${BUILDKITE_PLUGIN_TEST_COLLECTOR_FORMAT:-}"
TIMEOUT="${BUILDKITE_PLUGIN_TEST_COLLECTOR_TIMEOUT:-30}"
BASE_PATH="${BUILDKITE_PLUGIN_TEST_COLLECTOR_BASE_PATH:-.}"
DEBUG="false"

if [[ "${BUILDKITE_PLUGIN_TEST_COLLECTOR_DEBUG:-}" =~ ^(true|on|1|always)$ ]]; then
@@ -101,7 +102,7 @@ fi
matching_files=()
while IFS=$'' read -r matching_file ; do
matching_files+=("$matching_file")
done < <("${FIND_CMD[@]}" . -path "./${FILES_PATTERN}")
done < <("${FIND_CMD[@]}" "${BASE_PATH}" -path "${BASE_PATH}/${FILES_PATTERN}")

if [[ "${#matching_files[@]}" -eq "0" ]]; then
echo "No files found matching '${FILES_PATTERN}'"
2 changes: 2 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ configuration:
type: string
api-url:
type: string
base-path:
type: string
branches:
type: string
debug:
27 changes: 27 additions & 0 deletions tests/pre-exit-success.bats
Original file line number Diff line number Diff line change
@@ -166,4 +166,31 @@ COMMON_CURL_OPTIONS='--form \* --form \* --form \* --form \* --form \* --form \*
assert_output --partial "against https://test-api.example.com/v2"

unstub curl
}

@test "Base path can be changed" {
export BUILDKITE_PLUGIN_TEST_COLLECTOR_BASE_PATH='/test'

stub find "/test -path /test/\*\*/\*/junit-1.xml : echo '/test/tests/fixtures/junit-1.xml'"
stub curl "-X POST --silent --show-error --max-time 30 --form format=junit ${COMMON_CURL_OPTIONS} \* -H \* : echo 'curl success'"

run "${PWD}/hooks/pre-exit"

unstub curl
unstub find

assert_success
assert_output --partial "curl success"
}

@test "Absorb curl failures" {
stub curl "-X POST --silent --show-error --max-time 30 --form format=junit ${COMMON_CURL_OPTIONS} \* -H \* : exit 10"

run "$PWD/hooks/pre-exit"

unstub curl

assert_success
assert_output --partial "Uploading './tests/fixtures/junit-1.xml'..."
assert_output --partial "Error uploading, will continue"
}