Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f06bb2d
change build stats api
Aug 3, 2022
9ff8a45
fix projectToken value
Aug 3, 2022
46fed8a
fix
Aug 3, 2022
ad8294b
fix operations
Aug 3, 2022
fe2b544
fix
Aug 3, 2022
2049440
fix
Aug 3, 2022
755bfcb
add log
Aug 3, 2022
cb2cb2b
add %
Aug 3, 2022
218b0b3
fix text
Aug 3, 2022
0ee7453
add readme
Aug 3, 2022
ea985ba
fix text
Aug 3, 2022
7691544
fix text
Aug 3, 2022
5c04f03
add text
Aug 3, 2022
feeae52
add branch
Aug 3, 2022
ed44cbd
Merge branch 'master' into refactoring
SergeyPirogov Aug 3, 2022
e01b53a
add action wait for build to be completed
Aug 15, 2022
16cea3d
Merge branch 'refactoring' of github.com:reqover/reqover-action into …
Aug 15, 2022
11eec20
fix workflow
Aug 15, 2022
8508d7b
add logs
Aug 15, 2022
c26a144
fix
Aug 15, 2022
d638229
fix
Aug 15, 2022
2e2a2ff
fix buildName
Aug 15, 2022
3cfb19b
add log
Aug 15, 2022
debadb7
add log
Aug 15, 2022
4a52fe2
fix
Aug 15, 2022
e715d1d
fix
Aug 15, 2022
2f40b7f
fix
Aug 15, 2022
8e4c013
add wait for build
Aug 16, 2022
b0e1efb
Merge branch 'master' into refactoring
SergeyPirogov Aug 16, 2022
ccff36d
fix
Aug 16, 2022
6c3c38f
Merge branch 'refactoring' of github.com:reqover/reqover-action into …
Aug 16, 2022
737b7ed
refactor
Nov 26, 2022
8a7b0ac
refactor
Nov 26, 2022
496b94d
Merge branch 'master' into refactoring
SergeyPirogov Mar 24, 2023
a55ea97
fix
Mar 24, 2023
b1f73bf
fix
Mar 24, 2023
13acd57
fix
Mar 24, 2023
3b32c5c
add sleep
Mar 24, 2023
04d57b7
add diff
Mar 24, 2023
abae812
fix
Mar 24, 2023
64275e0
fix
Mar 24, 2023
0be0e72
fix
Mar 24, 2023
2845836
fix
Mar 24, 2023
d567d91
updated_at
Mar 24, 2023
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
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ on: [pull_request]
jobs:
hello_world_job:
runs-on: ubuntu-latest
name: Test Reqover action
name: Test Reqover action
steps:
- name: Checkout
uses: actions/checkout@v1
- uses: jakejarvis/wait-action@master
with:
time: "30s"
- name: Reqover action step
uses: ./
with:
Expand Down
68 changes: 40 additions & 28 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,76 @@
const core = require('@actions/core');
const github = require('@actions/github');
const fs = require('fs');
const core = require("@actions/core");
const github = require("@actions/github");
const fs = require("fs");

async function run() {
try {
const filePath = core.getInput('filePath');
const github_token = core.getInput('githubToken');
const pr_number = core.getInput('pr_number');
const filePath = core.getInput("filePath");
const github_token = core.getInput("githubToken");
const pr_number = core.getInput("pr_number");

const context = github.context;

const pull_number = parseInt(pr_number) || context.payload.pull_request?.number;

const pull_number =
parseInt(pr_number) || context.payload.pull_request?.number;
if (!pull_number) {
return;
}

if(!github_token){
core.setFailed('`Github TOKEN is not set');
if (!github_token) {
core.setFailed("`Github TOKEN is not set");
return;
}

const rawData = fs.readFileSync(filePath);
const coverage = JSON.parse(rawData);
// const rawData = fs.readFileSync(filePath);
// const coverage = JSON.parse(rawData);

// console.log(`Result:\n ${JSON.stringify(coverage, null, 2)}`);

console.log(`Result:\n ${JSON.stringify(coverage, null, 2)}`);

const octokit = new github.getOctokit(github_token);

await octokit.rest.issues.createComment({
...context.repo,
issue_number: pull_number,
body: getBody(coverage),
});
// await octokit.rest.issues.createComment({
// ...context.repo,
// issue_number: pull_number,
// body: getBody(coverage),
// });

const GITHUB_REPOSITORY = process.env.GITHUB_REPOSITORY;
const run_id = process.env.GITHUB_RUN_ID;

const repo = GITHUB_REPOSITORY.split("/")[1];
const owner = GITHUB_REPOSITORY.split("/")[0];

const runUsage = await octokit.rest.actions.getWorkflowRunUsage({
const runInfo = await octokit.rest.actions.getWorkflowRun({
owner,
repo,
run_id,
});

console.log(JSON.stringify(runUsage, null, 2))
console.log(JSON.stringify(runInfo, null, 2));

const run_started_at = runInfo.data.updated_at;

const date = new Date(run_started_at);

const now = new Date();
const diffInMilliseconds = now.getTime() - date.getTime();
const diffInSeconds = Math.floor(diffInMilliseconds / 1000);
const diffInMinutes = Math.floor(diffInSeconds / 60);
const diffInHours = Math.floor(diffInMinutes / 60);

console.log(
`${diffInHours % 24} hours, ${diffInMinutes % 60} minutes, and ${diffInSeconds % 60} seconds`
);

} catch (error) {
core.setFailed(error.message);
}
}

function getBody(coverage) {

let missingText = "";
for(const [key, value] of Object.entries(coverage.missing.items)) {
for(const item of value){
missingText += `- ${item.method} ${item.path}\n`
for (const [key, value] of Object.entries(coverage.missing.items)) {
for (const item of value) {
missingText += `- ${item.method} ${item.path}\n`;
}
}

Expand All @@ -71,7 +83,7 @@ function getBody(coverage) {

##### Missing:
${missingText}
`
`;
}

run()
run();