-
Notifications
You must be signed in to change notification settings - Fork 91
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
Conversation
WalkthroughThe changes involve significant modifications to the Changes
Assessment against linked issues
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📒 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-structuredThe 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 fetchingThe new test case provides excellent coverage for the GithubBinary.fetch() method specifically for the skia-canvas repository:
- It tests fetching the root directory, ensuring the correct structure is returned.
- It verifies fetching an older version (v0.9.24) to check for consistent behavior.
- 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 likeoptions
anddisable
.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 removingoptions
.The changes to the
skia-canvas
entry align with the PR objective. Thetype
has been updated toBinaryType.GitHub
, and thedistUrl
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
forskia-canvas
. No unintended side effects found.The
skia-canvas
entry has been correctly updated to useBinaryType.GitHub
with thedistUrl
pointing to the GitHub releases page. The removal of theoptions
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
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
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:
- The assertion for v0.9.24 is good, but consider adding a comment explaining the reason for this check.
- The detailed checks for v0.9.30 use a similar loop-and-flag approach as before, which can be improved.
- There's a console.log statement that should be removed before merging to production.
Consider the following improvements:
- 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)));
- 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);
});
- Remove the console.log statement on line 64.
Remove the console.log statement on line 64 before merging to production.
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); | ||
|
There was a problem hiding this comment.
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.
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/')); |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
[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))
closes #710
pick from #712
Summary by CodeRabbit
New Features
binaries
configuration to include new entries and modified existing ones, enhancing the variety and sources of available binaries.Bug Fixes
GithubBinary
class with a new test case to ensure proper fetching ofskia-canvas
release data from GitHub.Refactor
skia-canvas
package from theNodePreGypBinary
test suite, streamlining the testing process.