From a04f7b5f62c694a18f56ad54bde0d6ad719816bc Mon Sep 17 00:00:00 2001 From: fraxy-v <65565042+fraxy-v@users.noreply.github.com> Date: Sat, 31 Aug 2024 20:18:40 +0300 Subject: [PATCH] Update c-cpp.yml --- .github/workflows/c-cpp.yml | 61 +++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index ff9d101..3cb2adb 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -97,17 +97,52 @@ jobs: uses: actions/github-script@v7 with: script: | - var fs = require('fs'); - var parseString = require('xml2js').parseString; - - function requestReport(callback) { - fs.readFile('coverage.xml', 'utf8', function(err, data) { - if (err) return callback(err); - parseString(data, callback); - }); - } - - requestReport(function(err, result) { - if (err) return console.error(err); - console.log(JSON.stringify(result)); + const fs = require('fs'); + const parseString = require('xml2js').parseString; + const result = await new Promise((resolve, reject) => parseString(fs.readFileSync('coverage.xml', 'utf8'), (err, result) => { + if (err) reject(err); + else resolve(result); }); + console.log('${{ github.base_ref || github.ref_name }}'); + + # "packages": [ + # { + # "package": [ + # { + # "$": { + # "name": "src", + # "line-rate": "0.5", + # "branch-rate": "0.5", + # "complexity": "0.0" + # }, + # "classes": [ + # { + # "class": [ + # { + # "$": { + # "name": "main_cpp", + # "filename": "src/main.cpp", + # "line-rate": "0.0", + # "branch-rate": "1.0", + # "complexity": "0.0" + # }, + # "methods": [ + # "" + # ], + # "lines": [ + # { + # "line": [ + # { + # "$": { + # "number": "6", + # "hits": "0", + # "branch": "false" + # } + # }, + # { + # "$": { + # "number": "7", + # "hits": "0", + # "branch": "false" + # } + # },