Skip to content

👷 upload code coverage report to datadog #3710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .codecov.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ unit:
script:
- yarn
- yarn test:unit
- ./scripts/test/codecov.sh
after_script:
- node ./scripts/test/export-test-result.js unit

Expand Down
15 changes: 1 addition & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,5 @@ RUN apt-get -y install procps
RUN set -o pipefail \
&& curl -sSfL https://git.io/getwoke | bash -s -- -b /usr/local/bin v0.17.1

# Codecov https://docs.codecov.com/docs/codecov-uploader
RUN apt-get -y install gnupg coreutils \
&& set -o pipefail && curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import \
&& CODECOV_UPLOADER_VERSION=v0.1.15 \
&& curl -Os https://uploader.codecov.io/${CODECOV_UPLOADER_VERSION}/linux/codecov \
&& curl -Os https://uploader.codecov.io/${CODECOV_UPLOADER_VERSION}/linux/codecov.SHA256SUM \
&& curl -Os https://uploader.codecov.io/${CODECOV_UPLOADER_VERSION}/linux/codecov.SHA256SUM.sig \
&& gpgv codecov.SHA256SUM.sig codecov.SHA256SUM \
&& shasum -a 256 -c codecov.SHA256SUM \
&& chmod +x codecov \
&& mv codecov /usr/local/bin \
&& rm codecov.*

# Install authanywhere for pull request commenter token
RUN if [ $(uname -m) = x86_64 ]; then AAA="amd64"; else AAA="arm64"; fi; curl -OL "binaries.ddbuild.io/dd-source/authanywhere/LATEST/authanywhere-linux-${AAA}" && mv "authanywhere-linux-${AAA}" /bin/authanywhere && chmod +x /bin/authanywhere
RUN if [ $(uname -m) = x86_64 ]; then AAA="amd64"; else AAA="arm64"; fi; curl -OL "binaries.ddbuild.io/dd-source/authanywhere/LATEST/authanywhere-linux-${AAA}" && mv "authanywhere-linux-${AAA}" /bin/authanywhere && chmod +x /bin/authanywhere
9 changes: 0 additions & 9 deletions scripts/test/codecov.sh

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/test/export-test-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { getOrg2ApiKey } = require('../lib/secrets')

const testType = process.argv[2]
const resultFolder = `test-report/${testType}/`
const coverageFolder = `coverage/${testType}/`

runMain(() => {
command`datadog-ci junit upload --service browser-sdk --env ci --tags test.type:${testType} ${resultFolder}`
Expand All @@ -20,6 +21,12 @@ runMain(() => {
})
.withLogs()
.run()
command`datadog-ci coverage upload --tags service:browser-sdk --tags env:ci --tags test.type:${testType} ${coverageFolder}`
.withEnvironment({
DATADOG_API_KEY: getOrg2ApiKey(),
})
.withLogs()
.run()

printLog(`Export ${testType} tests done.`)
})
7 changes: 7 additions & 0 deletions test/envUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ function getTestReportDirectory() {
}
}

function getCoverageReportDirectory() {
if (process.env.CI_JOB_NAME) {
return `coverage/${process.env.CI_JOB_NAME}`
}
}

module.exports = {
getRunId,
getBuildInfos,
getIp,
getTestReportDirectory,
getCoverageReportDirectory,
}
12 changes: 10 additions & 2 deletions test/unit/karma.local.conf.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
const path = require('path')
const { getCoverageReportDirectory } = require('../envUtils')
const karmaBaseConf = require('./karma.base.conf')

const coverageReports = ['text-summary']

const coverageReportDirectory = getCoverageReportDirectory()
if (coverageReportDirectory) {
coverageReports.push('clover')
}

module.exports = function (config) {
config.set({
...karmaBaseConf,
reporters: ['coverage-istanbul', ...karmaBaseConf.reporters],
browsers: ['ChromeHeadlessNoSandbox'],
coverageIstanbulReporter: {
reports: ['html', 'text-summary', 'json'],
dir: path.join(__dirname, '../../coverage'),
reports: coverageReports,
dir: coverageReportDirectory,
},
customLaunchers: {
ChromeHeadlessNoSandbox: {
Expand Down