8000 fix: change skia-canvas to github release by fengmk2 · Pull Request #715 · cnpm/cnpmcore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: change skia-canvas to github release #715

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 p 8000 rivacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 13, 2024
Merged

fix: change skia-canvas to github release #715

merged 1 commit into from
Oct 13, 2024

Conversation

fengmk2
Copy link
Member
@fengmk2 fengmk2 commented Oct 13, 2024

closes #710

pick from #712

Summary by CodeRabbit

  • New Features

    • Updated the binaries configuration to include new entries and modified existing ones, enhancing the variety and sources of available binaries.
  • Bug Fixes

    • Improved the test coverage for the GithubBinary class with a new test case to ensure proper fetching of skia-canvas release data from GitHub.
  • Refactor

    • Removed outdated test cases related to the skia-canvas package from the NodePreGypBinary test suite, streamlining the testing process.

Copy link
Contributor
coderabbitai bot commented Oct 13, 2024

Walkthrough

The changes involve significant modifications to the BinaryTaskConfig type and the binaries constant in config/binaries.ts, particularly for the skia-canvas entry, which now points to a GitHub releases URL instead of an S3 URL. Additionally, the options property for skia-canvas has been removed. New entries have been added to the binaries constant. Corresponding updates were made to the test cases, including the addition of a test for fetching skia-canvas data from GitHub and the removal of the previous test for the same package from the NodePreGypBinary test suite.

Changes

File Change Summary
config/binaries.ts Updated BinaryTaskConfig type and binaries constant; modified skia-canvas entry; added multiple new entries.
test/common/adapter/binary/GithubBinary.test.ts Added test case for fetching skia-canvas from GitHub.
test/common/adapter/binary/NodePreGypBinary.test.ts Removed test case for fetching skia-canvas.

Assessment against linked issues

Objective Addressed Explanation
Update distUrl and options for skia-canvas in binaries.ts (#710)
Ensure synchronization of skia-canvas binary address (#710)

🐇 In the code where binaries play,
The skia-canvas found its way.
GitHub's now the place to be,
A hop, a skip, so binary!
Tests are added, some removed,
In this change, the path is proved! 🐇


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.

@fengmk2 fengmk2 added the bug Something isn't working label Oct 13, 2024
Copy link
Contributor
@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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b0cd0ba and ab3e9d9.

📒 Files selected for processing (3)
  • config/binaries.ts (1 hunks)
  • test/common/adapter/binary/GithubBinary.test.ts (2 hunks)
  • test/common/adapter/binary/NodePreGypBinary.test.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • test/common/adapter/binary/NodePreGypBinary.test.ts
🧰 Additional context used
🔇 Additional comments (4)
test/common/adapter/binary/GithubBinary.test.ts (2)

39-44: LGTM: Test setup is well-structured

The setup for the new test case follows good practices:

  • It uses a descriptive title.
  • It mocks the HTTP request to the GitHub API.
  • It loads test data from a fixture file, which is good for maintainability.

39-92: LGTM: Comprehensive test coverage for skia-canvas fetching

The new test case provides excellent coverage for the GithubBinary.fetch() method specifically for the skia-canvas repository:

  1. It tests fetching the root directory, ensuring the correct structure is returned.
  2. It verifies fetching an older version (v0.9.24) to check for consistent behavior.
  3. It thoroughly checks the latest version (v0.9.30), including specific file details.

This test case aligns well with the PR objectives of updating the skia-canvas configuration to use GitHub releases. It ensures that the new implementation correctly fetches and parses the release data from GitHub.

config/binaries.ts (2)

Line range hint 1-1000: LGTM! File structure and consistency are well-maintained.

The overall structure of the config/binaries.ts file is consistent and well-organized. Each binary entry follows a similar pattern, with variations as needed for different binary types. The file demonstrates flexibility in handling various binary configurations through properties like options and disable.

The changes made to the skia-canvas entry fit well within the existing structure of the file. The consistency in how binary configurations are defined will likely make future maintenance and updates easier.


137-140: LGTM! Verify the impact of removing options.

The changes to the skia-canvas entry align with the PR objective. The type has been updated to BinaryType.GitHub, and the distUrl now correctly points to the GitHub releases page. These changes should resolve the synchronization issue with the npmmirror registry.

However, the options property has been removed. While this is likely intentional due to the change in binary type, it's worth verifying that this removal doesn't have any unintended consequences on the binary handling process.

To ensure there are no unintended side effects, please run the following verification script:

✅ Verification successful

Verified the removal of options for skia-canvas. No unintended side effects found.

The skia-canvas entry has been correctly updated to use BinaryType.GitHub with the distUrl pointing to the GitHub releases page. The removal of the options property does not impact other binary entries in the configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any references to skia-canvas options in the codebase

# Search for any references to skia-canvas options
echo "Searching for references to skia-canvas options:"
rg --type typescript --type javascript 'skia-canvas.*options'

# Check if there are any other entries using NodePreGyp type without options
echo "Checking for other NodePreGyp entries without options:"
rg --type typescript 'type:\s*BinaryType\.NodePreGyp' -C 5 | rg -v 'options:'

Length of output: 437


Script:

#!/bin/bash
# Description: Check for any references to skia-canvas options in the codebase

# Search for any references to skia-canvas options
echo "Searching for references to skia-canvas options:"
rg 'skia-canvas.*options' --type ts --type tsx --type js --type jsx

# Check if there are any other entries using NodePreGyp type without options
echo "Checking for other NodePreGyp entries without options:"
rg 'type:\s*BinaryType\.NodePreGyp' --type ts --type tsx --type js --type jsx -C 5 | rg -v 'options:'

Length of output: 453


Script:

#!/bin/bash
# Description: Check for any references to skia-canvas options in the codebase

# Search for any references to skia-canvas options
echo "Searching for references to skia-canvas options:"
rg 'skia-canvas.*options' --glob '*.ts' --glob '*.tsx' --glob '*.js' --glob '*.jsx'

# Check for any other entries using NodePreGyp type without options
echo "Checking for other NodePreGyp entries without options:"
rg 'type:\s*BinaryType\.NodePreGyp' --glob '*.ts' --glob '*.tsx' --glob '*.js' --glob '*.jsx' -C 5 | rg -v 'options:'

Length of output: 2757

Comment on lines +58 to +91
result = await binary.fetch('/v0.9.24/', 'skia-canvas');
assert(result?.items.every(item => !/{.*}/.test(item.url)));

result = await binary.fetch('/v0.9.30/', 'skia-canvas');
assert(result);
assert(result.items.length > 0);
console.log(JSON.stringify(result.items, null, 2));
let matchFile1 = false;
let matchFile2 = false;
let matchFile3 = false;
for (const item of result.items) {
assert(item.isDir === false);
if (item.name === 'skia-canvas-v0.9.30-darwin-arm64.tar.gz') {
assert(item.date === '2024-08-26T18:04:13Z');
assert(item.size === 7547563);
assert.equal(item.url, 'https://github.com/samizdatco/skia-canvas/releases/download/v0.9.30/skia-canvas-v0.9.30-darwin-arm64.tar.gz');
matchFile1 = true;
}
if (item.name === 'skia-canvas-v0.9.30-linux-arm-glibc.tar.gz') {
assert(item.date === '2024-08-26T18:04:17Z');
assert(item.size === 8836353);
assert.equal(item.url, 'https://github.com/samizdatco/skia-canvas/releases/download/v0.9.30/skia-canvas-v0.9.30-linux-arm-glibc.tar.gz');
matchFile2 = true;
}
if (item.name === 'skia-canvas-v0.9.30-win32-x64.tar.gz') {
assert(item.date === '2024-08-26T18:04:29Z');
assert(item.size === 7497076);
assert.equal(item.url, 'https://github.com/samizdatco/skia-canvas/releases/download/v0.9.30/skia-canvas-v0.9.30-win32-x64.tar.gz');
matchFile3 = true;
}
}
assert(matchFile1);
assert(matchFile2);
assert(matchFile3);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Improve test efficiency and remove console logging

The test case for fetching specific version data is thorough, but there are a few areas for improvement:

  1. The assertion for v0.9.24 is good, but consider adding a comment explaining the reason for this check.
  2. The detailed checks for v0.9.30 use a similar loop-and-flag approach as before, which can be improved.
  3. There's a console.log statement that should be removed before merging to production.

Consider the following improvements:

  1. Add a comment explaining the v0.9.24 check:
// Ensure that item URLs don't contain curly braces, which could indicate an unresolved template
assert(result?.items.every(item => !/{.*}/.test(item.url)));
  1. Refactor the v0.9.30 checks using Array.prototype.find():
const files = [
  {
    name: 'skia-canvas-v0.9.30-darwin-arm64.tar.gz',
    date: '2024-08-26T18:04:13Z',
    size: 7547563,
    url: 'https://github.com/samizdatco/skia-canvas/releases/download/v0.9.30/skia-canvas-v0.9.30-darwin-arm64.tar.gz'
  },
  // ... add other files here
];

files.forEach(expectedFile => {
  const file = result.items.find(item => item.name === expectedFile.name);
  assert(file, `File ${expectedFile.name} not found`);
  assert.equal(file.date, expectedFile.date);
  assert.equal(file.size, expectedFile.size);
  assert.equal(file.url, expectedFile.url);
});
  1. Remove the console.log statement on line 64.

Remove the console.log statement on line 64 before merging to production.

Comment on lines +45 to +57
let result = await binary.fetch('/', 'skia-canvas');
assert(result);
assert(result.items.length > 0);
// console.log(JSON.stringify(result.items, null, 2));
let matchDir = false;
for (const item of result.items) {
assert(item.isDir === true);
if (item.name === 'v0.9.30/') {
matchDir = true;
}
}
assert(matchDir);

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using Array.prototype.some() for more efficient directory checking

While the current implementation works, we can improve its efficiency and readability by using Array.prototype.some() instead of a loop with a flag.

Consider refactoring the directory check as follows:

- let matchDir = false;
- for (const item of result.items) {
-   assert(item.isDir === true);
-   if (item.name === 'v0.9.30/') {
-     matchDir = true;
-   }
- }
- assert(matchDir);
+ assert(result.items.every(item => item.isDir === true));
+ assert(result.items.some(item => item.name === 'v0.9.30/'));

This change will make the code more concise and potentially more efficient, as it can short-circuit once a match is found.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no iss 8000 ues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let result = await binary.fetch('/', 'skia-canvas');
assert(result);
assert(result.items.length > 0);
// console.log(JSON.stringify(result.items, null, 2));
let matchDir = false;
for (const item of result.items) {
assert(item.isDir === true);
if (item.name === 'v0.9.30/') {
matchDir = true;
}
}
assert(matchDir);
let result = await binary.fetch('/', 'skia-canvas');
assert(result);
assert(result.items.length > 0);
// console.log(JSON.stringify(result.items, null, 2));
assert(result.items.every(item => item.isDir === true));
assert(result.items.some(item => item.name === 'v0.9.30/'));

Copy link
codecov bot commented Oct 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.46%. Comparing base (b0cd0ba) to head (ab3e9d9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #715      +/-   ##
==========================================
- Coverage   96.83%   96.46%   -0.37%     
==========================================
  Files         188      188              
  Lines       18799    18796       -3     
  Branches     2466     2464       -2     
==========================================
- Hits        18204    18132      -72     
- Misses        595      664      +69     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fengmk2 fengmk2 merged commit 99a8660 into master Oct 13, 2024
12 of 13 checks passed
@fengmk2 fengmk2 deleted the ltxhhz-master branch October 13, 2024 03:21
fengmk2 pushed a commit that referenced this pull request Oct 13, 2024
[skip ci]

## [3.63.1](v3.63.0...v3.63.1) (2024-10-13)

### Bug Fixes

* change skia-canvas to github release ([#715](#715)) ([99a8660](99a8660))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

skia-canvas 二进制地址已修改导致没有同步
2 participants
0