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: enable tools view regeneration on a build time #2264

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

princerajpoot20
Copy link
Member

@princerajpoot20 princerajpoot20 commented Oct 24, 2023

Description

  • Added manual tools regeneration.
  • In regenerate-tools.yml, the default function, buildTools, will be used.
  • During a build, the buildToolsManual function is used. This function utilizes the currently available tools-automated.json, ensuring automated tools don't regenerate with every build. This ensures changes are visible in PR preview.

Resolves #2124

Summary by CodeRabbit

  • New Features

    • Introduced a new manual tool building process to enhance the existing build workflow.
    • Added error handling for improved reliability during tool combination.
  • Improvements

    • Enhanced modularity by separating tool combination logic into its own function.

@netlify
Copy link

netlify bot commented Oct 24, 2023

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit da35a34
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/660cd159f518ae0009f72871
😎 Deploy Preview https://deploy-preview-2264--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@princerajpoot20 princerajpoot20 changed the title adding tool preview workflow ci: adding tools view regeneration on a PR level Oct 24, 2023
@princerajpoot20 princerajpoot20 changed the title ci: adding tools view regeneration on a PR level feat: adding tools view regeneration on a PR level Oct 29, 2023
@github-actions
Copy link

github-actions bot commented Oct 29, 2023

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 30
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🔴 PWA 30

Lighthouse ran on https://deploy-preview-2264--asyncapi-website.netlify.app/

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

looks pretty clean to me, @akshatnema thoughts?

scripts/build-tools.js Show resolved Hide resolved
@derberg derberg changed the title feat: adding tools view regeneration on a PR level feat: enable tools view regeneration on a build time Oct 30, 2023
@akshatnema
Copy link
Member

looks pretty clean to me, @akshatnema thoughts?

I'm not in support of including the building of tools in build time because if we make these scripts at the build level, tools.json will be updated or regenerated at every start of the website. And we don't have such frequent changes in the tools. So, we can make a workflow such that whenever there will be changes in tools-manual.json, it can trigger PR workflow to update tools.json in the PR.

@princerajpoot20
Copy link
Member Author

princerajpoot20 commented Nov 6, 2023

So, We can have a new workflow such that if there are any changes to tools-manual.json, a new PR will be triggered to update tools.json.

A few things we have to take into account:

  • We have to add a /do-not-merge label to the newly generated PR since we already have a workflow that automatically approves and merges PRs generated by the asyncapi-bot. This PR should not be merged until the contributor's PR is merged. We can use this PR for preview at the PR level.

  • If there are any new commits in the contributor's PR, then we need to update/regenerate tools.json in the generated PR accordingly to reflect the new changes. There is no need to create a new PR for these updates.

  • After the successful merge of the contributor's PR, we have to remove the /do-not-merge tag from the generated PR, so that it can also be merged.

The problem that may occur is that if adding the /do-not-merge script takes more time than expected, then the PR could get merged during that period.

Another approach could be:

To push the changes into the contributor's PR directly. This could be possible when:

  • The PR is marked to Allow edits and access to secrets by maintainers, which is the default setting.

  • I am not sure, but I believe the asyncapi-bot does not have access, and only the asyncapi-bot-eve has maintainer rights, so only that account can push changes to the contributor's PR directly. I'm not sure about this.

What are your views @akshatnema, @derberg ?

@princerajpoot20
Copy link
Member Author

@asyncapi-bot is working like a charm.😄

@derberg
Copy link
Member

derberg commented Nov 6, 2023

@akshatnema but building of tools during build just handles manual tools only, quick operation. During build we build also other things, like rss feed, or case studies - that also do not change often.

ci/cd automation is nice but the more custom workflows the harder migration is (you could see how long it took to migrate recently)

@akshatnema
Copy link
Member

ci/cd automation is nice but the more custom workflows the harder migration is (you could see how long it took to migrate recently)

Ok, got your point well. But looking into present changes made by @princerajpoot20, I think we should have a separate file for building manual tools at build time. I'm not in preference to change the current build-tools automation because I've a different plan for it (to restructure the implementation of tools generation). Therefore, it would be nice, if we take building of manual tools in separate script file. WDYT? @derberg

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Dec 19, 2023

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 30
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-2264--asyncapi-website.netlify.app/

@derberg
Copy link
Member

derberg commented Dec 19, 2023

@akshatnema really depends. The question is when do you plan these changes. Cause if not soon, then I say we merge as it is and later just refactor.

@princerajpoot20
Copy link
Member Author

@derberg @akshatnema Ping Pong 😅

@akshatnema
Copy link
Member

@princerajpoot20 Kindly resolve the conflicts first.

@sambhavgupta0705
Copy link
Member

@princerajpoot20 any update on this issue?

@princerajpoot20
Copy link
Member Author

Done. resolved conflicts.

@sambhavgupta0705
Copy link
Member

@derberg @akshatnema PTAL

@sambhavgupta0705
Copy link
Member

@princerajpoot20 please resolve the conflicts

Copy link

This pull request has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation.

There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Nov 20, 2024
Copy link

coderabbitai bot commented Nov 20, 2024

Walkthrough

The changes introduce a new asynchronous function, combineAutomatedAndManualTools, which enhances the existing buildTools function by incorporating error handling. A new function, buildToolsManual, retrieves automated tools and calls the new function, also with error handling. The exports have been updated to include both functions, and a conditional check ensures buildTools runs when the script is executed directly. Additionally, scripts/index.js has been modified to integrate buildToolsManual into the existing workflow.

Changes

File Change Summary
scripts/build-tools.js Added combineAutomatedAndManualTools and buildToolsManual functions; updated exports.
scripts/index.js Added import for buildToolsManual and modified start function to include a call to it.

Assessment against linked issues

Objective Addressed Explanation
Support tools view regeneration on a PR level for manual tools (#2124)

Possibly related PRs

Suggested labels

ready-to-merge, gsoc

Suggested reviewers

  • derberg
  • magicmatatjahu
  • akshatnema
  • sambhavgupta0705
  • Mayaleeeee
  • asyncapi-bot-eve
  • BhaswatiRoy

🐰 In the garden where tools combine,
A manual touch, oh how divine!
With error logs to guide the way,
We build our dreams, come what may.
So hop along, let's make it right,
For every tool shines in the light! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
scripts/build-tools.js (3)

9-16: LGTM! Consider enhancing error message format.

The extracted helper function is well-structured and follows the single responsibility principle.

Consider formatting the error message to include more context:

-    console.log("Error while combining tools:", err);
+    console.error(`Error while combining automated and manual tools: ${err.message}`);

33-41: Add validation for automated tools data.

While the function successfully avoids regeneration as intended, consider adding validation to ensure the automated tools data is valid and the file exists.

 const buildToolsManual = async () => {
   try {
+    const automatedToolsPath = resolve(__dirname, '../config/tools-automated.json');
+    if (!fs.existsSync(automatedToolsPath)) {
+      throw new Error('Automated tools file not found. Run buildTools first.');
+    }
     const automatedTools = require('../config/tools-automated.json');
+    if (!Array.isArray(automatedTools)) {
+      throw new Error('Invalid automated tools data structure');
+    }
     await combineAutomatedAndManualTools(automatedTools);
   } catch (err) {
     console.log(err);

Line range hint 1-51: Consider centralizing file path configuration.

The file contains multiple instances of path resolution to the config directory. Consider centralizing these paths in a configuration file to improve maintainability.

Create a new file config/paths.js:

const { resolve } = require('path');

module.exports = {
  automatedToolsPath: resolve(__dirname, './tools-automated.json'),
  manualToolsPath: resolve(__dirname, './tools-manual.json'),
  // Add other paths as needed
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d8e0357 and da35a34.

📒 Files selected for processing (2)
  • scripts/build-tools.js (2 hunks)
  • scripts/index.js (2 hunks)
🔇 Additional comments (4)
scripts/index.js (2)

4-4: LGTM! Import statement follows consistent pattern

The destructured import of buildToolsManual is appropriately placed with other build-related imports.


23-23: Consider adding error handling and verify build order dependencies

While the integration of buildToolsManual() is correct, consider:

  1. Adding error handling at the function level to prevent build failures
  2. Verifying if the current position in the build sequence is optimal

Let's verify the build dependencies and error handling:

Consider wrapping the build step in a try-catch block:

async function start() {
  await buildPostList();
  rssFeed(
    'blog',
    'AsyncAPI Initiative Blog RSS Feed',
    'AsyncAPI Initiative Blog',
    'rss.xml'
  );
  rssFeed(
    'jobs',
    'AsyncAPI Initiative Jobs RSS Feed',
    'AsyncAPI Initiative Jobs Board',
    'jobs/rss.xml'
  );
  await buildCaseStudiesList();
-  await buildToolsManual();
+  try {
+    await buildToolsManual();
+  } catch (error) {
+    console.error('Failed to build tools:', error);
+    throw error; // Re-throw to fail the build
+  }
  await buildAdoptersList();
  await buildFinanceInfoList();
}
scripts/build-tools.js (2)

26-26: LGTM! Good refactoring.

The change effectively reuses the new helper function while maintaining the same functionality.


43-46: LGTM! Well-documented conditional execution.

The conditional execution is properly implemented and documented as requested in previous reviews.

Comment on lines +48 to +51
buildTools,
buildToolsManual
};
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Potential issue with unused export

The buildTools function is exported but not imported anywhere in the codebase. Only buildToolsManual is being used (in scripts/index.js).

  • scripts/index.js: Only imports and uses buildToolsManual
  • buildTools function is defined and exported but appears to be unused

Consider either:

  • Removing the unused buildTools export if it's no longer needed
  • Or documenting why it's exported if it's intended for future/external use
🔗 Analysis chain

LGTM! Verify usage in dependent files.

The exports are correctly updated to include both functions.

Let's verify the usage of these exports in dependent files:


Let me gather more information to verify if there are any other files that might be using these exports.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for imports and usage of buildTools and buildToolsManual
rg -l "require.*build-tools" | xargs rg "buildTools(Manual)?"

Length of output: 146


Script:

#!/bin/bash
# Search for any potential usage of buildTools function
rg "buildTools[^M]" -A 2

# Also check for dynamic requires or imports
rg "require.*['\"].*build-tools" -A 2

Length of output: 626

@github-actions github-actions bot removed the stale label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support tools view regeneration on a PR level for manual tools
5 participants