Skip to content

feat(rust-plugins): plugin compress#117

Merged
CCherry07 merged 21 commits intomainfrom
feat/plugin-compress
Feb 25, 2025
Merged

feat(rust-plugins): plugin compress#117
CCherry07 merged 21 commits intomainfrom
feat/plugin-compress

Conversation

@fu050409
Copy link
Copy Markdown
Member

@fu050409 fu050409 commented Feb 10, 2025

图片

Summary by CodeRabbit

  • New Features

    • Introduced a compression plugin with enhanced algorithm options and advanced configuration.
    • Rolled out platform-specific packages for broader compatibility.
    • Added a new playground template for seamless integration with the Farm + React stack.
  • Documentation

    • Provided comprehensive guides and READMEs covering setup and usage of the compression plugin and playground.
  • Chores

    • Updated build workflows and dependency management for improved clarity and performance.
    • Removed outdated formatting configurations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 24, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces numerous updates and new files related to a compression plugin implementation. Modifications include adjustments to the GitHub build workflow (with command formatting and version updates for actions), and the addition of new plugin components across several directories. These encompass Rust source files, TypeScript interfaces, NPM package configurations for multiple target platforms, playground resources for a Farm+React setup, and supporting scripts. Additionally, several legacy rustfmt.toml configuration files have been removed from various submodules.

Changes

File(s) Change Summary
.github/workflows/build.yaml Updated build command formatting; upgraded actions/checkout and actions/setup-node versions; refactored dependency installation to a multi-line script.
rust-plugins/compress/.gitignore New .gitignore added to ignore common Node.js, macOS, Windows, and Rust/Cargo artifacts.
rust-plugins/compress/Cargo.toml New Cargo package defined for the farmfe_plugin_compress with crate types cdylib and rlib, and added dependencies.
rust-plugins/compress/npm/{darwin-arm64,darwin-x64,linux-arm64-gnu,linux-arm64-musl,linux-x64-gnu,linux-x64-musl,win32-arm64-msvc,win32-ia32-msvc,win32-x64-msvc}/{README.md,package.json} Introduced multiple new npm packages and README files for various OS/architecture targets for the compress plugin.
rust-plugins/compress/options.d.ts Added new TypeScript interface IPluginOptions for configuring the compression plugin.
rust-plugins/compress/package.json New package declaration for @farmfe/plugin-compress with metadata, scripts, and export definitions.
rust-plugins/compress/playground/** Added a complete playground setup including README, configuration (farm.config.ts), HTML, JS, CSS, TypeScript files, and TS config files for a Farm + React template.
rust-plugins/compress/pnpm-workspace.yaml New workspace configuration listing the current package and playground.
rust-plugins/compress/scripts/** New scripts added: func.js, TypeScript declaration (index.d.ts), dynamic binary resolution (index.js), and a watch script (watch.sh).
rust-plugins/compress/src/{lib.rs,utils.rs} Introduced Rust source files implementing the core compression plugin logic, including enums, structs, plugin lifecycle methods, and utility functions for various compression algorithms.
rust-plugins/compress/README.md New README documenting the plugin, its configuration options, and usage instructions.
rust-plugins/{dsv,icons,image,mdx,react-components,strip,url,virtual,wasm,yaml}/rustfmt.toml Removed legacy rustfmt.toml files (and their formatting settings) from multiple directories.

Sequence Diagram(s)

sequenceDiagram
  participant Farm as Farm Build Process
  participant Plugin as FarmfePluginCompress
  participant Utils as Compression Utils
  participant FS as File System

  Farm->>Plugin: Initiate compression on assets
  Plugin->>Utils: Call compress_buffer(buffer, algorithm, level)
  Utils-->>Plugin: Return compressed data
  Plugin->>FS: Replace original files (if deleteOriginFile enabled)
  Plugin->>Farm: Report compression summary and stats
Loading

Poem

Oh, what a thrill on this coding day,
I'm a rabbit hopping down the pipeline way.
New files and changes, crisp and neat,
Compressing assets with a rhythmic beat.
With whiskers twitching and code so bright,
I cheer these changes with pure delight!
🐇💻 Hop on and code away!


🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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
Copy Markdown

@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

🧹 Nitpick comments (15)
rust-plugins/compress/src/lib.rs (2)

84-85: Consider compiling the regex once earlier.
Regex compilation occurs during each finalize pass, which might be repetitive if called multiple times. Compiling the regex in the constructor could improve performance.


130-140: Provide configurable logging.
The color-coded log is helpful, but some environments may not support ANSI escape sequences. Consider adding a configuration option to disable or alter log formatting for different environments.

rust-plugins/compress/scripts/index.d.ts (1)

1-3: Validate or document default option values.
Although this declaration is minimal, ensuring that binPath() clearly documents or enforces valid defaults for IPluginOptions can prevent misuse.

Do you want to add additional type checks or JSDoc comments explaining the default behavior?

rust-plugins/compress/options.d.ts (1)

1-34: LGTM! Well-structured interface with clear documentation.

The interface is well-documented with JSDoc comments, sensible defaults, and clear type definitions. The use of a regex string instead of a RegExp object for the filter option is a good choice to avoid deserialization issues.

Consider adding common image formats to the default filter pattern since they often benefit from compression:

-	 * @default '\\.(js|mjs|json|css|html)$'
+	 * @default '\\.(js|mjs|json|css|html|png|jpg|jpeg|gif|svg)$'
rust-plugins/compress/playground/src/main.tsx (2)

7-7: Remove debug console.log statement.

The console.log statement appears to be debug code that should be removed before production.

-  console.log("rendering Main component")

11-16: Add security attributes to external links.

External links opening in new tabs should include rel="noopener noreferrer" to prevent potential security vulnerabilities.

-        <a href="https://farmfe.org/" target="_blank">
+        <a href="https://farmfe.org/" target="_blank" rel="noopener noreferrer">
-        <a href="https://react.dev" target="_blank">
+        <a href="https://react.dev" target="_blank" rel="noopener noreferrer">
rust-plugins/compress/src/utils.rs (2)

77-88: Document magic numbers in brotli_compress function.

The function uses magic numbers (4096, 22) without explanation. These parameters affect compression performance and should be documented.

+  // Buffer size of 4096 bytes and window size of 22 (4MB) for optimal compression
   let mut encoder = brotli::CompressorWriter::new(Vec::new(), 4096, level, 22);

23-88: Reduce error handling duplication.

The error mapping code is duplicated across all compression functions. Consider extracting it into a helper function.

fn map_compression_error(algorithm: &str, error: impl std::error::Error + 'static) -> CompilationError {
    CompilationError::GenerateResourcesError {
        name: algorithm.to_string(),
        ty: ResourcePotType::Custom(algorithm.to_string()),
        source: Some(Box::new(error)),
    }
}
rust-plugins/compress/scripts/index.js (1)

27-122: Reduce code duplication in platform-specific logic.

The binary path resolution logic is repeated for each platform/architecture combination. Consider extracting this into a helper function.

function resolveBinaryPath(platform, arch, variant = '') {
  const platformPath = `${platform}-${arch}${variant}`;
  const localPath = join(currentDir, `../npm/${platformPath}/index.farm`);
  return existsSync(localPath)
    ? localPath
    : require.resolve(`@farmfe/plugin-compress-${platformPath}`);
}
rust-plugins/compress/.cargo/config.toml (1)

16-25: AArch64 Linux MUSL Configuration Caution
The [target.aarch64-unknown-linux-musl] section sets a MUSL linker and applies rustflags including "-C", "target-feature=-crt-static". Since MUSL is typically associated with fully static linking, please double-check that disabling CRT static linking is intentional for your deployment scenario.

rust-plugins/compress/.github/workflows/ci.yaml (2)

11-29: Artifact Handling in Test Artifacts Job
The job downloads artifacts to /tmp/artifacts and then iterates over a set of ABI configurations to move plugin files to ./npm/${abi} and verify the existence of index.farm. Consider checking or creating the target directories before the move to avoid potential errors if they do not already exist.


36-36: Newline at EOF
A newline at the end of the file is missing. Please add one to comply with YAML formatting best practices.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 36-36: no new line character at the end of file

(new-line-at-end-of-file)

rust-plugins/compress/.github/workflows/release.yml (2)

31-37: Artifact Relocation in Release Job
The for-loop moves artifacts into the expected npm directories and validates the presence of index.farm. Similar to the CI workflow, consider ensuring that the destination directories exist to avoid move errors.


42-42: Newline at EOF
Please add a newline at the end of the file to meet YAML formatting requirements.

rust-plugins/compress/pnpm-workspace.yaml (1)

1-1: Remove Trailing Spaces
The static analysis tool detected trailing spaces on line 1. Please remove any trailing whitespace to maintain clean YAML formatting.

-packages: 
+packages:
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 1-1: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3fd2f6a and 5ebfe9b.

⛔ Files ignored due to path filters (7)
  • Cargo.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • rust-plugins/compress/Cargo.lock is excluded by !**/*.lock
  • rust-plugins/compress/playground/public/favicon.ico is excluded by !**/*.ico
  • rust-plugins/compress/playground/src/assets/logo.png is excluded by !**/*.png
  • rust-plugins/compress/playground/src/assets/react.svg is excluded by !**/*.svg
  • rust-plugins/compress/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (48)
  • .github/workflows/build.yaml (2 hunks)
  • rust-plugins/compress/.cargo/config.toml (1 hunks)
  • rust-plugins/compress/.github/workflows/build.yaml (1 hunks)
  • rust-plugins/compress/.github/workflows/ci.yaml (1 hunks)
  • rust-plugins/compress/.github/workflows/release.yml (1 hunks)
  • rust-plugins/compress/.gitignore (1 hunks)
  • rust-plugins/compress/Cargo.toml (1 hunks)
  • rust-plugins/compress/npm/darwin-arm64/README.md (1 hunks)
  • rust-plugins/compress/npm/darwin-arm64/package.json (1 hunks)
  • rust-plugins/compress/npm/darwin-x64/README.md (1 hunks)
  • rust-plugins/compress/npm/darwin-x64/package.json (1 hunks)
  • rust-plugins/compress/npm/linux-arm64-gnu/README.md (1 hunks)
  • rust-plugins/compress/npm/linux-arm64-gnu/package.json (1 hunks)
  • rust-plugins/compress/npm/linux-arm64-musl/README.md (1 hunks)
  • rust-plugins/compress/npm/linux-arm64-musl/package.json (1 hunks)
  • rust-plugins/compress/npm/linux-x64-gnu/README.md (1 hunks)
  • rust-plugins/compress/npm/linux-x64-gnu/package.json (1 hunks)
  • rust-plugins/compress/npm/linux-x64-musl/README.md (1 hunks)
  • rust-plugins/compress/npm/linux-x64-musl/package.json (1 hunks)
  • rust-plugins/compress/npm/win32-arm64-msvc/README.md (1 hunks)
  • rust-plugins/compress/npm/win32-arm64-msvc/package.json (1 hunks)
  • rust-plugins/compress/npm/win32-ia32-msvc/README.md (1 hunks)
  • rust-plugins/compress/npm/win32-ia32-msvc/package.json (1 hunks)
  • rust-plugins/compress/npm/win32-x64-msvc/README.md (1 hunks)
  • rust-plugins/compress/npm/win32-x64-msvc/package.json (1 hunks)
  • rust-plugins/compress/options.d.ts (1 hunks)
  • rust-plugins/compress/package.json (1 hunks)
  • rust-plugins/compress/playground/README.md (1 hunks)
  • rust-plugins/compress/playground/farm.config.ts (1 hunks)
  • rust-plugins/compress/playground/index.html (1 hunks)
  • rust-plugins/compress/playground/index.js (1 hunks)
  • rust-plugins/compress/playground/package.json (1 hunks)
  • rust-plugins/compress/playground/src/index.css (1 hunks)
  • rust-plugins/compress/playground/src/index.tsx (1 hunks)
  • rust-plugins/compress/playground/src/main.css (1 hunks)
  • rust-plugins/compress/playground/src/main.tsx (1 hunks)
  • rust-plugins/compress/playground/src/typings.d.ts (1 hunks)
  • rust-plugins/compress/playground/tsconfig.json (1 hunks)
  • rust-plugins/compress/playground/tsconfig.node.json (1 hunks)
  • rust-plugins/compress/pnpm-workspace.yaml (1 hunks)
  • rust-plugins/compress/rust-toolchain.toml (1 hunks)
  • rust-plugins/compress/rustfmt.toml (1 hunks)
  • rust-plugins/compress/scripts/func.js (1 hunks)
  • rust-plugins/compress/scripts/index.d.ts (1 hunks)
  • rust-plugins/compress/scripts/index.js (1 hunks)
  • rust-plugins/compress/scripts/watch.sh (1 hunks)
  • rust-plugins/compress/src/lib.rs (1 hunks)
  • rust-plugins/compress/src/utils.rs (1 hunks)
✅ Files skipped from review due to trivial changes (35)
  • rust-plugins/compress/playground/index.js
  • rust-plugins/compress/scripts/func.js
  • rust-plugins/compress/scripts/watch.sh
  • rust-plugins/compress/npm/win32-x64-msvc/README.md
  • rust-plugins/compress/playground/tsconfig.node.json
  • rust-plugins/compress/rustfmt.toml
  • rust-plugins/compress/playground/src/index.tsx
  • rust-plugins/compress/npm/linux-x64-musl/README.md
  • rust-plugins/compress/npm/linux-x64-gnu/README.md
  • rust-plugins/compress/npm/win32-ia32-msvc/README.md
  • rust-plugins/compress/npm/win32-arm64-msvc/README.md
  • rust-plugins/compress/npm/darwin-arm64/README.md
  • rust-plugins/compress/rust-toolchain.toml
  • rust-plugins/compress/npm/win32-arm64-msvc/package.json
  • rust-plugins/compress/npm/darwin-x64/README.md
  • rust-plugins/compress/npm/linux-arm64-musl/README.md
  • rust-plugins/compress/.gitignore
  • rust-plugins/compress/npm/linux-arm64-gnu/README.md
  • rust-plugins/compress/npm/linux-arm64-gnu/package.json
  • rust-plugins/compress/npm/linux-x64-musl/package.json
  • rust-plugins/compress/playground/index.html
  • rust-plugins/compress/npm/darwin-arm64/package.json
  • rust-plugins/compress/npm/darwin-x64/package.json
  • rust-plugins/compress/npm/linux-arm64-musl/package.json
  • rust-plugins/compress/playground/src/typings.d.ts
  • rust-plugins/compress/playground/tsconfig.json
  • rust-plugins/compress/package.json
  • rust-plugins/compress/npm/win32-ia32-msvc/package.json
  • rust-plugins/compress/npm/linux-x64-gnu/package.json
  • rust-plugins/compress/playground/README.md
  • rust-plugins/compress/npm/win32-x64-msvc/package.json
  • rust-plugins/compress/playground/src/index.css
  • rust-plugins/compress/playground/package.json
  • rust-plugins/compress/playground/src/main.css
  • rust-plugins/compress/Cargo.toml
🧰 Additional context used
🪛 YAMLlint (1.35.1)
rust-plugins/compress/.github/workflows/release.yml

[error] 43-43: no new line character at the end of file

(new-line-at-end-of-file)

rust-plugins/compress/.github/workflows/ci.yaml

[error] 36-36: no new line character at the end of file

(new-line-at-end-of-file)

rust-plugins/compress/pnpm-workspace.yaml

[error] 1-1: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-arm64-gnu
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-arm64-musl
  • GitHub Check: call-rust-build / Build and Upload Artifacts - win32-arm64-msvc
  • GitHub Check: call-rust-build / Build and Upload Artifacts - win32-ia32-msvc
  • GitHub Check: call-rust-build / Build and Upload Artifacts - darwin-x64
  • GitHub Check: call-rust-build / Build and Upload Artifacts - darwin-arm64
  • GitHub Check: call-rust-build / Build and Upload Artifacts - win32-x64-msvc
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-x64-musl
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-x64-gnu
🔇 Additional comments (48)
rust-plugins/compress/src/lib.rs (1)

91-96: Confirm safe parallel mutation.
Setting resource.emitted = true while traversing resources_map in parallel may require careful synchronization if resources_map can be accessed concurrently elsewhere. Make sure no data race can occur.

rust-plugins/compress/playground/farm.config.ts (1)

16-20: Revisit compression threshold and level.
A threshold of 2048 and a level of 11 could offer significant compression but also increase CPU usage. Consider verifying performance metrics to ensure these parameters are optimal for your application’s size and use case.

rust-plugins/compress/src/utils.rs (1)

90-96: Clarify extension naming for Deflate variants.

Both DeflateRaw and Deflate use the same extension "deflate", which might cause confusion. Consider using distinct extensions or documenting the rationale.

Please confirm if using the same extension for both Deflate variants is intentional and won't cause issues with content encoding headers in HTTP responses.

rust-plugins/compress/.cargo/config.toml (7)

2-4: Network Configuration Verification
The [net] section enables git-fetch-with-cli for Git operations via the CLI. Confirm that this option meets your network fetch needs.


5-9: Global Build Settings Review
The [build] section sets rustdocflags and a global rustflags for shared generics. This configuration looks appropriate for generating docs and optimizing generic code sharing.


10-12: Target-Specific Flags for x86_64 Linux
The [target.x86_64-unknown-linux-gnu] configuration applies the SSE2 feature flag and the shared generics flag. This configuration is clear and should improve performance on x86_64 Linux targets.


13-15: AArch64 Linux GNU Linker Configuration
The [target.aarch64-unknown-linux-gnu] section correctly defines the linker to use (aarch64-linux-gnu-gcc). No concerns here.


26-29: Windows MSVC (x86_64) Configuration
For [target.x86_64-pc-windows-msvc], the configuration specifies rust-lld as the linker with flags enforcing CRT static linking. This appears correct.


30-33: AArch64 Windows MSVC Configuration
Only a linker is specified for [target.aarch64-pc-windows-msvc]. If additional flags become necessary for this target in the future, consider adding them; otherwise, this minimal configuration is acceptable.


34-37: ARMv7 Linux GNUEABI Configuration
The [target.armv7-unknown-linux-gnueabi] section provides the appropriate linker and rustflags. This legacy target configuration meets standard requirements.

rust-plugins/compress/.github/workflows/ci.yaml (4)

1-6: Workflow Trigger and Naming
The workflow is named "Test Plugin" and is set to trigger on pull requests to the main branch. This configuration clearly targets CI validation of the plugin artifacts.


7-10: Chaining Build Workflows
The call-rust-build job references the shared build workflow (build.yaml), ensuring that the plugin build is executed prior to artifact testing.


29-33: Node.js Environment Setup
The workflow uses actions/setup-node@v3 with Node.js version 18.x. This step ensures a consistent Node.js environment for subsequent dependency installation and build steps.


35-36: Running Build Example in Playground
The final step navigates into the playground directory and runs dependency installation followed by a build. Verify that the playground is correctly configured and that its build script operates as expected.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 36-36: no new line character at the end of file

(new-line-at-end-of-file)

rust-plugins/compress/.github/workflows/release.yml (8)

1-6: Release Workflow Trigger and Naming
The release workflow is set to trigger on pushes to the main branch and is aptly named. The inclusion of concurrency helps avoid overlapping release runs.


7-8: Concurrency Configuration
Using a concurrency group based on the workflow and branch ensures isolated release runs. This design is effective in continuous deployment scenarios.


9-12: Pre-Release Build Dependency
The call-rust-build job is invoked prior to the release job, ensuring that the build artifacts are correctly prepared before proceeding with publishing.


13-17: Release Job Setup
The release job is configured with a dependency on the build job and is set to run on an Ubuntu environment. This clear delineation of steps supports a smooth release process.


18-20: Repository Checkout
The checkout step ensures that the repository’s code is available for the release process, which is a standard best practice.


21-25: Node.js Setup for Release
The workflow sets up Node.js (version 18.x) using the corresponding action, ensuring consistency with the build environment.


26-30: Artifact Download Step
Artifacts are downloaded from the build process into a temporary directory, aligning with the subsequent steps for artifact relocation.


38-42: Dependency Installation and Publishing
The workflow installs dependencies with PNPM and then configures npm authentication before running npm publish. Ensure that the NPM_TOKEN secret is correctly set and that robust error handling is in place for the publishing step.

rust-plugins/compress/.github/workflows/build.yaml (13)

1-3: Compress Plugin Build Workflow Initialization
This workflow, invoked via workflow_call, is well-named for its role in building and uploading Rust bindings for the compress plugin. The trigger and metadata are clear.


4-10: Job and Matrix Strategy Configuration
The matrix strategy is effectively used to run builds across multiple operating systems and ABI targets. Ensure that all matrix configurations reflect your supported environments accurately.


11-20: Matrix Entry: Linux x86_64-gnu Build
The build command for the linux-x64-gnu target sets necessary environment commands and invokes npm run build with clear target parameters.


21-29: Matrix Entry: Linux x86_64-musl Build
The configuration for the musl target is set up with careful environment resets and the appropriate build command. The formatting is consistent, which is beneficial for maintainability.


30-35: Matrix Entries for Windows and macOS Targets
For targets like win32-x64-msvc, darwin-x64, and darwin-arm64, the configurations omit custom build commands, implying defaults are acceptable. Confirm that these targets function properly with the default invocations.


35-44: Cross-compilation for Windows
The cross-compilation steps for win32-ia32-msvc and win32-arm64-msvc include custom build scripts that install cargo-xwin and configure environment variables. These detailed commands demonstrate careful consideration of cross-compilation challenges.


54-60: Matrix Entries for Linux ARM Targets
The ARM configurations for both MUSL and GNU targets include support for Zig (when enabled). Verify that the selected Zig version remains compatible with your toolchain.


72-77: Checkout and Caching Steps
The steps to checkout the repository using actions/checkout@v3 and caching rust artifacts with Swatinem/rust-cache@v2 are correctly implemented to speed up the build process.


77-81: Node.js Setup and Dependency Installation
Setting up Node.js (version 18) and installing PNPM dependencies with a frozen lockfile ensures a reproducible build environment.


82-83: Adding Rust Target
The conditional addition of the Rust target based on the matrix settings ensures that the build environment is correctly configured for each target architecture.


84-91: Cross-compilation Tools Setup
The steps to configure OSXCROSS and Zig are conditionally executed and support cross-compiling for macOS and specific ARM targets. This approach enhances the build’s portability.


92-98: Docker Build Command Update
The Docker build step now includes the --user 0:0 option on the root build workflow, which ensures proper file ownership and user context within the container. This is an important update for permission consistency.


99-107: Fallback Build and Artifact Upload Steps
The workflow provides conditional fallback build commands when Docker is not used, followed by detailed artifact upload steps for various plugin components. This ensures comprehensive coverage of build outputs.

.github/workflows/build.yaml (13)

1-3: Global Build Workflow Initialization
This top-level build workflow is designed for building Rust bindings and uploading artifacts. Its use of workflow_call highlights its role as a central component in the CI/CD pipeline.


4-10: Job and Matrix Strategy Setup
The overall job configuration and matrix strategy span multiple OS and ABI targets, with caching keyed by ABI. This granular approach is effective for maintaining build consistency across environments.


11-20: Linux x86_64-gnu Build Command
The build command for the GNU target correctly sets the safe directory, resets environment variables, and invokes pnpm with the proper target and ABI flags.


21-29: Linux x86_64-musl Build Command Formatting
The musl target’s build command is now correctly formatted without extraneous spaces. This small but important cleanup improves readability and consistency.


30-35: Matrix Entries for Windows and macOS Targets
The configurations for Windows and macOS targets are declared without extra build commands, implying that default procedures are adequate. Ensure that these targets are thoroughly tested in your CI environment.


36-44: Windows Cross-compilation Setup
Custom build steps for cross-compiling to Windows (both ia32 and arm64) are included, featuring environment variable setups and the installation of cargo-xwin. These details accommodate the complexity of Windows builds effectively.


54-62: Linux ARM Target Configuration with Zig
The ARM target configurations are clearly defined, and the optional support for Zig is a valuable addition for cross-compilation. Verify that Zig’s version remains consistent with your development needs.


64-69: Repository Checkout and Artifact Caching
Using a shallow checkout and caching Rust artifacts are both effective strategies for speeding up the build process while maintaining access to necessary source code details.

🧰 Tools
🪛 actionlint (1.7.4)

64-64: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


70-77: Node.js Environment and Dependency Management
The explicit setup of Node.js along with the installation of PNPM dependencies using a frozen lockfile guarantees reproducibility. This step adheres to best practices.

🧰 Tools
🪛 actionlint (1.7.4)

75-75: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


78-83: Adding Rust Target
The step to add the appropriate Rust target, when specified in the matrix, is conditionally executed and helps ensure the toolchain is fully prepared for the build.


84-91: Cross-Compilation Tool Setup
The conditional setup for OSXCROSS and Zig facilitates cross-compiling to macOS and ARM targets, respectively. This enhances the workflow’s versatility.

🧰 Tools
🪛 actionlint (1.7.4)

84-84: property "osxcross" is not defined in object type {abi: string; build: string; docker: string; os: string; target: string; zig: bool}

(expression)


92-98: Docker Build Command Update
The Docker run step now includes the --user 0:0 option, ensuring that the build run inside Docker uses the root user correctly. This update is critical for handling file permissions in containerized environments.


99-107: Fallback Build and Artifact Upload Steps
The later steps conditionally trigger alternative build commands when Docker is not used and comprehensively upload artifacts for various plugin components. This robust handling supports modular artifact management for releases.

Comment thread rust-plugins/compress/src/lib.rs
Comment thread rust-plugins/compress/scripts/index.js
@fu050409
Copy link
Copy Markdown
Member Author

@CCherry07 I have reverted the changes on CI checks, all changes in build.yml are format changes. PTAL on this PR.

Comment thread rust-plugins/compress/.cargo/config.toml Outdated
Comment thread rust-plugins/compress/.github/workflows/build.yaml Outdated
@CCherry07 CCherry07 merged commit d8d487b into main Feb 25, 2025
@fu050409 fu050409 deleted the feat/plugin-compress branch February 25, 2025 09:22
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.

3 participants