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

feat: ✨ ♻️ πŸ› Codefair v3.1.0 #97

Merged
merged 11 commits into from
Nov 5, 2024
Merged

feat: ✨ ♻️ πŸ› Codefair v3.1.0 #97

merged 11 commits into from
Nov 5, 2024

Conversation

slugb0t
Copy link
Member

@slugb0t slugb0t commented Nov 5, 2024

Summary by Sourcery

Introduce a new workflow to streamline GitHub release integration with Zenodo archiving, ensuring metadata is updated before releases. Add support for custom license titles and improve error handling and logging. Fix issues with metadata PR links and codemeta.json date updates. Enhance the UI with additional resources and improved layouts.

New Features:

  • Implement a new workflow to integrate GitHub release process with Zenodo archiving, ensuring metadata is updated before each release.
  • Add support for custom license titles, allowing users to specify a title for custom licenses.

Bug Fixes:

  • Fix issue with PR link not being replaced correctly in the Metadata section of the FAIR Compliance Dashboard Issue.
  • Stop updating the date for 'first released date' in the existing codemeta.json file.

Enhancements:

  • Improve error handling and logging for Zenodo publishing and license detection processes.
  • Enhance the user interface with additional links to external resources and improved button layouts.

Documentation:

  • Update documentation to reflect changes in the release and archival process, including new workflows and UI enhancements.

Summary by Sourcery

Introduce a new workflow to streamline GitHub release integration with Zenodo archiving, ensuring metadata is updated before releases. Add support for custom license titles and improve error handling and logging. Fix issues with metadata PR links and codemeta.json date updates. Enhance the UI with additional resources and improved layouts.

New Features:

  • Implement a new workflow to integrate GitHub release process with Zenodo archiving, ensuring metadata is updated before each release.
  • Add support for custom license titles, allowing users to specify a title for custom licenses.

Bug Fixes:

  • Fix issue with PR link not being replaced correctly in the Metadata section of the FAIR Compliance Dashboard Issue.
  • Stop updating the date for 'first released date' in the existing codemeta.json file.

Enhancements:

  • Improve error handling and logging for Zenodo publishing and license detection processes.
  • Enhance the user interface with additional links to external resources and improved button layouts.

Documentation:

  • Update documentation to reflect changes in the release and archival process, including new workflows and UI enhancements.

slugb0t and others added 11 commits October 17, 2024 10:52
* fix: πŸ› patch removing pull_request.closed bug on metadata pr merge

* fix: πŸ› don't update firstPublished in the codemeta file + better logs

* fix: πŸ› patch error on reading db entry when it doesn't exist

* chore: πŸ”Š better log on successful Zenodo publish

* style: 🎨 margins between text and icon

* feat: ✨ links to the list of tools used for codefair in /codefair

* refactor: ✨ ♻️ abstract the license validation fn

* doc: πŸ”– update changelog

* feat: ✨ ♻️ abstraction to zenodo workflow

* wip: 🚧 abstracting zenodo workflow

* feat: ✨ add help link in the Zenodo release page

* refactor: ♻️ ✨ abstract out github release functions

* refactor: πŸ”Š ♻️ improve error tracing in metadata file

* chore: πŸ”¨ remove todo

* refactor: ✨ ♻️ abstracted Zenodo workflow (bot)

* wip: 🚧 save custom license content when no assertion is provided

* ✨ feat: add support for custom licenses (#90)

* ✨ feat: add support for custom licenses

* πŸ› fix: reset citation license field

* πŸ› fix: update zenodo workflow for custom licenses

* fix: πŸ› license is valid with custom license

* feat: ✨ custom license template

* ✨ feat: update codemeta, license and cwl ui paths (#91)

* ✨ feat: update meta paths for consistency

* 🚚 fix: updatel icense request path

* ✨ feat: add support for custom license title (#92)

* refactor: ♻️ ✨ new patches for license, cwl, metadata UI's

* refactor: ✨ ♻️ apply migrations from UI to bot

* feat: ✨ request custom license title from user

* refactor: ♻️ hide message box when custom license title is blank

* refactor: ♻️ issue dashboard requests custom title

* feat: ✨ Saving custom title (#93)

* feat: ✨ save custom title option

* refactor: :recyle: reuse saveLicenseDraft for storing custom license title

* refactor: ♻️ join draft and save title buttons together

* refactor: ♻️ use naive-ui's properties for styling

* chore: πŸ”¨ remove typo

* chore: πŸ”¨ remove unused variables

* feat: ✨ toasts for custom title saved button

* refactor: ♻️ function rename

* feat: ✨ create Zenodo metadata fn handles custom licenses

* feat: ✨ custom license reference for archival workflow

* refactor: ♻️ stop creating identifiers for new db entries

* refactor: ♻️ πŸ› revert allowing custom licenses for zenodo

* refactor: ♻️ Custom License Support (#94)

* refactor: ♻️ ✨ custom title saved updates dashboard, disable create release btn when custom license

* refactor: ♻️ block progress of fair release if license is custom

* feat: ✨ listener for when custom license title is saved through UI

* feat: ✨ prevent fair release if not fair compliant

* refactor: ♻️ improve license validation and update template text for custom licenses

* refactor: ♻️ re-render issue from ui side

* refactor: ♻️ update to message explaining custom licenses

* db calls running in parallel

* fix: πŸ› prevent Zendo section from being seen when the license is custom

* fix: πŸ› trim license content before comparison

---------

Co-authored-by: Sanjay Soundarajan <sanjay.16@live.com>
Copy link

Thank you for submitting this pull request! We appreciate your contribution to the project. Before we can merge it, we need to review the changes you've made to ensure they align with our code standards and meet the requirements of the project. We'll get back to you as soon as we can with feedback. Thanks again!

Copy link

sourcery-ai bot commented Nov 5, 2024

Reviewer's Guide by Sourcery

This pull request implements a new workflow for GitHub release integration with Zenodo archiving, adds support for custom license titles, and includes various improvements to error handling, logging, and UI elements. The changes focus on enhancing the user experience while ensuring proper metadata handling and archival compliance.

Sequence diagram for GitHub release integration with Zenodo archiving

sequenceDiagram
    actor User
    participant GitHub
    participant Zenodo
    participant Database
    participant Bot

    User->>GitHub: Create a release
    GitHub->>Bot: Trigger release event
    Bot->>Database: Fetch Zenodo token
    Database-->>Bot: Return Zenodo token
    Bot->>Zenodo: Create or fetch deposition
    Zenodo-->>Bot: Return deposition info
    Bot->>GitHub: Update release metadata
    Bot->>Zenodo: Upload assets
    Bot->>Zenodo: Publish deposition
    Zenodo-->>Bot: Confirm publication
    Bot->>GitHub: Update release status
    Bot->>User: Notify release completion
Loading

Updated class diagram for archival and license handling

classDiagram
    class Archival {
        +updateGitHubRelease(context, repositoryName, owner, releaseId)
        +publishZenodoDeposition(zenodoToken, depositionId)
        +getZenodoToken(user)
        +parseZenodoInfo(issueBody)
    }
    class License {
        +validateLicense(licenseRequest, existingLicense)
        +applyLicenseTemplate(context, owner, repository, subjects)
    }
    class Metadata {
        +getCodemetaContent(context, owner, repository)
        +getCitationContent(context, owner, repository)
        +validateMetadata(content, fileType)
        +updateMetadataIdentifier(context, owner, repository, identifier, version)
    }
    Archival --> Zenodo
    Archival --> GitHub
    License --> Database
    Metadata --> Database
    Metadata --> GitHub
    Metadata --> Zenodo
    Zenodo : API
    GitHub : API
    Database : Prisma
Loading

File-Level Changes

Change Details Files
Implemented a new workflow for Zenodo archival integration
  • Added new functions for handling Zenodo deposition publishing and token management
  • Improved error handling for Zenodo API interactions
  • Restructured the Zenodo metadata update process
  • Added validation checks for Zenodo publishing requirements
bot/archival/index.js
Added support for custom license titles and improved license handling
  • Added custom license title field and validation
  • Implemented custom license detection and validation logic
  • Updated UI to handle custom license scenarios
  • Added warnings for custom license limitations with Zenodo
ui/pages/dashboard/[owner]/[repo]/edit/license.vue
bot/license/index.js
ui/server/api/[owner]/[repo]/license/index.post.ts
ui/server/api/[owner]/[repo]/license/custom_title.put.ts
Enhanced error handling and logging system
  • Implemented consistent error handling patterns across the application
  • Added more detailed error messages and logging
  • Improved error propagation and context preservation
  • Added validation checks for API responses
bot/utils/tools/index.js
bot/metadata/index.js
ui/error.vue
Improved UI and navigation structure
  • Restructured dashboard routes for better organization
  • Added additional resource links and improved layouts
  • Updated button placements and styling
  • Enhanced navigation handling for authentication flows
ui/pages/dashboard/[owner]/[repo]/index.vue
ui/pages/dashboard/[owner]/[repo]/release/zenodo.vue
ui/pages/codefair.vue
ui/middleware/protected.ts
Fixed metadata handling issues
  • Fixed PR link replacement in metadata section
  • Stopped updating first release date in codemeta.json
  • Improved metadata validation and update process
  • Added checks for custom license metadata handling
bot/metadata/index.js
ui/server/api/[owner]/[repo]/code-metadata/index.post.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

Thanks for making updates to your pull request. Our team will take a look and provide feedback as soon as possible. Please wait for any GitHub Actions to complete before editing your pull request. If you have any additional questions or concerns, feel free to let us know. Thank you for your contributions!

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @slugb0t - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟑 General issues: 3 issues found
  • 🟑 Security: 1 issue found
  • 🟒 Testing: all looks good
  • 🟒 Complexity: all looks good
  • 🟑 Documentation: 1 issue found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click πŸ‘ or πŸ‘Ž on each comment and I'll use the feedback to improve your reviews.

}
});

if (!deposition || !deposition.token) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Error message references undefined variable 'tagVersion'

The error message references 'tagVersion' which is not defined in this scope. Consider updating to reference the 'user' parameter instead.

});

if (!deposition || !deposition.token) {
throw new Error(`Deposition with tag ${tagVersion} not found in db.`, { cause: error });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Undefined error variable used in error cause

The error cause references an undefined 'error' variable. This could cause unexpected behavior.

if (!match) {
throw new Error("Zenodo publish information not found in issue body.");
}
const [depositionId, releaseId, tagVersion, userWhoSubmitted] = match[1].trim().split(/\s+/);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Add validation for parsed Zenodo info values

Consider adding validation to ensure all required values are present and valid before returning them.

Suggested change
const [depositionId, releaseId, tagVersion, userWhoSubmitted] = match[1].trim().split(/\s+/);
const [depositionId, releaseId, tagVersion, userWhoSubmitted] = match[1].trim().split(/\s+/);
if (!depositionId || !releaseId || !tagVersion || !userWhoSubmitted) {
throw new Error("Missing required Zenodo publish information values");
}

@@ -118,7 +118,7 @@ export async function applyCWLTemplate(
const privateRepo = await isRepoPrivate(context, owner, repository.name);
const identifier = createId();
const overallSection = `\n\n## Language Specific Standards\n\nTo make your software FAIR is it important to follow language specific standards and best practices. Codefair will check below that your code complies with applicable standards,`;
let url = `${CODEFAIR_DOMAIN}/view/cwl-validation/${identifier}`;
let url = `${CODEFAIR_DOMAIN}/dashboard/${owner}/${repository.name}/view/cwl-validation`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Use URL constructor for safer URL building

String concatenation for URLs can be unsafe if variables contain special characters. Consider using the URL constructor or proper URL encoding methods to safely construct URLs.

const url = new URL(`dashboard/${owner}/${repository.name}/view/cwl-validation`, CODEFAIR_DOMAIN).toString();

@@ -5,6 +5,23 @@ 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.3.1.0 - 11-05-2024
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (documentation): Version number format inconsistent with previous entries

Consider removing the extra period to match the format used in other version numbers (e.g., 'v3.1.0')

Suggested change
## v.3.1.0 - 11-05-2024
## v3.1.0 - 11-05-2024

Comment on lines +290 to +291
const newZenodoDeposition = await createNewZenodoDeposition(zenodoToken);
return newZenodoDeposition;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Inline variable that is immediately returned (inline-immediately-returned-variable)

Suggested change
const newZenodoDeposition = await createNewZenodoDeposition(zenodoToken);
return newZenodoDeposition;
return await createNewZenodoDeposition(zenodoToken);


ExplanationSomething that we often see in people's code is assigning to a result variable
and then immediately returning it.

Returning the result directly shortens the code and removes an unnecessary
variable, reducing the mental load of reading the function.

Where intermediate variables can be useful is if they then get used as a
parameter or a condition, and the name can act like a comment on what the
variable represents. In the case where you're returning it from a function, the
function name is there to tell you what the result is, so the variable name
is unnecessary.

})
]);

const license = licenseResponse?.license_id ? true : false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Avoid unneeded ternary statements (simplify-ternary)

Suggested change
const license = licenseResponse?.license_id ? true : false;
const license = !!licenseResponse?.license_id;


ExplanationIt is possible to simplify certain ternary statements into either use of an || or !.
This makes the code easier to read, since there is no conditional logic.

]);

const license = licenseResponse?.license_id ? true : false;
const citation = metadataResponse?.contains_citation ? true : false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Avoid unneeded ternary statements (simplify-ternary)

Suggested change
const citation = metadataResponse?.contains_citation ? true : false;
const citation = !!metadataResponse?.contains_citation;


ExplanationIt is possible to simplify certain ternary statements into either use of an || or !.
This makes the code easier to read, since there is no conditional logic.


const license = licenseResponse?.license_id ? true : false;
const citation = metadataResponse?.contains_citation ? true : false;
const codemeta = metadataResponse?.contains_codemeta ? true : false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Avoid unneeded ternary statements (simplify-ternary)

Suggested change
const codemeta = metadataResponse?.contains_codemeta ? true : false;
const codemeta = !!metadataResponse?.contains_codemeta;


ExplanationIt is possible to simplify certain ternary statements into either use of an || or !.
This makes the code easier to read, since there is no conditional logic.

const license = licenseResponse?.license_id ? true : false;
const citation = metadataResponse?.contains_citation ? true : false;
const codemeta = metadataResponse?.contains_codemeta ? true : false;
const cwl = cwlResponse?.contains_cwl_files ? true : false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Avoid unneeded ternary statements (simplify-ternary)

Suggested change
const cwl = cwlResponse?.contains_cwl_files ? true : false;
const cwl = !!cwlResponse?.contains_cwl_files;


ExplanationIt is possible to simplify certain ternary statements into either use of an || or !.
This makes the code easier to read, since there is no conditional logic.

@slugb0t slugb0t merged commit 8bf5625 into main Nov 5, 2024
1 check passed
Copy link

Thanks for closing this pull request! If you have any further questions, please feel free to open a new issue. We are always happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant