Debug @relative-ci/agent CLI

Use DEBUG environment variable

To debug @relative-ci/agent, set DEBUG=relative-ci:agent environment variable when running relative-ci-agent:

DEBUG=relative-ci:agent npx relative-ci-agent
relative-ci:agent Config {
config: {
payloadFilepath: undefined,
includeCommitMessage: true,
webpack: { stats: './webpack-stats.json' }
},
filepath: '/home/runner/work/repo/relativeci.config.js'
}
relative-ci:agent env-ci params {
branch: 'master',
commit: 'f4f52dd148c6fd7f39962fa52b08dc85cf77a679',
isCi: true,
prBranch: undefined,
service: 'github',
slug: 'acme/web-app'
}
relative-ci:agent RELATIVE_CI_SLUG not available, using env-ci
relative-ci:agent Job parameters {
key: '***',
endpoint: 'https://api.relative-ci.com/save',
agentVersion: '2.1.0',
branch: 'master',
commit: 'f4f52dd148c6fd7f39962fa52b08dc85cf77a679',
isCi: true,
prBranch: undefined,
service: 'github',
slug: 'acme/web-app',
commitMessage: 'feat: Add login validation'
}
relative-ci:agent Payload {
key: '***',
project: 'acme/web-app',
service: 'github',
job: {
commit: 'f4f52dd148c6fd7f39962fa52b08dc85cf77a679',
branch: 'master',
prNumber: undefined,
buildNumber: undefined,
buildUrl: undefined,
commitMessage: 'feat: Add login validation'
},
rawData: { webpack: { stats: [Object] } },
agentVersion: '2.1.0'
}
relative-ci:agent Payload size 298791
Send stats to RelativeCI branch=master commit=f4f52dd148c6fd7f39962fa52b08dc85cf77a679
relative-ci:agent Response {
reportUrl: 'https://app.relative-ci.com/projects/acme-web-app/jobs/20',
res: { job: { internalBuildNumber: 20 } },
info: { message: { txt: 'Bundle Size 12.42MB (+1.2%).' } }
}
Job #20 done.
Bundle Size 12.42MB (+1.2%).

Inspect payload

To inspect the agent entire payload, you can configure the CLU to write the data on disk. The payload output contains the data that the agent is sending to the RelativeCI ingestion service(build information, bundle stats).

relativeci.config.js
module.exports = {
includeCommitMessage: true,
payloadFilepath: './relative-ci-payload.json',
webpack: {
stats: './dist/webpack-stats.json'
}
};

Use bundle-stats

When using a custom webpack stats configuration, it is possible that the output of the JSON file is not in the exact format that @relative-ci/agent is expecting. In that case, the agent will return a validation error. To test and fix your configuration locally, you can use bundle-stats.

bundle-stats is the standalone open-source utility that relative-ci.com is using under the hood to validate, filter, and process webpack stats.

npx bundle-stats ./webpack-stats.json