Skip to content

Commit

Permalink
feat: ✨ full run through on action limit, display previous validation…
Browse files Browse the repository at this point in the history
…s on issue dashboard
  • Loading branch information
slugb0t committed Aug 7, 2024
1 parent 631d34a commit fa72532
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
32 changes: 31 additions & 1 deletion bot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export default async (app, { getRouter }) => {
}

const emptyRepo = await isRepoEmpty(context, owner, repository.name);
let fullCodefairRun = false;

const installationCollection = db.collection("installation");
const installation = await installationCollection.findOne({
Expand All @@ -232,15 +233,32 @@ export default async (app, { getRouter }) => {

return;
}

if (installation?.action === false && installation?.action_count > 4) {
installationCollection.updateOne(
{ repositoryId: repository.id },
{
$set: {
action: false,
action_count: installation.action_count + 1,
},
},
);

fullCodefairRun = true;
}
}

// Grab the commits being pushed
const { commits } = context.payload;

let cwl = [];
let license = await checkForLicense(context, owner, repository.name);
let citation = await checkForCitation(context, owner, repository.name);
let codemeta = await checkForCodeMeta(context, owner, repository.name);
const cwl = [];
if (fullCodefairRun) {
cwl = await getCWLFiles(context, owner, repository.name);
}

// Check if any of the commits added a LICENSE, CITATION, or codemeta file
const gatheredCWLFiles = [];
Expand Down Expand Up @@ -419,6 +437,18 @@ export default async (app, { getRouter }) => {

return;
}

if (installation?.action_count > 4) {
installationCollection.updateOne(
{ repositoryId: context.payload.repository.id },
{
$set: {
action: false,
action_count: installation.action_count + 1,
},
},
);
}
}
}

Expand Down
24 changes: 24 additions & 0 deletions bot/utils/renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ export async function applyCWLTemplate(
{ repositoryId: repository.id },
{ $set: { updated_at: Date.now() } },
);

// TODO: Create a table of the cwl files that were validated
const tableContent = "";
for (const file of existingCWL.files) {
tableContent += `| ${file.path} | ${file.validation_status === "valid" ? "❗" : "❌"} |\n`;
}

const cwlBadge = `[![CWL](https://img.shields.io/badge/View_CWL_Report-0ea5e9.svg)](${url})`;

baseTemplate += `\n\n## CWL Validations\n\nNo new CWL files were found in the repository but ***${existingCWL.files.length}/${existingCWL.files.length}*** that were validated already are considered valid by the [cwltool validator](https://cwltool.readthedocs.io/en/latest/).\n\n<details>\n<summary>Summary of the validation report</summary>\n\n| File | Status |\n| :---- | :----: |\n${tableContent}</details>\n\nTo view the full report of each CWL file, click the "View CWL Report" button below.\n\n${cwlBadge}`;
}

console.log(subjects);
Expand Down Expand Up @@ -360,6 +370,20 @@ export async function applyCWLTemplate(
},
);
url = `${CODEFAIR_DOMAIN}/add/cwl/${existingCWL.identifier}`;

// TODO: Create a table of the cwl files that were validated
for (const file of existingCWL.files) {
tableContent += `| ${file.path} | ${file.validation_status === "valid" ? "❗" : "❌"} |\n`;
subjects.cwl.files.push(file);

if (file.validation_status === "invalid") {
failedCount += 1;
}

if (file.validation_status === "invalid" && validOverall) {
validOverall = false;
}
}
}

const cwlBadge = `[![CWL](https://img.shields.io/badge/View_CWL_Report-0ea5e9.svg)](${url})`;
Expand Down

0 comments on commit fa72532

Please sign in to comment.