The official Elixir adapter for Buildkite Test Analytics which uses an ExUnit formatter to connect information about your tests.
⚒ Supported test frameworks: ExUnit.
📦 Supported CI systems: Buildkite, GitHub Actions, CircleCI, and others via the BUILDKITE_ANALYTICS_*
environment variables.
-
Create a test suite, and copy the API token that it gives you.
-
Add
buildkite_test_collector
to your list of dependencies inmix.exs
:
def deps do
[
{:buildkite_test_collector, "~> 0.3.0", only: [:test]}
]
end
- Set up your API token
In your config/test.exs
(or other environment configuration as appropriate) add the analytics API token. We suggest that you retrieve the token from the environment, and configure your CI environment accordingly (eg via secrets).
import Config
config :buildkite_test_collector,
api_key: System.get_env("BUILDKITE_ANALYTICS_TOKEN")
- Add
BuildkiteTestCollectorFormatter
to your ExUnit configuration intest/test_helper.exs
:
ExUnit.configure formatters: [BuildkiteTestCollector.Formatter, ExUnit.CLIFormatter]
ExUnit.start
- Run your tests
Run your tests like normal. Note that we attempt to detect the presence of several common CI environments, however if this fails you can set the CI
environment variable to any value and it will work.
$ mix test
...
Finished in 0.01 seconds (0.003s on load, 0.004s on tests)
3 tests, 0 failures
Randomized with seed 12345
- Verify that it works
If all is well, you should see the test run in the test analytics section of the Buildkite dashboard.
Buildkite Test Analytics has support for tracing potentially slow operations within your tests (SQL queries, HTTP requests, etc). Because ExUnit can run multiple tests simultaneously, it is difficult to achieve this without requiring code changes - we cannot simply use telemetry events because we cannot easily attribute the events to specific tests across process boundaries. Instead we have provided a simple API to manually instrument operations within your tests.
See the GitHub 'enhancement' issues for planned features. Pull requests are always welcome, and we’ll give you feedback and guidance if you choose to contribute 💚
After cloning the repository, install the dependencies:
mix deps.get
And run the tests:
mix test
Useful resources for developing collectors include the Buildkite Test Analytics docs and the RSpec and Minitest collectors.
Bug reports and pull requests are welcome on GitHub at https://github.com/buildkite/test_collector_elixir
Please use Conventional Commits so that the changelog and version can be automatically tracked via the git_ops package.
Important: some of this process is already automated by Github Actions. It should be completely automated shortly.
# Generate the new version and changelog
mix git_ops.release
# Push the tags
git push && git push --tags
# Publish the Hex package
mix hex.publish
# Create a new GitHub release
open "https://github.com/buildkite/test_collector_elixir/releases"
The package is available as open source under the terms of the MIT License.
Thanks to the folks at Alembic for building and maintaining this package.