CodeScene Coverage CLI tool¶
The CodeScene Coverage CLI tool is a command-line tool which performs the upload of code coverage data to your code scene instance.
Installation¶
Linux, macOS and Windows (if WSL)¶
The install script will download the binary, move it to ~/.local/bin
and make it executable. If ~/.local/bin
is not in the user’s PATH
, it will be added.
It works if your shell is one of: bash, zsh or fish
curl https://downloads.codescene.io/enterprise/cli/install-cs-coverage-tool.sh | sh
Run this command in your terminal, no matter in which folder you are
Windows (powershell)¶
The powershell script downloads the windows binary, moves it to $env:USERPROFILE\AppData\Local\Programs\CodeScene
and makes it executable.
Invoke-WebRequest -Uri 'https://downloads.codescene.io/enterprise/cli/install-cs-coverage-tool.ps1' -OutFile install-cs-coverage-tool.ps1
.\install-cs-coverage-tool.ps1
Run this command in a powershell terminal, no matter in which folder you are, on some instalattion might require administrator privileges
Note, on non-server editions of Windows, the script execution policy is set to Restricted by default, and script execution is disabled. It can be enabled with:
Set-ExecutionPolicy RemoteSigned
This allows for the execution of trusted scripts downloaded from the internet, and all local scripts. In our case the script is considered a local file.
Manual installation¶
The binaries are also available for manual installation. Just download the binary for you platform and make it executable.
Platform specific notes¶
MacOS binaries are not signed, thus you have to manually move them out of quarantine using
xattr -dr com.apple.quarantine <binary>
.Windows users might have to set the script execution policy manually as mentioned above:
Set-ExecutionPolicy RemoteSigned
Client setup¶
The CLI Coverage tool requires a API Token which can be created at API Tokens .
Then set your environment variables as follows, the pat token chars might require escaping, see escaping for: linux shell , windows comand prompt and windows power shell
export CS_ACCESS_TOKEN=<your-api-token>
Or in windows(powershell):
$env:CS_ACCESS_TOKEN = '<your-api-token>'
Or in windows(comand prompt):
set "CS_ACCESS_TOKEN = <your-pat-token>"
Upload CodeCoverage using CLI¶
After the CLI was installed via script or manually as described above and your environment variables are set the CLI is ready to use
cd /home/test/my-project-with-code-coverage cs-coverage upload --format lcov --metric line-coverage /tmp/my-project-with-code-coverage.lcov
the CLI requires to be execute from the root folder of your project, in this example the project is located at /home/test/my-project-with-code-coverage
during upload your local project clone need to point to same commit/branch as the project being analysed by the Codescene instance
we assumed the code coverage data fro project my-project-with-code-coverage was generated and saved on /tmp/my-project-with-code-coverage.lcov
the CLI can be used to upload the follwoing formats: open-clover, lcov, dotcover, jacoco, cobertura, ncover, bullseye, open-cover
the CLI supports the following metrics: condition-decision-coverage, sequence-point-coverage, statement-coverage, line-coverage, method-coverage, decision-coverage, condition-coverage, branch-coverage