forked from https://github.com/jobready to add workdir property.
A BuildKite plugin
https://buildkite.com/docs/agent/plugins
to report coverage with the Code Climate test reporter
https://github.com/codeclimate/test-reporter
Plugin can handle single, parallel and multiple test suites.
Also see: https://docs.codeclimate.com/docs/configuring-test-coverage
This plugin will download build artifact(s) generated by a previous step, compile and report to Code Climate.
steps:
- label: ":codeclimate: Report coverage"
plugins:
- blstrco/codeclimate-test-reporter#v2.3:
artifact: "coverage/.resultset.json"
input_type: simplecov
prefix: /app
env:
CC_TEST_REPORTER_ID:
If you are running parallel builds you'll probably want to create uniquely
named artifacts. That can be done by renaming the .resultset.json
file
after your tests have run:
mv -v coverage/.resultset.json coverage/.resultset${BUILDKITE_PARALLEL_JOB}.json
If your repository has more than one test suite you'll need to format each artifact (coverage file) before the result can be summed and reported to codeclimate.
To do this you'll need to configure multiple steps persisting the formated codeclimate compatable configuration files as artifacts between steps.
This is best shown via an example;
- label: ":rails: Tests"
key: "rails-tests"
command: "rails db:test:prepare && rails test"
env:
RUBY_OPT: "-W:deprecated"
depends_on:
- "build-base"
plugins:
- docker-compose#v3.7.0:
run: base
config: .buildkite/docker-compose.yml
volumes:
- "./coverage:/app/coverage"
artifact_paths:
- "coverage/**/*"
- label: ":codeclimate: Format Rails Coverage"
key: "codeclimate-format-rails-report"
plugins:
- blstrco/codeclimate-test-reporter#v2.3:
artifact: "coverage/coverage.json"
input_type: simplecov
prefix: /app
report: false
file_prefix: "codeclimate.rails"
depends_on:
- "rails-tests"
artifact_paths:
- "coverage/codeclimate.**"
- label: ":react: Tests"
key: "react-tests"
command: "yarn test"
depends_on:
- "build-base"
plugins:
- docker-compose#v3.7.0:
run: base
config: .buildkite/docker-compose.yml
volumes:
- "./coverage:/app/coverage"
artifact_paths:
- "coverage/**/*"
- label: ":codeclimate: Format React Coverage"
key: "codeclimate-format-react-report"
plugins:
- blstrco/codeclimate-test-reporter#v2.3:
artifact: "coverage/lcov.info"
input_type: lcov
prefix: /app
report: false
file_prefix: "codeclimate.react"
depends_on:
- "react-tests"
artifact_paths:
- "coverage/codeclimate.**"
- label: ":codeclimate: Report coverage"
key: "codeclimate-coverage-report"
plugins:
- blstrco/codeclimate-test-reporter#v2.3:
artifact: "coverage/codeclimate**"
format: false
env:
CC_TEST_REPORTER_ID:
depends_on:
- "codeclimate-format-rails-report"
- "codeclimate-format-react-report"
Passed through as the [COVERAGE FILE]
argument to
Example: coverage/.resultset.json
Would be the artifact path uploaded by a previous step. Use a wildcard for multiple artifacts
Example: coverage/.resultset*.json
Passed through to the --input-type option of
Example: simplecov
Passed through to the --prefix option of
Example: /app
If the coverage was generated from a Docker container, prefix would be the Dockerfile WORKDIR
.
The preferred version of the test reporter to download. Defaults to latest
.
Example: 0.4.3
If you expect multiple partial coverage artifacts, set this value to enforce a check. If not set the plugin will proceed with any/all provided parts.
Example: 2
Set to true to enable cc-test-reporter --debug flag
Example: true
Controls if formatting of artifacts should be performed. Set to false when wanting to upload artifacts formatted in a previous step.
Example: false
Controls if coverage reporting to codeclimate should be performed. Set to false when needing to parse multiple test suites for later upload.
Example: false
Controls the name outputs files formatted by the codeclimate test reporter. Required to stop artifact names clashing when processing muiltple test suites.
The CC_TEST_REPORTER_ID
environment variable must be configured.
To run the Buildkite Plugin Linter, run
docker-compose run --rm lint --name blstrco/codeclimate-test-reporter
MIT