Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔀 merge: main to staging branch #60

Merged
merged 9 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Change Log

All notable changes the Codefair App will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## v1.0.0 - 2024-08-26

### Identifier
https://doi.org/10.5281/zenodo.13376617

### Added
- First release with license file and metadata files generating features
37 changes: 37 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
title: Codefair
authors:
- given-names: Dorian
family-names: Portillo
email: dportillo@calmi2.org
affiliation: FAIR Data Innovations Hub, California Medical Innovations Institute
- given-names: Sanjay
family-names: Soundarajan
email: ssoundarajan@calmi2.org
affiliation: FAIR Data Innovations Hub, California Medical Innovations Institute
- given-names: Bhavesh
family-names: Patel
email: bpatel@calmi2.org
affiliation: FAIR Data Innovations Hub, California Medical Innovations Institute
cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
identifiers:
- type: doi
value: https://doi.org/10.5281/zenodo.13376617
abstract: "Codefair is a free and open source GitHub app that acts as your
personal assistant when it comes to making your research software reusable and
especially complying with the Findable, Accessible, Interoperable, Reusable
(FAIR) Principles for Research Software (FAIR4RS Principles). Whether you are
developing artificial intelligence (AI)/machine learning (ML) models with
Python, data visualization tools with Jupyter notebook, or data analysis code
with R, Codefair is here to assist you. "
keywords:
- best-practices
- fair
- research
- reusable
- software
license: MIT
repository-code: https://github.com/fairdataihub/codefair-app
version: 1.0.0
date-released: 2024-08-26
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ Your coding assistant to make research software reusable without breaking a swea
<a href="https://github.com/fairdataihub/codefair-app/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/fairdataihub/codefair-app.svg?style=flat-square" alt="license" />
</a>
<a href="https://fairdataihub.org/fairshare">
<img src="https://raw.githubusercontent.com/fairdataihub/FAIRshare/main/badge.svg" alt="Curated with FAIRshare" />
<a href="https://doi.org/10.5281/zenodo.13376617">
<img src="https://zenodo.org/badge/DOI/10.5281/zenodo.13376617.svg" alt="Zenodo DOI" />
</a>
<a href="https://archive.softwareheritage.org/browse/origin/https://github.com/fairdataihub/codefair-app/">
<img src="https://archive.softwareheritage.org/badge/origin/https://github.com/fairdataihub/codefair-app/" alt="Software Heritage archive" />
</a>

</p>

</div>
Expand Down Expand Up @@ -126,15 +130,8 @@ This work is licensed under
If you are using this package or reusing the source code from this repository for any purpose, please cite:

```text
Coming soon...
Portillo, D., Soundarajan, S., & Patel, B., (2024). Codefair App. Zenodo. 10.5281/zenodo.13376617
```

## Acknowledgements

```text
Coming soon...
```

<br />

---
Expand Down
33 changes: 21 additions & 12 deletions bot/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { MongoClient } from "mongodb";
import * as express from "express";
import { renderIssues, createIssue } from "./utils/renderer/index.js";
import { checkEnvVariable, isRepoEmpty, verifyRepoName } from "./utils/tools/index.js";
import {
checkEnvVariable,
isRepoEmpty,
verifyRepoName,
} from "./utils/tools/index.js";

checkEnvVariable("MONGODB_URI");
checkEnvVariable("MONGODB_DB_NAME");
Expand Down Expand Up @@ -93,7 +97,13 @@ export default async (app, { getRouter }) => {
verifyRepoName(analytics.repo, repoName, owner, analyticsCollection);
}

const issueBody = await renderIssues(context, owner, repository, db, emptyRepo);
const issueBody = await renderIssues(
context,
owner,
repository,
db,
emptyRepo,
);

// Create an issue with the compliance issues
await createIssue(context, owner, repoName, issueTitle, issueBody);
Expand Down Expand Up @@ -154,7 +164,13 @@ export default async (app, { getRouter }) => {
verifyRepoName(analytics.repo, repoName, owner, analyticsCollection);
}

const issueBody = await renderIssues(context, owner, repository, db, emptyRepo);
const issueBody = await renderIssues(
context,
owner,
repository,
db,
emptyRepo,
);

// Create an issue with the compliance issues
// console.log("CREATING ISSUE");
Expand Down Expand Up @@ -227,13 +243,7 @@ export default async (app, { getRouter }) => {
console.log("Empty Repo: ", emptyRepo);

if (!installation) {
await installationCollection.insertOne({
installationId: context.payload.installation.id,
owner,
repo: repoName,
repositoryId: repoId,
timestamp: Date.now(),
})
return;
} else {
await verifyRepoName(
installation.repo,
Expand All @@ -243,7 +253,6 @@ export default async (app, { getRouter }) => {
);
}


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

Expand Down Expand Up @@ -336,7 +345,7 @@ export default async (app, { getRouter }) => {
repo: repoName,
repositoryId: repoId,
timestamp: Date.now(),
})
});
} else {
await verifyRepoName(
installation.repo,
Expand Down
19 changes: 11 additions & 8 deletions bot/utils/renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function applyMetadataTemplate(
url = `${CODEFAIR_DOMAIN}/add/code-metadata/${existingMetadata.identifier}`;
}
const metadataBadge = `[![Metadata](https://img.shields.io/badge/Add_Metadata-dc2626.svg)](${url})`;
baseTemplate += `\n\n## Metadata ❌\n\nTo make your software FAIR, a CITATION.cff and codemetada.json are expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org/docs/guidelines). These files are not found in the repository. If you would like Codefair to add these files, click the "Add metadata" button below to go to our interface for providing metadata and generating these files.\n\n${metadataBadge}`;
baseTemplate += `\n\n## Metadata ❌\n\nTo make your software FAIR, a CITATION.cff and codemeta.json are expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org/docs/guidelines). These files are not found in the repository. If you would like Codefair to add these files, click the "Add metadata" button below to go to our interface for providing metadata and generating these files.\n\n${metadataBadge}`;
}

if (subjects.codemeta && subjects.citation && subjects.license) {
Expand Down Expand Up @@ -125,7 +125,7 @@ export async function applyMetadataTemplate(
if (!subjects.license) {
// License was not found
const metadataBadge = `![Metadata](https://img.shields.io/badge/Metadata_Not_Checked-fbbf24)`;
baseTemplate += `\n\n## Metadata\n\nTo make your software FAIR a CITATION.cff and codemetada.json metadata files are expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org/docs/guidelines). Codefair will check for these files after a license file is detected.\n\n${metadataBadge}`;
baseTemplate += `\n\n## Metadata\n\nTo make your software FAIR a CITATION.cff and codemeta.json metadata files are expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org/docs/guidelines). Codefair will check for these files after a license file is detected.\n\n${metadataBadge}`;
}

return baseTemplate;
Expand Down Expand Up @@ -155,7 +155,7 @@ export async function applyCodemetaTemplate(

let url = `${CODEFAIR_DOMAIN}/add/codemeta/${identifier}`;

const codemetaCollection = db.collection("codemetaRequests");
const codemetaCollection = db.collection("codeMetadata");
// console.log(repository);
const existingCodemeta = await codemetaCollection.findOne({
repositoryId: repository.id,
Expand Down Expand Up @@ -183,7 +183,7 @@ export async function applyCodemetaTemplate(
}

const codemetaBadge = `[![Citation](https://img.shields.io/badge/Add_Codemeta-dc2626.svg)](${url})`;
baseTemplate += `\n\n## codemeta.json\n\nA codemeta.json file was not found in the repository. To make your software reusable a codemetada.json is expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org).\n\n${codemetaBadge}`;
baseTemplate += `\n\n## codemeta.json\n\nA codemeta.json file was not found in the repository. To make your software reusable a codemeta.json is expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org).\n\n${codemetaBadge}`;
} else if (subjects.codemeta && subjects.license) {
// License was found and codemetata.json also exists
// Then add codemeta section mentioning it will be checked after license is added
Expand Down Expand Up @@ -214,7 +214,7 @@ export async function applyCodemetaTemplate(
} else {
// codemeta and license does not exist
const codemetaBadge = `![CodeMeta](https://img.shields.io/badge/Codemeta_Not_Checked-fbbf24)`;
baseTemplate += `\n\n## codemeta.json\n\nA codemeta.json file will be checked after a license file is added. To make your software reusable a codemetada.json is expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org).\n\n${codemetaBadge}`;
baseTemplate += `\n\n## codemeta.json\n\nA codemeta.json file will be checked after a license file is added. To make your software reusable a codemeta.json is expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org).\n\n${codemetaBadge}`;
}

return baseTemplate;
Expand Down Expand Up @@ -422,7 +422,7 @@ export async function renderIssues(
) {
if (emptyRepo) {
console.log("emtpy repo and returning base");
return `# Check the FAIRness of your software\n\nTThis issue is your repository's dashboard for all things FAIR. Keep it open as making and keeping software FAIR is a continuous process that evolves along with the software. You can read the [documentation](https://docs.codefair.io/docs/dashboard.html) to learn more.\n\n> [!WARNING]\n> Currently your repository is empty and will not be checked until content is detected within your repository.\n\n## LICENSE\n\nTo make your software reusable a license file is expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org). Codefair will check for a license file after you add content to your repository.\n\n![License](https://img.shields.io/badge/License_Not_Checked-fbbf24)\n\n## Metadata\n\nTo make your software FAIR a CITATION.cff and codemetada.json metadata files are expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org/docs/guidelines). Codefair will check for these files after a license file is detected.\n\n![Metadata](https://img.shields.io/badge/Metadata_Not_Checked-fbbf24)`;
return `# Check the FAIRness of your software\n\nTThis issue is your repository's dashboard for all things FAIR. Keep it open as making and keeping software FAIR is a continuous process that evolves along with the software. You can read the [documentation](https://docs.codefair.io/docs/dashboard.html) to learn more.\n\n> [!WARNING]\n> Currently your repository is empty and will not be checked until content is detected within your repository.\n\n## LICENSE\n\nTo make your software reusable a license file is expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org). Codefair will check for a license file after you add content to your repository.\n\n![License](https://img.shields.io/badge/License_Not_Checked-fbbf24)\n\n## Metadata\n\nTo make your software FAIR a CITATION.cff and codemeta.json metadata files are expected at the root level of your repository, as recommended in the [FAIR-BioRS Guidelines](https://fair-biors.org/docs/guidelines). Codefair will check for these files after a license file is detected.\n\n![Metadata](https://img.shields.io/badge/Metadata_Not_Checked-fbbf24)`;
}

let license = await checkForLicense(context, owner, repository.name);
Expand Down Expand Up @@ -514,8 +514,11 @@ export async function createIssue(context, owner, repo, title, body) {
let noIssue = false;
let issueNumber;
for (let i = 0; i < issue.data.length; i++) {
console.log(issue.data[i].title);
if (issue.data[i].title === title) {
if (issue.data[i]?.pull_request) {
continue;
}

if (issue.data[i].title === title && issue.data[i].state === "open") {
noIssue = true;
issueNumber = issue.data[i].number;
break;
Expand Down
72 changes: 72 additions & 0 deletions codemeta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "Codefair",
"@context": "https://w3id.org/codemeta/3.0",
"applicationCategory": "Content management software",
"author": [
{
"affiliation": {
"name": "FAIR Data Innovations Hub, California Medical Innovations Institute",
"type": "Organization"
},
"email": "dportillo@calmi2.org",
"familyName": "Portillo",
"id": "_:author_1",
"givenName": "Dorian",
"type": "Person"
},
{
"affiliation": {
"name": "FAIR Data Innovations Hub, California Medical Innovations Institute",
"type": "Organization"
},
"email": "ssoundarajan@calmi2.org",
"familyName": "Soundarajan",
"id": "_:author_2",
"givenName": "Sanjay",
"type": "Person"
},
{
"affiliation": {
"name": "FAIR Data Innovations Hub, California Medical Innovations Institute",
"type": "Organization"
},
"email": "bpatel@calmi2.org",
"familyName": "Patel",
"id": "_:author_3",
"givenName": "Bhavesh",
"type": "Person"
}
],
"codeRepository": "https://github.com/fairdataihub/codefair-app",
"dateCreated": "2024-03-27",
"dateModified": "2024-08-26",
"datePublished": "2024-08-26",
"description": "Codefair is a free and open source GitHub app that acts as your personal assistant when it comes to making your research software reusable and especially complying with the Findable, Accessible, Interoperable, Reusable (FAIR) Principles for Research Software (FAIR4RS Principles). Whether you are developing artificial intelligence (AI)/machine learning (ML) models with Python, data visualization tools with Jupyter notebook, or data analysis code with R, Codefair is here to assist you. ",
"developmentStatus": "active",
"downloadUrl": "https://github.com/marketplace/codefair-app",
"identifier": "https://doi.org/10.5281/zenodo.13376617",
"issueTracker": "https://github.com/fairdataihub/codefair-app/issues",
"keywords": [
"best-practices",
"fair",
"research",
"reusable",
"software"
],
"license": "https://spdx.org/licenses/MIT",
"operatingSystem": [],
"programmingLanguage": [
"Vue",
"JavaScript",
"HTML",
"TypeScript",
"CSS",
"Dockerfile"
],
"relatedLink": [],
"runtimePlatform": [],
"schema:releaseNotes": "First release",
"softwareRequirements": [],
"version": "1.0.0",
"type": "SoftwareSourceCode"
}
2 changes: 1 addition & 1 deletion ui/server/api/codeMetadata/[identifier]/index.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default defineEventHandler(async (event) => {

const codeMeta = {
name: codeMetadataRecord.name,
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@context": "https://w3id.org/codemeta/3.0",
...(codeMetadataRecord.applicationCategory && {
applicationCategory: codeMetadataRecord.applicationCategory,
}),
Expand Down
Loading