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

ARM builder image #373

Merged
merged 3 commits into from
Dec 5, 2024
Merged

ARM builder image #373

merged 3 commits into from
Dec 5, 2024

Conversation

jackalcooper
Copy link
Contributor

@jackalcooper jackalcooper commented Dec 4, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new job for building Docker images for ARM architecture in the release workflow.
    • Added instructions for building the project for ARM architecture in the contributing guide.
    • New Dockerfile created for setting up a Livebook environment.
  • Updates

    • Updated CI workflow to use Ubuntu 22.04 and a new Zig setup action.
    • Project version updated to 0.4.0, with a minor dependency version bump for kinda.
    • Enhanced dependency specifications for the mlir package.
    • Updated documentation to reflect the new version and enriched content regarding project goals and usage.
  • Bug Fixes

    • Ensured dependencies are fetched before precompilation in the build script.
    • Improved error handling with logging in the PassRunner module.

Copy link
Contributor

coderabbitai bot commented Dec 4, 2024

Walkthrough

The pull request includes several modifications across multiple files, primarily focusing on updates to development and CI configurations. It removes a development container configuration file, updates CI workflows for Elixir, introduces a new Dockerfile for a Livebook environment, and adjusts dependency specifications in various files. Notably, the project version is incremented, and new instructions for ARM architecture builds are added. The changes enhance the build and deployment processes while maintaining the overall structure of the project.

Changes

File Path Change Summary
.devcontainer/devcontainer.json Deleted file defining a C++ development container configuration with specific extensions and settings.
.github/workflows/elixir.yml Updated runs-on parameter to ubuntu-22.04 and changed Zig setup action from goto-bus-stop/setup-zig@v2 to mlugg/setup-zig@v1.
.github/workflows/release.yml Added a new branch trigger for release*, introduced arm_docker job for multi-architecture Docker builds, and updated Zig setup action.
CONTRIBUTING.md Added instructions for building the project for ARM architecture using Docker; minor formatting adjustments made.
dev-requirements.txt Updated mlir package version with more specific OS conditions.
docker/livebook.dockerfile Introduced a Dockerfile for Livebook, including system updates, package installations, and environment configurations.
mix.exs Updated project version to 0.4.0, changed precompiler URL, and bumped kinda dependency version.
native/Makefile Simplified assignment of LLVM_CONFIG_PATH variable.
scripts/build-for-publish.sh Added mix deps.get command to ensure dependencies are fetched before precompilation.
test/pass_test.exs Modified test to use @tag capture_log: true for log capturing; simplified exception assertion logic.
lib/beaver/pass_runner.ex Added logging functionality to error handling in handle_info/2, replacing exception propagation with logging.
CITATION.cff Updated version from 0.3.9 to 0.4.0.
README.md Updated package version in installation instructions to ~> 0.4.0, expanded project goals and functionality descriptions.
guides/your-first-beaver-compiler.livemd Updated Beaver library version from ~> 0.3 to ~> 0.4.

Possibly related PRs

🐰 In the garden, we dig and play,
With Docker and CI, we pave the way.
New builds for ARM, oh what a delight,
Dependencies fetched, everything feels right!
Version bumps and updates, a hop and a cheer,
In the world of code, we have nothing to fear! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 26eae45 and 6c18e29.

📒 Files selected for processing (8)
  • .github/workflows/release.yml (3 hunks)
  • CITATION.cff (1 hunks)
  • README.md (1 hunks)
  • docker/livebook.dockerfile (1 hunks)
  • guides/your-first-beaver-compiler.livemd (1 hunks)
  • lib/beaver/pass_runner.ex (2 hunks)
  • mix.exs (3 hunks)
  • test/pass_test.exs (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • CITATION.cff
  • guides/your-first-beaver-compiler.livemd
🚧 Files skipped from review as they are similar to previous changes (2)
  • docker/livebook.dockerfile
  • mix.exs
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/release.yml

176-176: 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)


181-181: 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)


189-189: shellcheck reported issue in this script: SC2086:info:1:55: Double quote to prevent globbing and word splitting

(shellcheck)


192-192: shellcheck reported issue in this script: SC2086:info:1:15: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (9)
README.md (1)

146-146: LGTM! Verify package availability.

The version update to "~> 0.4.0" is consistent with changes in other files.

Let's verify the package version is available:

✅ Verification successful

Version 0.4.0 is available in Hex.pm registry

The version update to "~> 0.4.0" in the README.md is valid as the package is published and available in the Hex.pm registry. Users will be able to install this version successfully.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the package version exists in Hex.pm registry
# Expected: Version 0.4.0 should be available

# Check available versions
curl -s https://hex.pm/api/packages/beaver | jq '.releases[].version'

Length of output: 355

lib/beaver/pass_runner.ex (2)

3-3: LGTM: Logger requirement added

The addition of Logger is appropriate for the new error handling implementation.


27-27: Verify error handling behavior change

The error handling has been modified to log errors instead of re-raising them. While logging is good for observability, swallowing exceptions might hide issues from upstream error handlers.

Let's verify the impact of this change:

Consider one of these approaches:

  1. Log and re-raise to maintain both logging and original error propagation
  2. Add structured logging with metadata for better error tracking
  3. Implement a supervision strategy if error recovery is intended
test/pass_test.exs (2)

34-34: LGTM: Appropriate test configuration

The capture_log: true tag is correctly added to capture and test the new logging behavior.


39-43: LGTM: Test case properly adapted

The test case has been appropriately modified to work with the new error handling behavior while maintaining the same verification of error conditions.

.github/workflows/release.yml (4)

7-7: LGTM: Branch trigger addition

The addition of release* branch trigger appropriately extends CI coverage to release branches.


136-152: LGTM: Well-structured matrix strategy

The matrix strategy effectively handles both ARM64 and AMD64 architectures with appropriate Zig binary URLs for each platform.


176-185: 🛠️ Refactor suggestion

Update checkout action versions

The checkout actions should be updated to the latest version.

-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.4)

176-176: 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)


181-181: 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)


189-192: ⚠️ Potential issue

Fix shell script quoting issues

The Docker run commands need proper quoting to prevent word splitting.

-        run: docker run --platform ${{ matrix.image.platform }} -v $PWD:/src -w /src/beaver jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest bash scripts/build-for-publish.sh
+        run: docker run --platform "${{ matrix.image.platform }}" -v "$PWD:/src" -w /src/beaver "jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest" bash scripts/build-for-publish.sh
-        run: docker run -v $PWD:/src -w /src/beaver jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest bash scripts/build-for-publish.sh
+        run: docker run -v "$PWD:/src" -w /src/beaver "jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest" bash scripts/build-for-publish.sh
🧰 Tools
🪛 actionlint (1.7.4)

189-189: shellcheck reported issue in this script: SC2086:info:1:55: Double quote to prevent globbing and word splitting

(shellcheck)


192-192: shellcheck reported issue in this script: SC2086:info:1:15: Double quote to prevent globbing and word splitting

(shellcheck)


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
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: 5

🧹 Outside diff range and nitpick comments (4)
docker/livebook.dockerfile (2)

2-8: Optimize package installation layer

The current package installation can be optimized to reduce image size.

Suggested improvement:

-RUN apt-get upgrade -y \
-  && apt-get update \
-  && apt-get install --no-install-recommends -y \
-    ninja-build \
-    python3-pip \
-  && apt-get clean \
-  && rm -rf /var/lib/apt/lists/*
+RUN apt-get update && \
+    apt-get install --no-install-recommends -y \
+      ninja-build \
+      python3-pip && \
+    apt-get clean && \
+    rm -rf /var/lib/apt/lists/*

Note: Removed apt-get upgrade as it's not typically needed in container builds.


1-31: Consider multi-stage build optimization

The current Dockerfile could be optimized further using multi-stage builds.

Consider:

  1. Separating build dependencies from runtime dependencies
  2. Using a slimmer base image for the final stage
  3. Adding proper Docker metadata labels
  4. Implementing health checks

Would you like me to provide a fully optimized version of the Dockerfile?

CONTRIBUTING.md (1)

107-110: Enhance ARM build documentation

While the Docker command is correct, the documentation could be improved by adding:

  1. Prerequisites (Docker installation, architecture requirements)
  2. Expected output and verification steps
  3. Troubleshooting guide for common issues

Consider adding this additional documentation:

 ### Linux
 
-Run docker image to build for ARM:
+#### Building for ARM
+
+Prerequisites:
+- Docker installed and running
+- Docker with ARM64 support enabled
+
+Steps:
 ```bash
 docker run -it --rm -v $PWD/..:/src -w /src/beaver --env MIX_BUILD_ROOT='_build/arm' jackalcooper/beaver-livebook-arm64:latest bash scripts/build-for-publish.sh

+Expected output:
+- Successful build will create artifacts in _build/arm directory
+- Generated files should include ARM-specific .so files
+
+Troubleshooting:
+- If Docker fails to pull the image, ensure you have ARM64 support enabled
+- If build fails, check the Docker container's architecture with uname -m


</blockquote></details>
<details>
<summary>.github/workflows/release.yml (1)</summary><blockquote>

`167-170`: **Consider adding Docker image versioning**

Currently only using 'latest' tag. Consider:
- Adding version tags based on releases
- Implementing a tag cleanup strategy

```diff
-          tags: jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest
+          tags: |
+            jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest
+            jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:${{ github.ref_name }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 98f4295 and 26eae45.

⛔ Files ignored due to path filters (1)
  • mix.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • .devcontainer/devcontainer.json (0 hunks)
  • .github/workflows/elixir.yml (2 hunks)
  • .github/workflows/release.yml (3 hunks)
  • CONTRIBUTING.md (1 hunks)
  • dev-requirements.txt (1 hunks)
  • docker/livebook.dockerfile (1 hunks)
  • mix.exs (3 hunks)
  • native/Makefile (1 hunks)
  • scripts/build-for-publish.sh (1 hunks)
💤 Files with no reviewable changes (1)
  • .devcontainer/devcontainer.json
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/release.yml

177-177: 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)


182-182: 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)


190-190: shellcheck reported issue in this script: SC2086:info:1:55: Double quote to prevent globbing and word splitting

(shellcheck)


193-193: shellcheck reported issue in this script: SC2086:info:1:15: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (9)
scripts/build-for-publish.sh (1)

4-4: LGTM! Verify dependency fetching behavior.

Adding mix deps.get before precompilation is a good practice to ensure all dependencies are available.

Let's verify this doesn't cause issues with cached dependencies:

✅ Verification successful

LGTM! Dependencies are properly managed

The mix deps.get addition is safe and follows best practices:

  • Dependencies are properly defined in mix.exs with specific version constraints
  • The mix.lock file ensures reproducible builds by locking exact versions
  • The script sets ELIXIR_MAKE_CACHE_DIR=. which properly handles cached dependencies
  • Dependencies are fetched before precompilation, which is the correct order
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any dependency-related issues reported in recent commits
git log -n 10 --grep="dep\|dependencies\|mix" --pretty=format:"%h %s"

Length of output: 0


Script:

#!/bin/bash
# Let's check the mix.lock file and mix.exs for dependency configuration
fd "mix\.(lock|exs)$" --exec cat {}

# Also check if there are any other build scripts that handle dependencies
fd "build.*\.sh$" --exec cat {}

Length of output: 7636

native/Makefile (1)

1-1: Verify LLVM config path availability on ARM

The simplified LLVM_CONFIG_PATH assignment assumes llvm-config is available in PATH. While this change makes the Makefile cleaner, we should ensure it works consistently across ARM environments.

Consider documenting the LLVM installation requirements for ARM builds in the README or CONTRIBUTING guide.

✅ Verification successful

LLVM config path change is safe and well-documented

The simplified LLVM_CONFIG_PATH assignment is appropriate because:

  1. The project provides clear installation instructions for LLVM/MLIR in CONTRIBUTING.md
  2. The Makefile retains the ability to override the path using ?= operator
  3. ARM builds are handled through documented Docker-based builds with proper environment setup

The change aligns with the project's documented build process and maintains compatibility across all platforms, including ARM.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if llvm-config is available and accessible in common paths

# Test 1: Check if llvm-config exists in standard paths
which llvm-config || echo "llvm-config not found in PATH"

# Test 2: Check llvm-config version and target architecture
llvm-config --version
llvm-config --host-target

Length of output: 440


Script:

#!/bin/bash
# Let's check the Makefile history and documentation for ARM-specific configurations
# and any existing LLVM-related documentation

# Check if there are any ARM-specific instructions in documentation
fd -t f "README|CONTRIBUTING|INSTALL" -X grep -i -l "arm\|aarch64\|llvm"

# Look for any ARM or LLVM related configuration in the Makefile
cat native/Makefile | grep -i "arm\|aarch64\|llvm"

# Check if there are any CI configurations that might handle ARM builds
fd ".github/workflows" -t f -X cat

Length of output: 1179


Script:

#!/bin/bash
# Let's check the content of README and CONTRIBUTING files for LLVM setup instructions
# and examine if there are any GitHub workflows

cat README.md CONTRIBUTING.md

# Check for workflow files with the correct fd syntax
fd . '.github/workflows'

Length of output: 16281

mix.exs (2)

7-7: Version bump aligns with ARM support feature

The increment to version 0.4.0 appropriately reflects the addition of ARM architecture support as a significant feature.


22-22: Verify ARM artifacts in precompiler URL

The updated precompiler URL points to new build artifacts. Let's verify the ARM-specific artifacts are available.

✅ Verification successful

ARM artifacts are available in the release

The release contains the necessary ARM artifacts:

  • beaver-nif-2.17-aarch64-apple-darwin-0.4.0.tar.gz (ARM for macOS)
  • beaver-nif-2.17-aarch64-linux-gnu-0.4.0.tar.gz (ARM for Linux)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify ARM artifacts existence in the new release

# Test: Check if ARM artifacts exist in the release
gh api \
  -H "Accept: application/vnd.github+json" \
  repos/beaver-lodge/beaver-prebuilt/releases/tags/2024-12-04-0908 | \
  jq -r '.assets[].name' | \
  grep -i "arm"

Length of output: 153


Script:

#!/bin/bash
# Let's first check what artifacts are actually available in the release
gh api \
  -H "Accept: application/vnd.github+json" \
  repos/beaver-lodge/beaver-prebuilt/releases/tags/2024-12-04-0908 | \
  jq -r '.assets[].name'

Length of output: 328

.github/workflows/elixir.yml (2)

37-46: LGTM: Matrix strategy updates look good

The matrix configuration changes make sense:

  • Pinning to Ubuntu 22.04 provides better stability than using latest
  • Adding OTP 27.0.1 with Elixir 1.17.2 ensures testing on newer versions

70-72: Verify the Zig action downgrade

The change from goto-bus-stop/setup-zig@v2 to mlugg/setup-zig@v1 appears to be a version downgrade.

✅ Verification successful

The action change appears to be well-maintained

The switch to mlugg/setup-zig@v1 is actually not concerning as both actions are actively maintained, with the new action having more recent commits (November 2024) compared to the previous one (September 2024). Let's verify the stability and usage of both actions.


The action change is appropriate and well-maintained

The switch to mlugg/setup-zig@v1 is a sound decision. Both actions are actively maintained, with mlugg/setup-zig showing:

  • More recent commits (November 2024)
  • Fewer open issues (6 vs 12)
  • Stable releases with v1.2.1 released in September 2024
  • Healthy community adoption (96 stars)

While it may appear as a downgrade from v2 to v1, the version numbers are independent between different repositories, and the actual implementation is what matters.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the new action version is actively maintained
gh api repos/mlugg/setup-zig/commits --jq '.[0].commit.committer.date'

# Compare with the old action
gh api repos/goto-bus-stop/setup-zig/commits --jq '.[0].commit.committer.date'

Length of output: 195


Script:

#!/bin/bash
# Check stars and open issues for both actions
echo "mlugg/setup-zig stats:"
gh api repos/mlugg/setup-zig --jq '[.stargazers_count, .open_issues_count]'

echo "goto-bus-stop/setup-zig stats:"
gh api repos/goto-bus-stop/setup-zig --jq '[.stargazers_count, .open_issues_count]'

# Check recent releases for mlugg/setup-zig
gh api repos/mlugg/setup-zig/releases --jq '.[0:2] | .[] | {tag_name, published_at}'

Length of output: 512

.github/workflows/release.yml (3)

7-7: LGTM: Added release branch trigger

Adding release* branch trigger is appropriate for handling release branches.


136-152: LGTM: Matrix strategy for multi-architecture builds

The matrix strategy for ARM64 and AMD64 builds is well-structured:

  • Proper platform specifications
  • Architecture-specific Zig binaries
  • Clear naming conventions with suffixes

154-158: Verify Docker Hub credentials usage

Ensure Docker Hub credentials are properly configured in repository secrets.

dev-requirements.txt Show resolved Hide resolved
docker/livebook.dockerfile Outdated Show resolved Hide resolved
docker/livebook.dockerfile Show resolved Hide resolved
.github/workflows/release.yml Show resolved Hide resolved
.github/workflows/release.yml Show resolved Hide resolved
@jackalcooper jackalcooper merged commit 3e9f6f8 into main Dec 5, 2024
16 checks passed
@jackalcooper jackalcooper deleted the release-0.4.0 branch December 5, 2024 12:27
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.

1 participant