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

fix: 🐛 Codefair v2.0.1 #65

Merged
merged 78 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
e32e766
feat: :sparkles: improvement to bot workflow
slugb0t Jul 25, 2024
922dbff
fix: :bug: correct codemeta url
slugb0t Jul 25, 2024
4a53a59
fix: :bug: correct collection call with correct name
slugb0t Jul 25, 2024
cf0bfca
style: :art: prettier refactor
slugb0t Jul 25, 2024
40b9fd3
refactor: :recycle: update on call for installation and analytics col…
slugb0t Jul 25, 2024
55070f3
✨ feat: add front end support for cwl validation (#41)
megasanjay Aug 1, 2024
ba378cc
feat: ✨ CWL validations across repo, single instance db, bot restruct…
slugb0t Aug 2, 2024
ed91ea5
refactor: :recycle: exit push event in the case of no entry in instal…
slugb0t Aug 2, 2024
098c94a
feat: ✨ bot event listeners concised + extra cwl validation checks (#43)
slugb0t Aug 6, 2024
89416f6
🐛 fix: rework dashboard page for clarity (#44)
megasanjay Aug 6, 2024
c69aecb
feat: ✨ action queue limit + cwl template updates (#45)
slugb0t Aug 7, 2024
2f06a2a
fix: :bug: add await to db call
slugb0t Aug 7, 2024
7293f75
fix: :bug: overwriting previous cwl files in db patched
slugb0t Aug 7, 2024
631d34a
feat: :sparkles: set action key to false upon reaching action count l…
slugb0t Aug 7, 2024
fa72532
feat: :sparkles: full run through on action limit, display previous v…
slugb0t Aug 7, 2024
f9b3791
dev: :memo: better comments
slugb0t Aug 7, 2024
f4583bd
feat: :sparkles: better comments and always show total validations on…
slugb0t Aug 7, 2024
38e00ca
✨ feat: Add support for DB migrations (#46)
megasanjay Aug 7, 2024
8a59388
✨ feat: add a simple faq for errors (#47)
megasanjay Aug 8, 2024
d44ae7b
fix: 🐛 bot patches for cwl and action queue features (#48)
slugb0t Aug 8, 2024
39d4f8b
refactor: :recycle: const declaration on validateCWLFile function call
slugb0t Aug 8, 2024
ea5f153
feat: :sparkles: consola for logging (#49)
slugb0t Aug 8, 2024
1794a53
🐛 fix: check github org permissions (#50)
megasanjay Aug 8, 2024
3e61a06
🧑‍💻 chore: remove old dashboard
megasanjay Aug 9, 2024
7f2b6c2
refactors: ♻️ action limit update (#51)
slugb0t Aug 9, 2024
1225839
Merge branch 'staging' of https://github.com/fairdataihub/codefair-ap…
megasanjay Aug 9, 2024
b2ec880
📈 feat: add metrics for ui side (#52)
megasanjay Aug 9, 2024
5b9807b
feat: :sparkles: analytics validatedFileCount (#53)
slugb0t Aug 12, 2024
c577af6
fix: :bug: if file is deleted, check for overall status before final …
slugb0t Aug 12, 2024
941bec8
chore: :hammer: todo removed
slugb0t Aug 12, 2024
baddb93
refactor: :recycle: update issue dashboard template for CWL section (…
slugb0t Aug 12, 2024
5d50f49
refactor: :refactor: additional cwl logs and action queue decreases
slugb0t Aug 12, 2024
6f6071e
chore: :hammer: removed unnecessary logs
slugb0t Aug 12, 2024
4534d4c
➖ chore: remove consola from ui
megasanjay Aug 13, 2024
6831c00
🔊 chore: log error
megasanjay Aug 13, 2024
353b1a4
🔥 Feat: removing old cwl UI
slugb0t Aug 13, 2024
3e2f344
fix: :bug: update cwl db when file is modified
slugb0t Aug 13, 2024
72afbca
fix: :bug: failedcount/cwlfilecount ratio for issue template
slugb0t Aug 13, 2024
8bf3f83
fix: 🐛 cwl bug patches (#55)
slugb0t Aug 14, 2024
ce0789e
refactor: :recycle: align contains_license key with other collections
slugb0t Aug 14, 2024
3630a7d
feat: ✨ validation status + trigger bot rerun full validation (#56)
slugb0t Aug 16, 2024
51a4fa8
feat: :sparkles: include validation check for when only one metadata …
slugb0t Aug 16, 2024
f94c47e
refactor: :memo: update readme run githb app locally section
slugb0t Aug 20, 2024
b3d3308
Update README.md
slugb0t Aug 20, 2024
fe2a5fc
refactor: :recycle: update /fairsoftware page text
slugb0t Aug 20, 2024
ef7847c
feat: :sparkles: Add button to direct to docs on codefair homepage
slugb0t Aug 20, 2024
9dc2d89
refactor: :recycle: /fairsoftware learn more about codefair directs t…
slugb0t Aug 20, 2024
fef258c
refactor: :recycle: remove mention of fair-biors guidelines from bot
slugb0t Aug 20, 2024
f6ae158
refactor: :recycle: remove mention of fair biors guidelines in UI
slugb0t Aug 20, 2024
5d41fba
✨ feat: bring ui dashboard to issue dashboard level (#57)
megasanjay Aug 24, 2024
6cd55db
🐛 fix: undefined vars
megasanjay Aug 24, 2024
3aa0a06
fix: :bug: get default branch name for commit info
slugb0t Aug 27, 2024
e5b2424
fix: :bug: patch iterating through existing cwl files for removal
slugb0t Aug 27, 2024
02b03ff
refactor: :recycle: Prettier refactors
slugb0t Aug 27, 2024
9b2d9eb
refactor: :recycle: display repos with no action limit in UI dashboard
slugb0t Aug 27, 2024
4d58422
refactor: :building_construction: update bot file structure (#59)
slugb0t Aug 27, 2024
3ec85bd
refactor: :art: standardize spacing of content for dashboard cards
slugb0t Aug 27, 2024
4a5bd2c
refactor: :recycle: update on styling of repo cards
slugb0t Aug 27, 2024
75fa2ec
🔀 merge: main to staging branch (#60)
slugb0t Aug 27, 2024
bb92783
fix: :bug: correct typo in README
slugb0t Aug 27, 2024
a33c789
feat: :bookmark: bump version number to v2.0.0
slugb0t Aug 27, 2024
a34ecd2
feat: :sparkles: activate dashboard
slugb0t Aug 27, 2024
a9d3883
refactor: :recycle: remove mention of the fair-biors guidelines in bot
slugb0t Aug 27, 2024
97df0a9
feat: :sparkles: if issue is reopened update the latest commits in db
slugb0t Aug 28, 2024
4fd4f61
feat: :sparkles: fetch commit details if bot yet has not done so
slugb0t Aug 28, 2024
738c098
revert: :rewind: remove fetching commits from UI
slugb0t Aug 28, 2024
0a9a7ad
Update CITATION.cff
bvhpatel Aug 29, 2024
b5a2567
Update codemeta.json
bvhpatel Aug 29, 2024
d957734
Update README.md
bvhpatel Aug 29, 2024
a8027b9
Update CHANGELOG.md
bvhpatel Aug 29, 2024
4ce4e8b
update: :memo: update CHANGELOG for v2
slugb0t Aug 29, 2024
4b6c306
Merge branch 'main' into staging
slugb0t Aug 29, 2024
4161959
refactor: :recycle: PR feedback resolved
slugb0t Aug 29, 2024
099bf89
refactor: :recycle: update validator endpoint
slugb0t Aug 29, 2024
ff0c312
feat: :sparkles: migration update (#62)
slugb0t Aug 29, 2024
1bb82fd
feat: :sparkles: Migrations update (#63)
slugb0t Aug 29, 2024
f858326
fix: 🐛 Codefair v2.0.1 (#64)
slugb0t Sep 3, 2024
dd38f92
Merge branch 'main' into staging
slugb0t Sep 3, 2024
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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ 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).


## v.2.0.1 - 2024-09-03

### Identifier

https://doi.org/10.5281/zenodo.13651177

### Added

- Added a migration script to update the database for users who may try to access the dashboard before the v2.0.0 bot has ran on all their repositories.
- Added badges to the CWL card on the dashboard to show the overall status of the CWL validations.

### Fixed

- Fixed a bug where the bot would updated the overall status of the CWL validation on the database.
- Link generator for Codefair repository settings was fixed to correctly generate the link for a user or repository.

### Removed

- Removed references to the action key in the database as it was not being used.


## v.2.0.0 - 2024-08-29

### Identifier
Expand Down
6 changes: 3 additions & 3 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ message: If you use this software, please cite it using the metadata from this f
type: software
identifiers:
- type: doi
value: https://doi.org/10.5281/zenodo.13544387
value: https://doi.org/10.5281/zenodo.13651177
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
Expand All @@ -33,5 +33,5 @@ keywords:
- software
license: MIT
repository-code: https://github.com/fairdataihub/codefair-app
version: 2.0.0
date-released: 2024-08-29
version: 2.0.1
date-released: 2024-09-03
2 changes: 1 addition & 1 deletion bot/cwl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export async function applyCWLTemplate(

// Check if the overall status is still valid
for (const file of newFiles) {
if (file.overall_status === "invalid") {
if (file.validation_status === "invalid") {
validOverall = false;
break;
}
Expand Down
115 changes: 115 additions & 0 deletions bot/dev-migrate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import fs from "fs";
import dotenv from "dotenv";
import { MongoClient } from "mongodb";
import { consola } from "consola";

if (process.env.NODE_ENV !== "production") {
dotenv.config({
path: ".env",
});
}

if (!process.env.MONGODB_URI) {
throw new Error("Please define the MONGODB_URI environment variable");
}

if (!process.env.MONGODB_DB_NAME) {
throw new Error("Please define the MONGODB_DB_NAME environment variable");
}

const uri = process.env.MONGODB_URI;
const dbName = process.env.MONGODB_DB_NAME;
const devDbName = `${dbName}-migrations-test`;

// Create a new MongoClient
const client = new MongoClient(uri);

await client.connect();

const database = client.db(dbName);

if (!database) {
throw new Error("Database not found");
}

const devDatabase = client.db(devDbName);

// FOR DEV ONLY
// Clone the original database
// Get the list of collections in the original database
consola.start("Cloning the original database...");

const collections = await database.listCollections().toArray();

for (const collection of collections) {
const collectionName = collection.name;

// Get the collection
const dbCollection = database.collection(collectionName);

// Get the documents in the collection
const documents = await dbCollection.find().toArray();

// Drop the collection in the new database if it exists
await devDatabase.dropCollection(collectionName).catch(() => {});

// Create a new collection in the new database
const newCollection = devDatabase.collection(collectionName);

// Insert the documents into the new collection
if (documents.length > 0) {
await newCollection.insertMany(documents);
}
}

consola.success("Database cloned!");

// Get the list of files in the migrations folder
const files = fs.readdirSync("./migrations");

// Order the files by name
files.sort();

const migrationsCollection = devDatabase.collection("migrations");

for (const file of files) {
// Get the file name without the extension
const migrationId = file.replace(".ts", "");

// Check if the migration has already been applied
const migration = await migrationsCollection.findOne({
migration_id: migrationId,
});

if (migration) {
consola.warn(`Migration ${migrationId} has already been applied`);
continue;
}

// Import the migration file
const { default: migrationFunction } = await import(
`./migrations/${migrationId}`
);

consola.start(`Applying migration ${migrationId}`);

try {
// Run the migration
await migrationFunction(uri, devDbName, migrationId);
} catch (error) {
consola.error(`Error applying migration ${migrationId}: ${error.message}`);
throw error;
}

consola.success(`Migration ${migrationId} has been applied!`);

// Insert the migration into the migrations collection
// await migrationsCollection.insertOne({
// migration_id: migrationId,
// created_at: new Date(),
// });
}

await client.close();

process.exit();
11 changes: 3 additions & 8 deletions bot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export default async (app, { getRouter }) => {
await verifyInstallationAnalytics(
context,
repository,
applyActionLimit,
actionCount,
latestCommitInfo,
);
Expand Down Expand Up @@ -259,7 +258,7 @@ export default async (app, { getRouter }) => {
installationCollection,
);

if (installation?.action && installation?.action_count > 0) {
if (installation?.action_count > 0) {
consola.warn(
"Action limit count down:",
installation.action_count,
Expand Down Expand Up @@ -288,7 +287,6 @@ export default async (app, { getRouter }) => {
{ repositoryId: repository.id },
{
$set: {
action: false,
action_count: 0,
latestCommitDate: latestCommitInfo.latestCommitDate,
latestCommitMessage: latestCommitInfo.latestCommitMessage,
Expand Down Expand Up @@ -452,7 +450,7 @@ export default async (app, { getRouter }) => {
const installation = await installationCollection.findOne({
repositoryId: repository.id,
});
if (installation?.action && installation?.action_count > 0) {
if (installation?.action_count > 0) {
installationCollection.updateOne(
{ repositoryId: repository.id },
{
Expand All @@ -470,7 +468,6 @@ export default async (app, { getRouter }) => {
{ repositoryId: repository.id },
{
$set: {
action: false,
action_count: 0,
},
},
Expand Down Expand Up @@ -543,7 +540,7 @@ export default async (app, { getRouter }) => {
installationCollection,
);

if (installation?.action && installation?.action_count > 0) {
if (installation?.action_count > 0) {
installationCollection.updateOne(
{ repositoryId: context.payload.repository.id },
{ $set: { action_count: installation.action_count - 1 } },
Expand All @@ -557,7 +554,6 @@ export default async (app, { getRouter }) => {
{ repositoryId: context.payload.repository.id },
{
$set: {
action: false,
action_count: 0,
},
},
Expand Down Expand Up @@ -749,7 +745,6 @@ export default async (app, { getRouter }) => {
await verifyInstallationAnalytics(
context,
repository,
false,
0,
latestCommitInfo,
);
Expand Down
57 changes: 12 additions & 45 deletions bot/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import fs from "fs";
import dotenv from "dotenv";
import { MongoClient } from "mongodb";
import fs from "fs";
import { consola } from "consola";
import { nanoid } from "nanoid";

if (process.env.NODE_ENV !== "production") {
dotenv.config({
Expand All @@ -20,7 +19,6 @@ if (!process.env.MONGODB_DB_NAME) {

const uri = process.env.MONGODB_URI;
const dbName = process.env.MONGODB_DB_NAME;
const devDbName = `${dbName}-migrations-test`;

// Create a new MongoClient
const client = new MongoClient(uri);
Expand All @@ -33,45 +31,13 @@ if (!database) {
throw new Error("Database not found");
}

const devDatabase = client.db(devDbName);

// FOR DEV ONLY
// Clone the original database
// Get the list of collections in the original database
consola.start("Cloning the original database...");

const collections = await database.listCollections().toArray();

for (const collection of collections) {
const collectionName = collection.name;

// Get the collection
const dbCollection = database.collection(collectionName);

// Get the documents in the collection
const documents = await dbCollection.find().toArray();

// Drop the collection in the new database if it exists
await devDatabase.dropCollection(collectionName).catch(() => {});

// Create a new collection in the new database
const newCollection = devDatabase.collection(collectionName);

// Insert the documents into the new collection
if (documents.length > 0) {
await newCollection.insertMany(documents);
}
}

consola.success("Database cloned!");

// Get the list of files in the migrations folder
const files = fs.readdirSync("./migrations");

// Order the files by name
files.sort();

const migrationsCollection = devDatabase.collection("migrations");
const migrationsCollection = database.collection("migrations");

for (const file of files) {
// Get the file name without the extension
Expand All @@ -96,19 +62,20 @@ for (const file of files) {

try {
// Run the migration
await migrationFunction(uri, devDbName, migrationId);
const entriesUpdated = await migrationFunction(uri, dbName, migrationId);

consola.success(`Migration ${migrationId} has been applied!`);

// Insert the migration into the migrations collection
await migrationsCollection.insertOne({
created_at: new Date(),
entries_updated: entriesUpdated,
migration_id: migrationId,
});
} catch (error) {
consola.error(`Error applying migration ${migrationId}: ${error.message}`);
throw error;
}

consola.success(`Migration ${migrationId} has been applied!`);

// Insert the migration into the migrations collection
// await migrationsCollection.insertOne({
// migration_id: migrationId,
// created_at: new Date(),
// });
}

await client.close();
Expand Down
Loading
Loading