Skip to content

Commit fe3e569

Browse files
committed
fix: clean JSON output for cost command in CI
- Suppress Logger messages when format is JSON to avoid polluting output - Use tail to skip dotenv message and DOTENV_QUIET env var in CI - This resolves jq parsing errors in GitHub Actions workflow - JSON output is now clean and parseable by automation tools
1 parent d04f4fb commit fe3e569

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.github/workflows/evalops-ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ jobs:
3636
3737
- name: Calculate Cost Estimate
3838
id: cost
39+
env:
40+
DOTENV_QUIET: true
3941
run: |
40-
COST=$(evalops cost --format json | jq -r '.totalCost')
42+
COST=$(evalops cost --format json | tail -n +2 | jq -r '.totalCost')
4143
echo "total-cost=$COST" >> $GITHUB_OUTPUT
4244
echo "### 💰 Cost Estimate: \$${COST}" >> $GITHUB_STEP_SUMMARY
4345

src/commands/cost.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ export class CostCommand {
8888
throw new Error('Configuration file not found');
8989
}
9090

91-
Logger.info('💰 Calculating cost estimate...');
91+
if (options.format !== 'json') {
92+
Logger.info('💰 Calculating cost estimate...');
93+
}
9294

9395
// Load and parse configuration
9496
let config: EvaluationConfig;
9597
try {
9698
config = YamlParser.parseFile(configPath);
97-
if (options.verbose) {
99+
if (options.verbose && options.format !== 'json') {
98100
Logger.success('✓ Configuration loaded');
99101
}
100102
} catch (error) {
@@ -106,7 +108,7 @@ export class CostCommand {
106108
try {
107109
const basePath = path.dirname(configPath);
108110
config = YamlParser.resolveFileReferences(config, basePath);
109-
if (options.verbose) {
111+
if (options.verbose && options.format !== 'json') {
110112
Logger.success('✓ File references resolved');
111113
}
112114
} catch (error) {
@@ -119,7 +121,7 @@ export class CostCommand {
119121
if (totalTests === 0) {
120122
// Provide a reasonable default for cost estimation
121123
totalTests = 1;
122-
if (options.verbose) {
124+
if (options.verbose && options.format !== 'json') {
123125
Logger.info('ℹ No tests defined in configuration, using default count for estimation');
124126
}
125127
}

0 commit comments

Comments
 (0)