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.4.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.5.0
Choose a head ref
  • 9 commits
  • 5 files changed
  • 4 contributors

Commits on Jan 9, 2023

  1. Copy the full SHA
    e634510 View commit details
  2. Merge pull request #31 from buildkite-plugins/renovate/buildkite-plug…

    …in-tester-4.x
    
    Update buildkite/plugin-tester Docker tag to v4
    toote authored Jan 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1c81234 View commit details
  3. Copy the full SHA
    cde55bd View commit details
  4. Copy the full SHA
    bd5c5b5 View commit details
  5. Copy the full SHA
    9238248 View commit details

Commits on Jan 13, 2023

  1. Copy the full SHA
    bc765bd View commit details
  2. Simplified condition

    toote committed Jan 13, 2023
    Copy the full SHA
    9a30ad6 View commit details
  3. Merge pull request #32 from buildkite-plugins/toote_api_config

    Configurable API
    pzeballos authored Jan 13, 2023
    Copy the full SHA
    b1e4543 View commit details
  4. Merge pull request #34 from buildkite-plugins/toote_bash4.3_compat

    Bash 4.3 compatibility
    pzeballos authored Jan 13, 2023
    Copy the full SHA
    fd4f463 View commit details
Showing with 39 additions and 17 deletions.
  1. +10 −6 README.md
  2. +1 −1 docker-compose.yml
  3. +11 −10 hooks/pre-exit
  4. +2 −0 plugin.yml
  5. +15 −0 tests/pre-exit-success.bats
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@ Name of the environment variable that contains the Test Analytics API token.

Default value: `BUILDKITE_ANALYTICS_TOKEN`

#### `api-url` (string)

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

#### `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).
@@ -79,7 +83,7 @@ steps:
- label: "🔨 Test"
command: "make test"
plugins:
- test-collector#v1.4.0:
- test-collector#v1.5.0:
files: "test/junit-*.xml"
format: "junit"
```
@@ -93,7 +97,7 @@ steps:
- label: "🔨 Test"
command: "make test"
plugins:
- test-collector#v1.4.0:
- test-collector#v1.5.0:
files: "test-data-*.json"
format: "json"
```
@@ -114,7 +118,7 @@ steps:
- label: "🔍 Test Analytics"
command: buildkite-agent artifact download tests-*.xml
plugins:
- test-collector#v1.4.0:
- test-collector#v1.5.0:
files: "tests-*.xml"
format: "junit"
```
@@ -128,7 +132,7 @@ steps:
- label: "🔨 Test"
command: "make test"
plugins:
- test-collector#v1.4.0:
- test-collector#v1.5.0:
files: "test-data-*.json"
format: "json"
branches: "-qa$"
@@ -141,7 +145,7 @@ steps:
- label: "🔨 Test"
command: "make test"
plugins:
- test-collector#v1.4.0:
- test-collector#v1.5.0:
files: "test-data-*.json"
format: "json"
exclude-branches: "^legacy$"
@@ -154,7 +158,7 @@ steps:
- label: "🔨 Test"
command: "make test"
plugins:
- test-collector#v1.4.0:
- test-collector#v1.5.0:
files: "test-data-*.json"
format: "json"
branches: "^stage-"
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '2'
services:
tests:
image: buildkite/plugin-tester:v3.0.1
image: buildkite/plugin-tester:v4.0.0
volumes:
- ".:/plugin:ro"
21 changes: 11 additions & 10 deletions hooks/pre-exit
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ upload() {
curl_args+=("--form" "run_env[version]=$PLUGIN_VERSION")
fi

curl_args+=("https://analytics-api.buildkite.com/v1/uploads")
curl_args+=("${BUILDKITE_PLUGIN_TEST_COLLECTOR_API_URL:-https://analytics-api.buildkite.com/v1/uploads}")

# Print debugging output before we add the token, so it doesn't ever get
# printed to output
@@ -105,14 +105,15 @@ done < <("${FIND_CMD[@]}" . -path "./${FILES_PATTERN}")

if [[ "${#matching_files[@]}" -eq "0" ]]; then
echo "No files found matching '${FILES_PATTERN}'"
if [[ -z "${BUILDKITE_COMMAND_EXIT_STATUS+x}" ]] || [[ "${BUILDKITE_COMMAND_EXIT_STATUS}" -eq "0" ]]; then
if [[ "${BUILDKITE_COMMAND_EXIT_STATUS:-0}" -eq "0" ]]; then
exit 1
fi
fi

for file in "${matching_files[@]}"; do
echo "Uploading '$file'..."
if ! upload "$TOKEN_VALUE" "$FORMAT" "${file}"; then
echo "Error uploading, will continue"
fi
done
else
# needs to be part of else for bash4.3 compatibility
for file in "${matching_files[@]}"; do
echo "Uploading '$file'..."
if ! upload "$TOKEN_VALUE" "$FORMAT" "${file}"; then
echo "Error uploading, will continue"
fi
done
fi
2 changes: 2 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ configuration:
properties:
api-token-env-name:
type: string
api-url:
type: string
branches:
type: string
debug:
15 changes: 15 additions & 0 deletions tests/pre-exit-success.bats
Original file line number Diff line number Diff line change
@@ -152,3 +152,18 @@ COMMON_CURL_OPTIONS='--form \* --form \* --form \* --form \* --form \* --form \*
assert_success
assert_output --partial "curl success"
}

@test "API can change" {
export BUILDKITE_PLUGIN_TEST_COLLECTOR_API_URL='https://test-api.example.com/v2'

stub curl "-X POST --silent --show-error --max-time 30 --form format=junit ${COMMON_CURL_OPTIONS} \* -H \* : echo \"curl success against \${29}\""

run "$PWD/hooks/pre-exit"

assert_success
assert_output --partial "Uploading './tests/fixtures/junit-1.xml'..."
assert_output --partial "curl success"
assert_output --partial "against https://test-api.example.com/v2"

unstub curl
}