diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1e5998..889f594 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,10 @@ name: CI on: pull_request: - push: - branches: - - main + schedule: + # Run daily at 10 AM UTC, after the nightlies are typically published. + - cron: '0 10 * * *' + workflow_dispatch: # Allow manual triggering jobs: test: @@ -15,7 +16,7 @@ jobs: matrix: os: - ubuntu-24.04 - - macos-15 + - macos-15-intel - windows-2025 defaults: run: @@ -26,29 +27,17 @@ jobs: uses: actions/checkout@v4 - name: Install Zig - uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # ratchet:mlugg/setup-zig@v2.0.5 + uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # 2.2.1 with: - version: 0.15.2 + version: 0.16.0 use-cache: false - - name: Clone Roc source - run: | - ROC_COMMIT=$(python3 ci/get_roc_commit.py) - - git init roc-src - cd roc-src - git remote add origin https://github.com/roc-lang/roc - git fetch --depth 1 origin "$ROC_COMMIT" - git checkout --detach "$ROC_COMMIT" - - - name: Build Roc - uses: roc-lang/roc/.github/actions/flaky-retry@3d0fdde9ae6ffb5ef411f8c8c2fc2cdce22a74fe + - name: Install Roc + uses: roc-lang/setup-roc@bd311e2fb815a3d2255f7ee14a922f0b736e020b with: - command: cd roc-src && zig build roc - error_string_contains: "build.zig.zon" + # Installs the latest nightly from https://github.com/roc-lang/nightlies + version: nightly-new-compiler - - name: Add Roc to PATH - run: echo "$(pwd)/roc-src/zig-out/bin" >> "$GITHUB_PATH" - name: Run checks run: ci/all_tests.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 80fe682..fc4ce55 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,6 +9,9 @@ on: type: string pull_request: +env: + ZIG_VERSION: "0.16.0" + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -28,29 +31,16 @@ jobs: uses: actions/checkout@v4 - name: Install Zig - uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # ratchet:mlugg/setup-zig@v2.0.5 + uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # 2.2.1 with: - version: 0.15.2 + version: ${{ env.ZIG_VERSION }} use-cache: false - - name: Clone Roc source - run: | - ROC_COMMIT=$(python3 ci/get_roc_commit.py) - - git init roc-src - cd roc-src - git remote add origin https://github.com/roc-lang/roc - git fetch --depth 1 origin "$ROC_COMMIT" - git checkout --detach "$ROC_COMMIT" - - - name: Build Roc - uses: roc-lang/roc/.github/actions/flaky-retry@3d0fdde9ae6ffb5ef411f8c8c2fc2cdce22a74fe + - name: Install Roc + uses: roc-lang/setup-roc@bd311e2fb815a3d2255f7ee14a922f0b736e020b with: - command: cd roc-src && zig build roc - error_string_contains: "build.zig.zon" - - - name: Add Roc to PATH - run: echo "$(pwd)/roc-src/zig-out/bin" >> "$GITHUB_PATH" + # Installs the latest nightly from https://github.com/roc-lang/nightlies + version: nightly-new-compiler - name: Check format and package run: | @@ -90,7 +80,7 @@ jobs: matrix: os: - ubuntu-24.04 - - macos-15 + - macos-15-intel - windows-2025 defaults: run: @@ -101,29 +91,16 @@ jobs: uses: actions/checkout@v4 - name: Install Zig - uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # ratchet:mlugg/setup-zig@v2.0.5 + uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # 2.2.1 with: - version: 0.15.2 + version: ${{ env.ZIG_VERSION }} use-cache: false - - name: Clone Roc source - run: | - ROC_COMMIT=$(python3 ci/get_roc_commit.py) - - git init roc-src - cd roc-src - git remote add origin https://github.com/roc-lang/roc - git fetch --depth 1 origin "$ROC_COMMIT" - git checkout --detach "$ROC_COMMIT" - - - name: Build Roc - uses: roc-lang/roc/.github/actions/flaky-retry@3d0fdde9ae6ffb5ef411f8c8c2fc2cdce22a74fe + - name: Install Roc + uses: roc-lang/setup-roc@bd311e2fb815a3d2255f7ee14a922f0b736e020b with: - command: cd roc-src && zig build roc - error_string_contains: "build.zig.zon" - - - name: Add Roc to PATH - run: echo "$(pwd)/roc-src/zig-out/bin" >> "$GITHUB_PATH" + # Installs the latest nightly from https://github.com/roc-lang/nightlies + version: nightly-new-compiler - name: Download package bundle artifact uses: actions/download-artifact@v4 @@ -157,15 +134,21 @@ jobs: name: package-bundle path: dist + - name: Install Roc + uses: roc-lang/setup-roc@bd311e2fb815a3d2255f7ee14a922f0b736e020b + with: + # Installs the latest nightly from https://github.com/roc-lang/nightlies + version: nightly-new-compiler + - name: Create release env: GH_TOKEN: ${{ github.token }} run: | BUNDLE_FILE="dist/${{ needs.build-bundle.outputs.bundle_filename }}" - ROC_COMMIT=$(python3 ci/get_roc_commit.py | cut -c1-8) + ROC_VERSION=$(roc version) gh release create "${{ github.event.inputs.release_tag }}" \ "$BUNDLE_FILE" \ --title "${{ github.event.inputs.release_tag }}" \ --generate-notes \ - --notes "HTTP package bundle built with Roc $ROC_COMMIT." + --notes "HTTP package bundle built with Roc $ROC_VERSION." diff --git a/.gitignore b/.gitignore index 1d94ae6..a06d93c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ dist/ generated-docs/ roc-src/ __pycache__/ +.roc-http-tmp/ diff --git a/ci/ROC_COMMIT b/ci/ROC_COMMIT deleted file mode 100644 index 974673a..0000000 --- a/ci/ROC_COMMIT +++ /dev/null @@ -1 +0,0 @@ -cf21a1e29315caf430bea4e67269bb94e51b5b3d diff --git a/ci/all_tests.sh b/ci/all_tests.sh index d644579..5d2c41a 100755 --- a/ci/all_tests.sh +++ b/ci/all_tests.sh @@ -6,11 +6,10 @@ cd "$root_dir" if [ -n "${ROC_HTTP_TMPDIR:-}" ]; then tmp_base="$ROC_HTTP_TMPDIR" -elif [ -d /private/tmp ]; then - tmp_base=/private/tmp else - tmp_base="${TMPDIR:-/tmp}" + tmp_base="$root_dir/.roc-http-tmp" fi +export ROC_HTTP_TMPDIR="$tmp_base" tmp_dir="$tmp_base/roc-http-ci" docs_dir="$tmp_dir/docs" @@ -37,6 +36,14 @@ echo "" echo "Generating package docs..." roc docs package/main.roc --output="$docs_dir" +case "$(uname -s)" in + MINGW* | MSYS* | CYGWIN*) + echo "" + echo "Skipping package bundling on Windows." + exit 0 + ;; +esac + echo "" echo "Bundling package..." scripts/bundle.sh --output-dir "$bundle_dir" diff --git a/ci/get_roc_commit.py b/ci/get_roc_commit.py deleted file mode 100644 index a42ce1a..0000000 --- a/ci/get_roc_commit.py +++ /dev/null @@ -1,19 +0,0 @@ -import re -from pathlib import Path - - -def main() -> None: - commit_path = Path(__file__).resolve().parent / "ROC_COMMIT" - try: - commit = commit_path.read_text().strip() - except FileNotFoundError: - raise SystemExit(f"Missing ROC_COMMIT at {commit_path}") - - if not re.fullmatch(r"[0-9a-fA-F]{40}", commit): - raise SystemExit(f"Invalid commit hash in ROC_COMMIT: {commit!r}") - - print(commit) - - -if __name__ == "__main__": - main() diff --git a/ci/test_bundle_examples.py b/ci/test_bundle_examples.py index c950ed7..aa12902 100755 --- a/ci/test_bundle_examples.py +++ b/ci/test_bundle_examples.py @@ -85,17 +85,15 @@ def copy_examples_with_bundle_url(examples_dir: Path, bundle_url: str) -> list[P def run_example_checks(examples: list[Path]) -> None: - run(["roc", "fmt", "--check", str(examples[0].parent)]) - for example in examples: - run(["roc", "check", str(example), "--no-cache"]) + run(["roc", "check", example.name, "--no-cache"], cwd=example.parent) def run_example_apps(examples: list[Path]) -> None: for example in examples: if example.name == "tests.roc": continue - run(["roc", str(example), "--no-cache"]) + run(["roc", example.name, "--no-cache"], cwd=example.parent) def run_example_tests(examples: list[Path]) -> None: @@ -103,7 +101,7 @@ def run_example_tests(examples: list[Path]) -> None: if len(tests) != 1: raise SystemExit("Expected exactly one examples/tests.roc file") - run(["roc", "test", str(tests[0]), "--no-cache"]) + run(["roc", "test", tests[0].name, "--no-cache"], cwd=tests[0].parent) def build_and_run_examples(examples: list[Path], build_dir: Path) -> None: @@ -115,7 +113,7 @@ def build_and_run_examples(examples: list[Path], build_dir: Path) -> None: continue output = build_dir / f"{example.stem}{exe_suffix}" - run(["roc", "build", str(example), f"--output={output}", "--no-cache"]) + run(["roc", "build", example.name, f"--output={output}", "--no-cache"], cwd=example.parent) run([str(output)]) @@ -125,8 +123,9 @@ def main() -> None: parser.add_argument("--skip-build-run", action="store_true", help="Skip compiled example execution") args = parser.parse_args() - default_tmp = Path("/private/tmp") if Path("/private/tmp").exists() else Path(tempfile.gettempdir()) + default_tmp = ROOT / ".roc-http-tmp" tmp_parent = Path(os.environ.get("ROC_HTTP_TMPDIR", default_tmp)) + tmp_parent.mkdir(parents=True, exist_ok=True) with tempfile.TemporaryDirectory(prefix="roc-http-bundle-", dir=tmp_parent) as tmp: tmp_dir = Path(tmp) diff --git a/examples/body_bytes.roc b/examples/body_bytes.roc index 897685a..41c01ac 100644 --- a/examples/body_bytes.roc +++ b/examples/body_bytes.roc @@ -1,5 +1,5 @@ app [main!] { - pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst", + pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.9/8GdFEvQYS3TeAZxKvTzCLVdQiomweGtXcdZkXNDEeABq.tar.zst", http: "../package/main.roc", } diff --git a/examples/custom_method.roc b/examples/custom_method.roc index 1070b3e..c70f6d5 100644 --- a/examples/custom_method.roc +++ b/examples/custom_method.roc @@ -1,5 +1,5 @@ app [main!] { - pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst", + pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.9/8GdFEvQYS3TeAZxKvTzCLVdQiomweGtXcdZkXNDEeABq.tar.zst", http: "../package/main.roc", } diff --git a/examples/headers.roc b/examples/headers.roc index 2e4f4aa..80c2a9d 100644 --- a/examples/headers.roc +++ b/examples/headers.roc @@ -1,5 +1,5 @@ app [main!] { - pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst", + pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.9/8GdFEvQYS3TeAZxKvTzCLVdQiomweGtXcdZkXNDEeABq.tar.zst", http: "../package/main.roc", } @@ -11,7 +11,7 @@ header_to_str = |(name, value)| "${name}: ${value}" headers_to_str = |headers| - headers.map(header_to_str).join_with("\n") + Str.join_with(headers.map(header_to_str), "\n") main! = |_args| { request0 = Request.from_method(GET) diff --git a/examples/hello_request.roc b/examples/hello_request.roc index 7524219..c4595db 100644 --- a/examples/hello_request.roc +++ b/examples/hello_request.roc @@ -1,5 +1,5 @@ app [main!] { - pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst", + pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.9/8GdFEvQYS3TeAZxKvTzCLVdQiomweGtXcdZkXNDEeABq.tar.zst", http: "../package/main.roc", } diff --git a/examples/mock_send.roc b/examples/mock_send.roc index 61f7cef..8848429 100644 --- a/examples/mock_send.roc +++ b/examples/mock_send.roc @@ -1,5 +1,5 @@ app [main!] { - pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst", + pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.9/8GdFEvQYS3TeAZxKvTzCLVdQiomweGtXcdZkXNDEeABq.tar.zst", http: "../package/main.roc", } diff --git a/examples/response.roc b/examples/response.roc index ebe4071..c3ccce1 100644 --- a/examples/response.roc +++ b/examples/response.roc @@ -1,5 +1,5 @@ app [main!] { - pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst", + pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.9/8GdFEvQYS3TeAZxKvTzCLVdQiomweGtXcdZkXNDEeABq.tar.zst", http: "../package/main.roc", } diff --git a/examples/router.roc b/examples/router.roc index da93d06..2faee6f 100644 --- a/examples/router.roc +++ b/examples/router.roc @@ -1,5 +1,5 @@ app [main!] { - pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst", + pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.9/8GdFEvQYS3TeAZxKvTzCLVdQiomweGtXcdZkXNDEeABq.tar.zst", http: "../package/main.roc", } diff --git a/examples/tests.roc b/examples/tests.roc index 1639a10..1d17385 100644 --- a/examples/tests.roc +++ b/examples/tests.roc @@ -1,5 +1,5 @@ app [main!] { - pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst", + pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.9/8GdFEvQYS3TeAZxKvTzCLVdQiomweGtXcdZkXNDEeABq.tar.zst", http: "../package/main.roc", } diff --git a/examples/timeouts.roc b/examples/timeouts.roc index 86c739a..dcb9656 100644 --- a/examples/timeouts.roc +++ b/examples/timeouts.roc @@ -1,5 +1,5 @@ app [main!] { - pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst", + pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.9/8GdFEvQYS3TeAZxKvTzCLVdQiomweGtXcdZkXNDEeABq.tar.zst", http: "../package/main.roc", }