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

fix(ci): fix multiplatform build #460

Merged

Conversation

COLDTURNIP
Copy link
Contributor

Fix multiplatform build

@COLDTURNIP COLDTURNIP requested a review from derekbit February 14, 2025 08:12
Copy link

coderabbitai bot commented Feb 14, 2025

Walkthrough

This pull request enhances multi-platform building support by modifying the GitHub Actions workflow to include steps for setting up QEMU and Docker Buildx, along with the declaration of a new environment variable for target platforms. Additionally, the Dockerfile and build scripts have been updated to replace hardcoded architecture values with dynamic detection using uname -m, allowing for the correct handling of both amd64 and arm64 architectures during the build and packaging processes.

Changes

File(s) Change Summary
.github/workflows/build.yml Added steps for QEMU (docker/setup-qemu-action@v3) and Docker Buildx (docker/setup-buildx-action@v3); defined TARGET_PLATFORMS for multi-arch builds.
Dockerfile.dapper Updated the DAPPER_ENV declaration to include the ARCHS variable, expanding the environment settings available in the container.
scripts/build, scripts/package Replaced hardcoded architecture arrays with dynamic detection using uname -m; updated variable usage (switched from archs/ARCH to ARCHS/BUILDERARCH) and improved directory creation.

Sequence Diagram(s)

sequenceDiagram
    participant CI as GitHub Actions Workflow
    participant QEMU as docker/setup-qemu-action@v3
    participant Buildx as docker/setup-buildx-action@v3
    participant Build as Build/Package Scripts

    CI->>QEMU: Execute QEMU setup step
    QEMU-->>CI: QEMU installed
    CI->>Buildx: Execute Docker Buildx setup step
    Buildx-->>CI: Buildx ready
    CI->>Build: Run build job with TARGET_PLATFORMS env variable
Loading
sequenceDiagram
    participant Script as Build Script
    participant System as Machine (uname -m)
    
    Script->>System: Query architecture via uname -m
    System-->>Script: Return architecture (e.g., amd64 or arm64)
    Script->>Script: Assign value to ARCHS/BUILDERARCH and proceed with build
Loading

Possibly related PRs

Suggested reviewers

  • innobead
  • yangchiu
  • PhanLe1010
  • shuo-wu
  • derekbit

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 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.

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c543bd7 and 90810b6.

📒 Files selected for processing (4)
  • .github/workflows/build.yml (2 hunks)
  • Dockerfile.dapper (1 hunks)
  • scripts/build (1 hunks)
  • scripts/package (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build binaries
  • GitHub Check: Summary
🔇 Additional comments (4)
scripts/build (1)

23-38: LGTM! Dynamic architecture detection looks good.

The implementation properly handles both environment variable override and runtime detection for supported architectures.

scripts/package (1)

30-40: LGTM! Architecture detection for Docker builds looks good.

The implementation properly handles architecture detection and integration with Docker buildx for multi-platform builds.

Dockerfile.dapper (1)

1-1:

✅ Verification successful

Verify golang version.

The base image specifies golang 1.23 which doesn't exist yet. The latest stable version is 1.22.


🌐 Web query:

What is the latest version of golang?

💡 Result:

The latest stable version of Go (Golang) as of February 2025 is Go 1.23, with its most recent minor revision being Go 1.23.6 released on February 4, 2025[5]. This release includes security fixes and bug patches across various components like the compiler and crypto/elliptic package[5].

Key details about recent releases:

  • Go 1.23 was initially released on August 13, 2024[2][4]
  • Subsequent minor updates addressed security vulnerabilities and bugs in:
    • Cryptographic packages (crypto/elliptic, crypto/x509)[5]
    • Network components (net/http)[5]
    • Toolchain improvements[5]

For installation, use:

go install golang.org/x/tools/gopls@latest

to get the latest language server tools compatible with Go 1.23[1]. The current release maintains compatibility with projects using Go versions back to at least Go 1.21 through automatic toolchain upgrades[1][3].

Citations:


Rewritten Review Comment

The Dockerfile now correctly references the latest stable Go version (1.23) as of February 2025, so there’s no issue with the base image. Additionally, exposing ARCHS to the build environment is properly implemented.

.github/workflows/build.yml (1)

75-93: LGTM! Multi-platform build setup looks good.

The implementation properly sets up QEMU and Docker buildx for multi-platform builds, targeting both amd64 and arm64 architectures.

@COLDTURNIP COLDTURNIP force-pushed the feat-fix_multiplatform_for_secure_build branch from 90810b6 to 1f865d3 Compare February 14, 2025 08:21
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: 0

🧹 Nitpick comments (1)
scripts/build (1)

23-38: Enhance error handling and documentation.

While the architecture detection logic is correct, consider these improvements:

  1. Add a comment documenting the supported architectures and expected format of ARCHS.
  2. Make the error message more helpful by listing supported architectures.

Apply this diff to improve the error message:

-        echo "$(uname -m): unsupported architecture"
+        echo "Error: $(uname -m) is not supported. Supported architectures: x86_64 (amd64), aarch64/arm64"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90810b6 and 1f865d3.

📒 Files selected for processing (4)
  • .github/workflows/build.yml (2 hunks)
  • Dockerfile.dapper (1 hunks)
  • scripts/build (1 hunks)
  • scripts/package (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/build.yml
  • Dockerfile.dapper
  • scripts/package
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build binaries
  • GitHub Check: Summary
🔇 Additional comments (1)
scripts/build (1)

39-41: LGTM! Build loop implementation is correct.

The build loop correctly:

  • Uses the new ARCHS variable
  • Sets appropriate GOARCH for each architecture
  • Maintains all necessary build flags

@derekbit derekbit merged commit 93428bf into longhorn:master Feb 14, 2025
9 checks passed
@COLDTURNIP COLDTURNIP deleted the feat-fix_multiplatform_for_secure_build branch February 14, 2025 09:05
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.

2 participants