Skip to content

Commit

Permalink
execute echo to push variable in output of github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcellino-Palerme committed Sep 27, 2024
1 parent 3758359 commit c5e118d
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions .github/workflows/extractResultsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
// This file extracts the results of the tests from the file results.json

import fs from 'fs';
import path from 'path';
// import core from '@actions/core';
// import path from 'path';
import {exec} from 'child_process';

// Path to the file containing the results of the tests
const filePath = './test/results/results.json';

Expand All @@ -26,21 +27,13 @@ fs.readFile(filePath, 'utf-8', (err, data) => {
const todoTests = results.numTodoTests;
const successTests = results.success;

fs.writeFileSync(path.join(process.env.GITHUB_OUTPUT),
`\n totalTests=${totalTests}
\n passedTests=${passedTests}
\n failedTests=${failedTests}
\n pendingTests=${pendingTests}
\n todoTests=${todoTests}
\n successTests=${successTests}`);

// Define the outputs for GitHub Actions
// core.setOutput('totalTests', totalTests);
// core.setOutput('passedTests', passedTests);
// core.setOutput('failedTests', failedTests);
// core.setOutput('pendingTests', pendingTests);
// core.setOutput('todoTests', todoTests);
// core.setOutput('successTests', successTests);
// Print the outputs for GitHub Actions
exec(`echo "{totalTests}=${totalTests}" >> $GITHUB_OUT`);
exec(`echo "{passedTests}=${passedTests}" >> $GITHUB_OUT`);
exec(`echo "{failedTests}=${failedTests}" >> $GITHUB_OUT`);
exec(`echo "{pendingTests}=${pendingTests}" >> $GITHUB_OUT`);
exec(`echo "{todoTests}=${todoTests}" >> $GITHUB_OUT`);
exec(`echo "{successTests}=${successTests}" >> $GITHUB_OUT`);

} catch (parseError) {
console.error('Analyse of json failed', parseError);
Expand Down

0 comments on commit c5e118d

Please sign in to comment.