Bld extension for the Tests Badge service
A bld
extension for reporting test results through a
Tests Badge service.
The complete documentation of TestsBadgeOperation
can be found in its javadocs.
This is an example usage where you replace the test
command with the
TestsBadgeOperation
. Please note that the TestBadgeOperation
currently
only works with JUnit 5 tests.
private final TestsBadgeOperation testsBadgeOperation = new TestsBadgeOperation();
public void test()
throws Exception {
testsBadgeOperation.executeOnce(() -> testsBadgeOperation
.url(property("testsBadgeUrl"))
.apiKey(property("testsBadgeApiKey"))
.fromProject(this));
}
The testsBadgeUrl
and testsBadgeApiKey
properties can then be passed in
through bld
's hierarchical properties.
Typically, you would set this up through a CI workflow.
Here's how this could look for a bld.yml
GitHub worflow:
name: bld-ci
on: [push, pull_request, workflow_dispatch]
jobs:
build-project:
runs-on: ubuntu-latest
steps:
- name: Checkout source repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'17${{ matrix.java-version }}
- name: Run tests
run: >-
./bld download compile test
-DtestsBadgeUrl=https://rife2.com/tests-badge/update/group/artifact
-DtestsBadgeApiKey=${{ secrets.TESTS_BADGE_API_KEY }}
The TESTS_BADGE_API_KEY
secret can then be added to the settings of your
GitHub project without it being visible publicly.