-
Notifications
You must be signed in to change notification settings - Fork 42
WIP Migrate zig compiler #413
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
Draft
lukewilliamboswell
wants to merge
36
commits into
main
Choose a base branch
from
migrate-zig-compiler
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
6ba1155
initial migration - support just Sdout and native target
lukewilliamboswell b1f3ce5
migrate Env and File effects, examples and tests
lukewilliamboswell 5779c84
migrate test script
lukewilliamboswell c2b3e05
migrate command line example and test
lukewilliamboswell 519d2af
add linux binaries libc and libunwind
lukewilliamboswell 4774794
add linux CRT files
lukewilliamboswell 08e14d4
migrate print-test
lukewilliamboswell e914e0a
migrate Dir functionality
lukewilliamboswell 41f75f5
migrate Path
lukewilliamboswell 3e6246a
update CI
lukewilliamboswell 4f62b3b
improve error handling, use open tag union
lukewilliamboswell 1fcef27
implement Random, Sleep, Utc modules
lukewilliamboswell 953ed5f
migrate Cmd
lukewilliamboswell 8c951de
fix some things
lukewilliamboswell 1b6f5c6
remove Path.type! due to opaque type ABI issue
lukewilliamboswell 49eb5d0
Restructure Cmd module and clean up orphaned tests
lukewilliamboswell 73ca5fa
Update Cmd module to use static dispatch for effects
lukewilliamboswell 41f87a4
Delete test-cmd-method-chaining
lukewilliamboswell 6db4a74
Make Cmd an opaque nominal type
lukewilliamboswell c1d5baf
remove nix for now
lukewilliamboswell 912b156
Fix command-line argument handling for static library builds
lukewilliamboswell 4179f25
Use c_char instead of i8 for cross-platform compatibility
lukewilliamboswell b919143
Fix SIGPIPE error in release workflow on Linux
lukewilliamboswell f538094
Add explicit permissions blocks to CI workflows
lukewilliamboswell 28a376e
small CI improvements
Anton-4 188e1b5
same setup-zig version everywhere
Anton-4 c0d20d9
use flaky-retry action
Anton-4 8fd545b
Cargo.toml improvements
Anton-4 070b8b3
gitignore binary files without extension
Anton-4 8c1135c
bundle include THIRD_PARTY_LICENSES.md #417
Anton-4 43cdaf5
use commit for latest nightly
Anton-4 2b4c74f
use nightly roc
Anton-4 7532209
fix: print bundle.sh output before failing in CI
Anton-4 634720e
fix: use relative path for THIRD_PARTY_LICENSES.md in bundle
Anton-4 03e94ad
fix: copy THIRD_PARTY_LICENSES.md into platform dir for bundling
Anton-4 a2e0191
Add Tty and Locale modules (#418)
codegod100 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,226 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| release_tag: | ||
| description: 'Release tag (e.g., v0.1.0)' | ||
| required: true | ||
| type: string | ||
| pull_request: | ||
|
|
||
| # Ensure only one release workflow runs at a time | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| # Do not add permissions here! Configure them at the job level! | ||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| ZIG_VERSION: 0.15.2 | ||
|
|
||
| jobs: | ||
| build-and-bundle: | ||
| name: Build and Bundle Platform | ||
| runs-on: macos-15 # macOS can cross-compile to all targets | ||
| outputs: | ||
| bundle_filename: ${{ steps.bundle.outputs.bundle_filename }} | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Zig | ||
| uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # ratchet:mlugg/setup-zig@v2.0.5 | ||
| with: | ||
| version: ${{ env.ZIG_VERSION }} | ||
|
|
||
| - name: Install Rust cross-compilation targets | ||
| run: | | ||
| rustup target add x86_64-apple-darwin | ||
| rustup target add aarch64-apple-darwin | ||
| rustup target add x86_64-unknown-linux-musl | ||
| rustup target add aarch64-unknown-linux-musl | ||
|
|
||
| - name: Download Roc nightly | ||
| run: | | ||
| source ci/get_roc_nightly_url.sh | ||
| echo "Downloading $ROC_NIGHTLY_URL" | ||
| curl -fOL "$ROC_NIGHTLY_URL" | ||
| tar -xzf "$ROC_NIGHTLY_ARCHIVE" | ||
| ROC_DIR=$(ls -d roc_nightly-*/ | head -1) | ||
| echo "$(pwd)/${ROC_DIR}" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Build platform for all targets | ||
| run: ./build.sh --all | ||
|
|
||
| - name: Bundle platform | ||
| id: bundle | ||
| run: | | ||
| # Run bundle.sh and capture output (disable set -e to ensure output is printed) | ||
| set +e | ||
| BUNDLE_OUTPUT=$(./bundle.sh 2>&1) | ||
| EXIT_CODE=$? | ||
| set -e | ||
| echo "$BUNDLE_OUTPUT" | ||
| if [ $EXIT_CODE -ne 0 ]; then | ||
| echo "bundle.sh failed with exit code $EXIT_CODE" | ||
| exit $EXIT_CODE | ||
| fi | ||
|
|
||
| # Extract the tar.zst filename from "Created: /path/to/HASH.tar.zst" line | ||
| BUNDLE_PATH=$(echo "$BUNDLE_OUTPUT" | grep "^Created:" | awk '{print $2}') | ||
| BUNDLE_FILENAME=$(basename "$BUNDLE_PATH") | ||
|
|
||
| if [ -z "$BUNDLE_FILENAME" ]; then | ||
| echo "Error: Could not extract bundle filename from output" | ||
| echo "Bundle output was:" | ||
| echo "$BUNDLE_OUTPUT" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Bundle created: $BUNDLE_FILENAME" | ||
| echo "bundle_filename=$BUNDLE_FILENAME" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Upload bundle artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: platform-bundle | ||
| path: ${{ steps.bundle.outputs.bundle_filename }} | ||
| retention-days: 30 | ||
|
|
||
| test-bundle: | ||
| name: Test Bundle (${{ matrix.os }}) | ||
| needs: build-and-bundle | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - macos-15 # Apple Silicon | ||
| - macos-15-intel # Intel Mac | ||
| - ubuntu-22.04 # Linux x86_64 | ||
| - ubuntu-24.04-arm # Linux ARM64 | ||
| runs-on: ${{ matrix.os }} | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Zig | ||
| uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # ratchet:mlugg/setup-zig@v2.0.5 | ||
| with: | ||
| version: ${{ env.ZIG_VERSION }} | ||
|
|
||
| - name: Install expect (Ubuntu) | ||
| if: startsWith(matrix.os, 'ubuntu-') | ||
| run: sudo apt-get install -y expect | ||
|
|
||
| - name: Install expect (macOS) | ||
| if: startsWith(matrix.os, 'macos-') | ||
| run: brew install expect | ||
|
|
||
| - name: Download Roc nightly | ||
| run: | | ||
| source ci/get_roc_nightly_url.sh | ||
| echo "Downloading $ROC_NIGHTLY_URL" | ||
| curl -fOL "$ROC_NIGHTLY_URL" | ||
| tar -xzf "$ROC_NIGHTLY_ARCHIVE" | ||
| ROC_DIR=$(ls -d roc_nightly-*/ | head -1) | ||
| echo "$(pwd)/${ROC_DIR}" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Download bundle artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: platform-bundle | ||
|
|
||
| - name: Start HTTP server for bundle | ||
| run: | | ||
| # Start Python HTTP server in background on port 8000 | ||
| python3 -m http.server 8000 & | ||
| HTTP_SERVER_PID=$! | ||
| echo "HTTP_SERVER_PID=$HTTP_SERVER_PID" >> "$GITHUB_ENV" | ||
|
|
||
| # Wait for server to start | ||
| sleep 5 | ||
|
|
||
| # Verify server is running and bundle is accessible | ||
| if ! curl -f -I "http://localhost:8000/${{ needs.build-and-bundle.outputs.bundle_filename }}" > /dev/null 2>&1; then | ||
| echo "Error: HTTP server not accessible or bundle not found" | ||
| kill $HTTP_SERVER_PID || true | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "HTTP server started on port 8000 (PID: $HTTP_SERVER_PID)" | ||
| echo "Bundle accessible at: http://localhost:8000/${{ needs.build-and-bundle.outputs.bundle_filename }}" | ||
|
|
||
| - name: Modify examples to use bundled platform | ||
| run: | | ||
| # Replace local platform path with HTTP URL in all examples | ||
| for example in examples/*.roc; do | ||
| sed -i.bak "s|platform \"../platform/main.roc\"|platform \"http://localhost:8000/${{ needs.build-and-bundle.outputs.bundle_filename }}\"|g" "$example" | ||
| done | ||
|
|
||
| # Show diff for verification | ||
| echo "Modified examples:" | ||
| git diff examples/ | head -50 || true | ||
|
|
||
| # Skip native build since we're using the bundle | ||
| # The test script will detect all targets exist and use bundle testing | ||
| # Run all tests against the bundled platform | ||
| - name: Run tests with bundled platform | ||
| uses: roc-lang/roc/.github/actions/flaky-retry@main | ||
| with: | ||
| command: bash ci/all_tests.sh | ||
| error_string_contains: "error: unable" | ||
| env: | ||
| NO_BUILD: "1" | ||
|
|
||
| create-release: | ||
|
||
| name: Create GitHub Release | ||
| needs: [build-and-bundle, test-bundle] | ||
| runs-on: ubuntu-24.04 | ||
| # Only run on manual trigger | ||
| if: github.event_name == 'workflow_dispatch' | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Download bundle artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: platform-bundle | ||
|
|
||
| - name: Create GitHub Release | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| BUNDLE_FILE=$(ls *.tar.zst | head -1) | ||
|
|
||
| if [ -z "$BUNDLE_FILE" ]; then | ||
| echo "Error: No bundle file found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| source ci/get_roc_nightly_url.sh | ||
| ROC_COMMIT="$ROC_NIGHTLY_COMMIT" | ||
|
|
||
| # Create release with auto-generated notes | ||
| gh release create "${{ github.event.inputs.release_tag }}" \ | ||
| "$BUNDLE_FILE" \ | ||
| --title "${{ github.event.inputs.release_tag }}" \ | ||
| --generate-notes \ | ||
| --notes "Platform bundle built with Rust (stable) and Roc $ROC_COMMIT" | ||
|
|
||
| echo "Release created: ${{ github.event.inputs.release_tag }}" | ||
| echo "Bundle uploaded: $BUNDLE_FILE" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.