Compare commits
13 Commits
a58028d063
...
v1.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef010b3c12 | ||
|
|
88336c869b | ||
|
|
f975f12553 | ||
|
|
54109136ab | ||
|
|
3e5ed611fe | ||
|
|
3085d3ce98 | ||
|
|
143db9c20e | ||
|
|
4f9dff66c1 | ||
|
|
fbe1eb3fc8 | ||
|
|
08f2abc60e | ||
|
|
65404a1883 | ||
|
|
f317a618b8 | ||
|
|
683de60603 |
1
.bazelversion
Normal file
1
.bazelversion
Normal file
@@ -0,0 +1 @@
|
||||
9.0.1
|
||||
47
.github/workflows/ci.yml
vendored
47
.github/workflows/ci.yml
vendored
@@ -25,17 +25,58 @@ jobs:
|
||||
phase8_target: windows
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
USE_BAZEL_VERSION: 9.0.0
|
||||
USE_BAZEL_VERSION: 9.0.1
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: bazel-contrib/setup-bazel@0.15.0
|
||||
- uses: bazel-contrib/setup-bazel@0.18.0
|
||||
with:
|
||||
bazelisk-cache: true
|
||||
repository-cache: true
|
||||
external-cache: true
|
||||
disk-cache: ci-${{ matrix.phase8_target }}
|
||||
cache-save: ${{ github.event_name != 'pull_request' }}
|
||||
- name: Install Nix
|
||||
if: runner.os != 'Windows'
|
||||
uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
- name: Restore and save Nix store cache
|
||||
if: runner.os != 'Windows'
|
||||
uses: nix-community/cache-nix-action@v7
|
||||
with:
|
||||
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
|
||||
restore-prefixes-first-match: nix-${{ runner.os }}-
|
||||
- name: Install flake dependencies
|
||||
if: runner.os != 'Windows'
|
||||
run: nix develop --accept-flake-config -c true
|
||||
- name: Set up Python
|
||||
if: runner.os == 'Windows'
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Provide python3 shim
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p "$RUNNER_TEMP/bin"
|
||||
cat >"$RUNNER_TEMP/bin/python3" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
exec python "$@"
|
||||
EOF
|
||||
chmod +x "$RUNNER_TEMP/bin/python3"
|
||||
echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"
|
||||
- name: Run tests (${{ matrix.phase8_target }})
|
||||
if: runner.os != 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Phase 8 target: ${{ matrix.phase8_target }}"
|
||||
bazel test //tests/...
|
||||
mapfile -t targets < <(./tests/ci_test/phase8_ci_targets.sh "${{ matrix.phase8_target }}")
|
||||
nix develop --accept-flake-config -c bazel test --test_output=errors "${targets[@]}"
|
||||
- name: Run tests (${{ matrix.phase8_target }})
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Phase 8 target: ${{ matrix.phase8_target }}"
|
||||
mapfile -t targets < <(./tests/ci_test/phase8_ci_targets.sh "${{ matrix.phase8_target }}")
|
||||
bazel test --test_output=errors "${targets[@]}"
|
||||
|
||||
4
.github/workflows/pages.yml
vendored
4
.github/workflows/pages.yml
vendored
@@ -23,14 +23,14 @@ jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
USE_BAZEL_VERSION: 9.0.0
|
||||
USE_BAZEL_VERSION: 9.0.1
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: bazel-contrib/setup-bazel@0.15.0
|
||||
- uses: bazel-contrib/setup-bazel@0.18.0
|
||||
with:
|
||||
bazelisk-cache: true
|
||||
repository-cache: true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module(
|
||||
name = "rules_bun",
|
||||
version = "1.0.0",
|
||||
version = "1.0.3",
|
||||
)
|
||||
|
||||
# Core ruleset dependencies.
|
||||
|
||||
15
MODULE.bazel.lock
generated
15
MODULE.bazel.lock
generated
@@ -34,8 +34,9 @@
|
||||
"https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9",
|
||||
"https://bcr.bazel.build/modules/bazel_features/1.30.0/MODULE.bazel": "a14b62d05969a293b80257e72e597c2da7f717e1e69fa8b339703ed6731bec87",
|
||||
"https://bcr.bazel.build/modules/bazel_features/1.33.0/MODULE.bazel": "8b8dc9d2a4c88609409c3191165bccec0e4cb044cd7a72ccbe826583303459f6",
|
||||
"https://bcr.bazel.build/modules/bazel_features/1.33.0/source.json": "13617db3930328c2cd2807a0f13d52ca870ac05f96db9668655113265147b2a6",
|
||||
"https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7",
|
||||
"https://bcr.bazel.build/modules/bazel_features/1.42.1/MODULE.bazel": "275a59b5406ff18c01739860aa70ad7ccb3cfb474579411decca11c93b951080",
|
||||
"https://bcr.bazel.build/modules/bazel_features/1.42.1/source.json": "fcd4396b2df85f64f2b3bb436ad870793ecf39180f1d796f913cc9276d355309",
|
||||
"https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a",
|
||||
"https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8",
|
||||
"https://bcr.bazel.build/modules/bazel_skylib/1.1.1/MODULE.bazel": "1add3e7d93ff2e6998f9e118022c84d163917d912f5afafb3058e3d2f1545b5e",
|
||||
@@ -51,8 +52,8 @@
|
||||
"https://bcr.bazel.build/modules/bazel_skylib/1.8.1/MODULE.bazel": "88ade7293becda963e0e3ea33e7d54d3425127e0a326e0d17da085a5f1f03ff6",
|
||||
"https://bcr.bazel.build/modules/bazel_skylib/1.8.2/MODULE.bazel": "69ad6927098316848b34a9142bcc975e018ba27f08c4ff403f50c1b6e646ca67",
|
||||
"https://bcr.bazel.build/modules/bazel_skylib/1.8.2/source.json": "34a3c8bcf233b835eb74be9d628899bb32999d3e0eadef1947a0a562a2b16ffb",
|
||||
"https://bcr.bazel.build/modules/buildozer/8.2.1/MODULE.bazel": "61e9433c574c2bd9519cad7fa66b9c1d2b8e8d5f3ae5d6528a2c2d26e68d874d",
|
||||
"https://bcr.bazel.build/modules/buildozer/8.2.1/source.json": "7c33f6a26ee0216f85544b4bca5e9044579e0219b6898dd653f5fb449cf2e484",
|
||||
"https://bcr.bazel.build/modules/buildozer/8.5.1/MODULE.bazel": "a35d9561b3fc5b18797c330793e99e3b834a473d5fbd3d7d7634aafc9bdb6f8f",
|
||||
"https://bcr.bazel.build/modules/buildozer/8.5.1/source.json": "e3386e6ff4529f2442800dee47ad28d3e6487f36a1f75ae39ae56c70f0cd2fbd",
|
||||
"https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb",
|
||||
"https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4",
|
||||
"https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6",
|
||||
@@ -112,8 +113,8 @@
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.1.5/MODULE.bazel": "88dfc9361e8b5ae1008ac38f7cdfd45ad738e4fa676a3ad67d19204f045a1fd8",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.14/MODULE.bazel": "353c99ed148887ee89c54a17d4100ae7e7e436593d104b668476019023b58df8",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.14/source.json": "55d0a4587c5592fad350f6e698530f4faf0e7dd15e69d43f8d87e220c78bea54",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.17/MODULE.bazel": "1849602c86cb60da8613d2de887f9566a6d354a6df6d7009f9d04a14402f9a84",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.17/source.json": "3832f45d145354049137c0090df04629d9c2b5493dc5c2bf46f1834040133a07",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642",
|
||||
"https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6",
|
||||
"https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8",
|
||||
@@ -193,7 +194,7 @@
|
||||
"//bun:extensions.bzl%bun": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "314UOH4dQIGBHGpxCwA7yzI++E2J3bjIc20m5MZhM7U=",
|
||||
"usagesDigest": "F7vNx1FkssnJKNa2AZDuwHKkH7+IjJNX42lRAaJhhKE=",
|
||||
"usagesDigest": "prFfUGEBfgU9euYPzwB9Wux0cLYR+2MKCz+nUIyHYkI=",
|
||||
"recordedInputs": [
|
||||
"REPO_MAPPING:,bazel_tools bazel_tools"
|
||||
],
|
||||
@@ -284,7 +285,7 @@
|
||||
"//bun:extensions.bzl%bun_install": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "314UOH4dQIGBHGpxCwA7yzI++E2J3bjIc20m5MZhM7U=",
|
||||
"usagesDigest": "5mKuORKUFhw+/OMHQF0I8Ngq0GV2eqMaOTDmyqaQa8M=",
|
||||
"usagesDigest": "rhYKu+vVZOHFMZV+ai/X42v6prfhsLITQYyLZaCnX+g=",
|
||||
"recordedInputs": [
|
||||
"REPO_MAPPING:,bazel_tools bazel_tools"
|
||||
],
|
||||
|
||||
13
README.md
13
README.md
@@ -66,7 +66,7 @@ Strict defaults are enabled by default:
|
||||
|
||||
- `bun_install` skips lifecycle scripts unless `ignore_scripts = False`
|
||||
- `bun_build`, `bun_bundle`, `bun_compile`, and `bun_test` require `install_mode = "disable"`
|
||||
- Runtime launchers do not inherit the host `PATH` unless `inherit_host_path = True`
|
||||
- Runtime launchers stage hermetic `bun`, `bunx`, and `node` commands on `PATH` and do not inherit the host `PATH` unless `inherit_host_path = True`
|
||||
|
||||
To refresh generated rule docs:
|
||||
|
||||
@@ -80,7 +80,7 @@ Release announcements should provide a copy-pasteable module snippet in the
|
||||
standard ruleset form:
|
||||
|
||||
```starlark
|
||||
bazel_dep(name = "rules_bun", version = "1.0.0")
|
||||
bazel_dep(name = "rules_bun", version = "1.0.3")
|
||||
```
|
||||
|
||||
Then add the Bun repositories and register the toolchains in `MODULE.bazel`:
|
||||
@@ -218,10 +218,11 @@ bun_script(
|
||||
)
|
||||
```
|
||||
|
||||
When `node_modules` is provided, executables from `node_modules/.bin` are added
|
||||
to the runtime `PATH`. The host `PATH` is not inherited unless
|
||||
`inherit_host_path = True`. This label typically comes from `bun_install`,
|
||||
which still produces a standard `node_modules/` directory.
|
||||
Launcher-based runtime rules stage hermetic `bun`, `bunx`, and `node`
|
||||
commands on `PATH`. When `node_modules` is provided, executables from
|
||||
`node_modules/.bin` are also added to the runtime `PATH`. The host `PATH` is
|
||||
not inherited unless `inherit_host_path = True`. This label typically comes
|
||||
from `bun_install`, which still produces a standard `node_modules/` directory.
|
||||
|
||||
### `bun_build` and `bun_compile`
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ Public API surface for Bun Bazel rules.
|
||||
Strict defaults:
|
||||
|
||||
- `bun_build`, `bun_bundle`, `bun_compile`, and `bun_test` require `install_mode = "disable"`
|
||||
- Runtime launchers do not inherit the host `PATH` unless `inherit_host_path = True`
|
||||
- Runtime launchers stage hermetic `bun`, `bunx`, and `node` commands on `PATH` and do not inherit the host `PATH` unless `inherit_host_path = True`
|
||||
|
||||
<a id="bun_binary"></a>
|
||||
|
||||
@@ -41,7 +41,7 @@ Use this rule for non-test scripts and CLIs that should run via `bazel run`.
|
||||
| <a id="bun_binary-entry_point"></a>entry_point | Path to the main JS/TS file to execute. | <a href="https://bazel.build/concepts/labels">Label</a> | required | |
|
||||
| <a id="bun_binary-env_files"></a>env_files | Additional environment files loaded with `--env-file`. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
|
||||
| <a id="bun_binary-install_mode"></a>install_mode | Whether Bun may auto-install missing packages at runtime. Non-`disable` values are runtime opt-ins and are not hermetic. | String | optional | `"disable"` |
|
||||
| <a id="bun_binary-inherit_host_path"></a>inherit_host_path | If true, appends the host PATH after staged `node_modules/.bin` entries at runtime. | Boolean | optional | `False` |
|
||||
| <a id="bun_binary-inherit_host_path"></a>inherit_host_path | If true, appends the host PATH after the staged Bun runtime tool bin and `node_modules/.bin` entries at runtime. | Boolean | optional | `False` |
|
||||
| <a id="bun_binary-no_env_file"></a>no_env_file | If true, disables Bun's automatic `.env` loading. | Boolean | optional | `False` |
|
||||
| <a id="bun_binary-node_modules"></a>node_modules | Optional label providing package files from a `node_modules` tree, typically produced by `bun_install`, in runfiles. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
|
||||
| <a id="bun_binary-preload"></a>preload | Modules to preload with `--preload` before running the entry point. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
|
||||
@@ -265,7 +265,7 @@ watch/HMR plus optional full restarts on selected file changes.
|
||||
| <a id="bun_dev-entry_point"></a>entry_point | Path to the main JS/TS file to execute in dev mode. | <a href="https://bazel.build/concepts/labels">Label</a> | required | |
|
||||
| <a id="bun_dev-env_files"></a>env_files | Additional environment files loaded with `--env-file`. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
|
||||
| <a id="bun_dev-install_mode"></a>install_mode | Whether Bun may auto-install missing packages in dev mode. This is a local workflow helper, not a hermetic execution surface. | String | optional | `"disable"` |
|
||||
| <a id="bun_dev-inherit_host_path"></a>inherit_host_path | If true, appends the host PATH after staged `node_modules/.bin` entries at runtime. | Boolean | optional | `False` |
|
||||
| <a id="bun_dev-inherit_host_path"></a>inherit_host_path | If true, appends the host PATH after the staged Bun runtime tool bin and `node_modules/.bin` entries at runtime. | Boolean | optional | `False` |
|
||||
| <a id="bun_dev-no_clear_screen"></a>no_clear_screen | If true, disables terminal clearing on Bun reloads. | Boolean | optional | `False` |
|
||||
| <a id="bun_dev-no_env_file"></a>no_env_file | If true, disables Bun's automatic `.env` loading. | Boolean | optional | `False` |
|
||||
| <a id="bun_dev-node_modules"></a>node_modules | Optional label providing package files from a `node_modules` tree, typically produced by `bun_install`, in runfiles. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
|
||||
@@ -295,7 +295,7 @@ Use this rule to expose existing package scripts such as `dev`, `build`, or
|
||||
`check` via `bazel run` without adding wrapper shell scripts. This is a good fit
|
||||
for Vite-style workflows, where scripts like `vite dev` or `vite build` are
|
||||
declared in `package.json` and expect to run from the package directory with
|
||||
`node_modules/.bin` available on `PATH`.
|
||||
the staged Bun runtime tool bin and `node_modules/.bin` available on `PATH`.
|
||||
|
||||
**ATTRIBUTES**
|
||||
|
||||
@@ -309,10 +309,10 @@ declared in `package.json` and expect to run from the package directory with
|
||||
| <a id="bun_script-execution_mode"></a>execution_mode | How Bun should execute matching workspace scripts. | String | optional | `"single"` |
|
||||
| <a id="bun_script-filters"></a>filters | Workspace package filters passed via repeated `--filter` flags. | List of strings | optional | `[]` |
|
||||
| <a id="bun_script-install_mode"></a>install_mode | Whether Bun may auto-install missing packages while running the script. This is a local workflow helper, not a hermetic execution surface. | String | optional | `"disable"` |
|
||||
| <a id="bun_script-inherit_host_path"></a>inherit_host_path | If true, appends the host PATH after staged `node_modules/.bin` entries at runtime. | Boolean | optional | `False` |
|
||||
| <a id="bun_script-inherit_host_path"></a>inherit_host_path | If true, appends the host PATH after the staged Bun runtime tool bin and `node_modules/.bin` entries at runtime. | Boolean | optional | `False` |
|
||||
| <a id="bun_script-no_env_file"></a>no_env_file | If true, disables Bun's automatic `.env` loading. | Boolean | optional | `False` |
|
||||
| <a id="bun_script-no_exit_on_error"></a>no_exit_on_error | If true, Bun keeps running other workspace scripts when one fails. | Boolean | optional | `False` |
|
||||
| <a id="bun_script-node_modules"></a>node_modules | Optional label providing package files from a `node_modules` tree, typically produced by `bun_install`, in runfiles. Executables from `node_modules/.bin` are added to `PATH`, which is useful for scripts such as `vite`. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
|
||||
| <a id="bun_script-node_modules"></a>node_modules | Optional label providing package files from a `node_modules` tree, typically produced by `bun_install`, in runfiles. The staged Bun runtime tool bin and executables from `node_modules/.bin` are added to `PATH`, which is useful for scripts such as `vite`. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
|
||||
| <a id="bun_script-package_json"></a>package_json | Label of the `package.json` file containing the named script. | <a href="https://bazel.build/concepts/labels">Label</a> | required | |
|
||||
| <a id="bun_script-preload"></a>preload | Modules to preload with `--preload` before running the script. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
|
||||
| <a id="bun_script-run_flags"></a>run_flags | Additional raw flags forwarded to `bun run` before the script name. | List of strings | optional | `[]` |
|
||||
@@ -356,7 +356,7 @@ Supports Bazel test filtering (`--test_filter`) and coverage integration.
|
||||
| <a id="bun_test-coverage_reporters"></a>coverage_reporters | Repeated Bun coverage reporters such as `text` or `lcov`. | List of strings | optional | `[]` |
|
||||
| <a id="bun_test-env_files"></a>env_files | Additional environment files loaded with `--env-file`. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
|
||||
| <a id="bun_test-install_mode"></a>install_mode | Whether Bun may auto-install missing packages while testing. Hermetic tests require `\"disable\"`, and other values are rejected. | String | optional | `"disable"` |
|
||||
| <a id="bun_test-inherit_host_path"></a>inherit_host_path | If true, appends the host PATH after staged `node_modules/.bin` entries at runtime. | Boolean | optional | `False` |
|
||||
| <a id="bun_test-inherit_host_path"></a>inherit_host_path | If true, appends the host PATH after the staged Bun runtime tool bin and `node_modules/.bin` entries at runtime. | Boolean | optional | `False` |
|
||||
| <a id="bun_test-max_concurrency"></a>max_concurrency | Optional maximum number of concurrent tests. | Integer | optional | `0` |
|
||||
| <a id="bun_test-no_env_file"></a>no_env_file | If true, disables Bun's automatic `.env` loading. | Boolean | optional | `False` |
|
||||
| <a id="bun_test-node_modules"></a>node_modules | Optional label providing package files from a `node_modules` tree, typically produced by `bun_install`, in runfiles. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
|
||||
@@ -427,7 +427,7 @@ the provided tool with any default arguments.
|
||||
| <a id="js_run_devserver-package_dir_hint"></a>package_dir_hint | Optional package-relative directory hint when package_json is not supplied. | String | optional | `"."` |
|
||||
| <a id="js_run_devserver-package_json"></a>package_json | Optional package.json used to resolve the package working directory. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
|
||||
| <a id="js_run_devserver-tool"></a>tool | Executable target to launch as the dev server. | <a href="https://bazel.build/concepts/labels">Label</a> | required | |
|
||||
| <a id="js_run_devserver-inherit_host_path"></a>inherit_host_path | If true, appends the host PATH after staged `node_modules/.bin` entries at runtime. | Boolean | optional | `False` |
|
||||
| <a id="js_run_devserver-inherit_host_path"></a>inherit_host_path | If true, appends the host PATH after the staged Bun runtime tool bin and `node_modules/.bin` entries at runtime. | Boolean | optional | `False` |
|
||||
| <a id="js_run_devserver-working_dir"></a>working_dir | Working directory at runtime: Bazel runfiles workspace root or the resolved package directory. | String | optional | `"workspace"` |
|
||||
|
||||
|
||||
|
||||
17
flake.nix
17
flake.nix
@@ -15,7 +15,7 @@
|
||||
...
|
||||
}:
|
||||
let
|
||||
bazelVersion = "9.0.0";
|
||||
bazelVersion = "9.0.1";
|
||||
in
|
||||
repo-lib.lib.mkRepo {
|
||||
inherit self nixpkgs;
|
||||
@@ -108,12 +108,6 @@
|
||||
version.args = [ "--version" ];
|
||||
banner.color = "YELLOW";
|
||||
})
|
||||
(repo-lib.lib.tools.fromPackage {
|
||||
name = "Go";
|
||||
package = pkgs.go;
|
||||
version.args = [ "version" ];
|
||||
banner.color = "CYAN";
|
||||
})
|
||||
(repo-lib.lib.tools.fromPackage {
|
||||
name = "Bazel";
|
||||
package = bazel9;
|
||||
@@ -123,20 +117,21 @@
|
||||
];
|
||||
|
||||
shell.packages = [
|
||||
pkgs.gopls
|
||||
pkgs.gotools
|
||||
pkgs.bazel-buildtools
|
||||
pkgs.curl
|
||||
pkgs.python3
|
||||
self.packages.${system}.release
|
||||
];
|
||||
|
||||
checks.tests = {
|
||||
command = "bazel test //tests/...";
|
||||
command = "bazelisk test //tests/...";
|
||||
stage = "pre-push";
|
||||
passFilenames = false;
|
||||
runtimeInputs = [
|
||||
bazel9
|
||||
pkgs.bun
|
||||
pkgs.go
|
||||
pkgs.curl
|
||||
pkgs.python3
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -114,7 +114,7 @@ _BUN_BINARY_ATTRS.update({
|
||||
),
|
||||
"inherit_host_path": attr.bool(
|
||||
default = False,
|
||||
doc = "If true, appends the host PATH after staged node_modules/.bin entries at runtime.",
|
||||
doc = "If true, appends the host PATH after the staged Bun runtime tool bin and node_modules/.bin entries at runtime.",
|
||||
),
|
||||
})
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ _BUN_DEV_ATTRS.update({
|
||||
),
|
||||
"inherit_host_path": attr.bool(
|
||||
default = False,
|
||||
doc = "If true, appends the host PATH after staged node_modules/.bin entries at runtime.",
|
||||
doc = "If true, appends the host PATH after the staged Bun runtime tool bin and node_modules/.bin entries at runtime.",
|
||||
),
|
||||
})
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ _BUN_SCRIPT_ATTRS.update({
|
||||
doc = "Label of the `package.json` file containing the named script.",
|
||||
),
|
||||
"node_modules": attr.label(
|
||||
doc = "Optional label providing package files from a `node_modules` tree, typically produced by `bun_install`, in runfiles. Executables from `node_modules/.bin` are added to `PATH`, which is useful for scripts such as `vite`.",
|
||||
doc = "Optional label providing package files from a `node_modules` tree, typically produced by `bun_install`, in runfiles. The staged Bun runtime tool bin and executables from `node_modules/.bin` are added to `PATH`, which is useful for scripts such as `vite`.",
|
||||
),
|
||||
"data": attr.label_list(
|
||||
allow_files = True,
|
||||
@@ -148,7 +148,7 @@ _BUN_SCRIPT_ATTRS.update({
|
||||
),
|
||||
"inherit_host_path": attr.bool(
|
||||
default = False,
|
||||
doc = "If true, appends the host PATH after staged node_modules/.bin entries at runtime.",
|
||||
doc = "If true, appends the host PATH after the staged Bun runtime tool bin and node_modules/.bin entries at runtime.",
|
||||
),
|
||||
})
|
||||
|
||||
@@ -159,8 +159,9 @@ bun_script = rule(
|
||||
Use this rule to expose existing package scripts such as `dev`, `build`, or
|
||||
`check` via `bazel run` without adding wrapper shell scripts. This is a good fit
|
||||
for Vite-style workflows, where scripts like `vite dev` or `vite build` are
|
||||
declared in `package.json` and expect to run from the package directory. This
|
||||
is a local workflow helper rather than a hermetic build rule.
|
||||
declared in `package.json` and expect to run from the package directory with
|
||||
the staged Bun runtime tool bin and `node_modules/.bin` on `PATH`. This is a
|
||||
local workflow helper rather than a hermetic build rule.
|
||||
""",
|
||||
attrs = _BUN_SCRIPT_ATTRS,
|
||||
executable = True,
|
||||
|
||||
@@ -180,7 +180,7 @@ _BUN_TEST_ATTRS.update({
|
||||
),
|
||||
"inherit_host_path": attr.bool(
|
||||
default = False,
|
||||
doc = "If true, appends the host PATH after staged node_modules/.bin entries at runtime.",
|
||||
doc = "If true, appends the host PATH after the staged Bun runtime tool bin and node_modules/.bin entries at runtime.",
|
||||
),
|
||||
})
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ _JS_RUN_DEVSERVER_ATTRS.update({
|
||||
),
|
||||
"inherit_host_path": attr.bool(
|
||||
default = False,
|
||||
doc = "If true, appends the host PATH after staged node_modules/.bin entries at runtime.",
|
||||
doc = "If true, appends the host PATH after the staged Bun runtime tool bin and node_modules/.bin entries at runtime.",
|
||||
),
|
||||
})
|
||||
|
||||
|
||||
@@ -489,6 +489,31 @@ function materializeTreeContents(sourceRoot, destinationRoot) {
|
||||
}
|
||||
}
|
||||
|
||||
function stageRuntimeToolAlias(sourcePath, destinationPath, preferLinks) {
|
||||
removePath(destinationPath);
|
||||
ensureDir(dirname(destinationPath));
|
||||
if (preferLinks && !IS_WINDOWS) {
|
||||
symlinkSync(sourcePath, destinationPath);
|
||||
return;
|
||||
}
|
||||
copyPath(sourcePath, destinationPath);
|
||||
}
|
||||
|
||||
function stageRuntimeToolBin(runtimeWorkspace, bunPath, preferLinks) {
|
||||
const runtimeToolBin = join(runtimeWorkspace, ".rules_bun", "bin");
|
||||
ensureDir(runtimeToolBin);
|
||||
|
||||
const bunName = IS_WINDOWS ? "bun.exe" : "bun";
|
||||
const stagedBunPath = join(runtimeToolBin, bunName);
|
||||
materializePath(realpathSync(bunPath), stagedBunPath, preferLinks);
|
||||
|
||||
for (const aliasName of IS_WINDOWS ? ["bunx.exe", "node.exe"] : ["bunx", "node"]) {
|
||||
stageRuntimeToolAlias(stagedBunPath, join(runtimeToolBin, aliasName), preferLinks);
|
||||
}
|
||||
|
||||
return runtimeToolBin;
|
||||
}
|
||||
|
||||
function stageWorkspaceView(sourceRoot, destinationRoot, packageRelDir) {
|
||||
ensureDir(destinationRoot);
|
||||
const skippedEntry = firstPathComponent(packageRelDir);
|
||||
@@ -765,9 +790,19 @@ function mirrorInstallRepoWorkspaceNodeModules(
|
||||
}
|
||||
}
|
||||
|
||||
function buildRuntimePath(runtimeWorkspace, runtimePackageDir, runtimeInstallRoot, inheritHostPath) {
|
||||
function buildRuntimePath(
|
||||
runtimeToolBin,
|
||||
runtimeWorkspace,
|
||||
runtimePackageDir,
|
||||
runtimeInstallRoot,
|
||||
inheritHostPath,
|
||||
) {
|
||||
const entries = [];
|
||||
|
||||
if (existsSync(runtimeToolBin) && statSync(runtimeToolBin).isDirectory()) {
|
||||
entries.push(runtimeToolBin);
|
||||
}
|
||||
|
||||
const installBin = join(runtimeInstallRoot, "node_modules", ".bin");
|
||||
const packageBin = join(runtimePackageDir, "node_modules", ".bin");
|
||||
const workspaceBin = join(runtimeWorkspace, "node_modules", ".bin");
|
||||
@@ -915,9 +950,16 @@ function createRuntime(spec, runfiles) {
|
||||
materializePath(runtimeInstallNodeModules, runtimePackageNodeModules, preferLinks);
|
||||
}
|
||||
|
||||
const runtimeToolBin = stageRuntimeToolBin(
|
||||
runtimeWorkspace,
|
||||
runfiles.rlocation(spec.bun_short_path),
|
||||
preferLinks,
|
||||
);
|
||||
|
||||
const env = { ...process.env };
|
||||
const pathKey = pathEnvKey(env);
|
||||
const runtimePath = buildRuntimePath(
|
||||
runtimeToolBin,
|
||||
runtimeWorkspace,
|
||||
runtimePackageDir,
|
||||
runtimeInstallRoot,
|
||||
@@ -992,12 +1034,31 @@ function composeBunArgs(spec, runfiles, runtime) {
|
||||
return args;
|
||||
}
|
||||
|
||||
function spawnProcess(command, args, options) {
|
||||
return new Promise((resolvePromise, rejectPromise) => {
|
||||
const child = spawn(command, args, {
|
||||
function isWindowsBatchFile(command) {
|
||||
return IS_WINDOWS && /\.(cmd|bat)$/i.test(String(command || ""));
|
||||
}
|
||||
|
||||
function quoteForWindowsShell(command) {
|
||||
return `"${String(command).replace(/"/g, '""')}"`;
|
||||
}
|
||||
|
||||
function spawnChild(command, args, options) {
|
||||
const spawnOptions = {
|
||||
...options,
|
||||
stdio: "inherit",
|
||||
};
|
||||
if (isWindowsBatchFile(command)) {
|
||||
return spawn(quoteForWindowsShell(command), args, {
|
||||
...spawnOptions,
|
||||
shell: true,
|
||||
});
|
||||
}
|
||||
return spawn(command, args, spawnOptions);
|
||||
}
|
||||
|
||||
function spawnProcess(command, args, options) {
|
||||
return new Promise((resolvePromise, rejectPromise) => {
|
||||
const child = spawnChild(command, args, options);
|
||||
child.once("error", rejectPromise);
|
||||
child.once("exit", (code, signal) => {
|
||||
resolvePromise({ child, code, signal });
|
||||
@@ -1077,10 +1138,9 @@ async function runDevMode(spec, runfiles, userArgs) {
|
||||
currentRuntime = createRuntime(spec, runfiles);
|
||||
const bunPath = runfiles.rlocation(spec.bun_short_path);
|
||||
const bunArgs = [...composeBunArgs(spec, runfiles, currentRuntime), watchFlag, ...passthroughArgs];
|
||||
child = spawn(bunPath, bunArgs, {
|
||||
child = spawnChild(bunPath, bunArgs, {
|
||||
cwd: currentRuntime.runtimeExecDir,
|
||||
env: currentRuntime.env,
|
||||
stdio: "inherit",
|
||||
});
|
||||
exitPromise = new Promise((resolvePromise, rejectPromise) => {
|
||||
child.once("error", rejectPromise);
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
exports_files(["nested_bazel_test.sh"])
|
||||
|
||||
@@ -44,8 +44,8 @@ sh_test(
|
||||
size = "small",
|
||||
srcs = ["verify_data_shape.sh"],
|
||||
args = [
|
||||
"$(location //internal:bun_binary.bzl)",
|
||||
"$(location //tests/binary_test:BUILD.bazel)",
|
||||
"$(rlocationpath //internal:bun_binary.bzl)",
|
||||
"$(rlocationpath //tests/binary_test:BUILD.bazel)",
|
||||
],
|
||||
data = [
|
||||
"//internal:bun_binary.bzl",
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
const pathValue = process.env.PATH ?? "";
|
||||
|
||||
function commandSucceeds(command: string, args: string[]): boolean {
|
||||
const result = spawnSync(command, args, {
|
||||
encoding: "utf8",
|
||||
env: process.env,
|
||||
});
|
||||
return result.status === 0;
|
||||
}
|
||||
|
||||
console.log(JSON.stringify({
|
||||
hasHostSentinel: pathValue.includes("rules_bun_host_path_sentinel"),
|
||||
canRunBun: commandSucceeds("bun", ["-e", "process.exit(0)"]),
|
||||
canRunBunx: commandSucceeds("bunx", ["--version"]),
|
||||
canRunNode: commandSucceeds("node", ["-e", "process.exit(0)"]),
|
||||
}));
|
||||
|
||||
@@ -8,12 +8,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -8,12 +8,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
env PATH="rules_bun_host_path_sentinel:${PATH:-}" cmd.exe /c "${command}" | tr -d '\r'
|
||||
env PATH="rules_bun_host_path_sentinel:${PATH:-}" cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
env PATH="rules_bun_host_path_sentinel:${PATH:-}" "${launcher}" "$@"
|
||||
@@ -22,12 +17,12 @@ run_launcher() {
|
||||
default_output="$(run_launcher "${default_binary}")"
|
||||
inherit_output="$(run_launcher "${inherit_binary}")"
|
||||
|
||||
if [[ ${default_output} != '{"hasHostSentinel":false}' ]]; then
|
||||
if [[ ${default_output} != '{"hasHostSentinel":false,"canRunBun":true,"canRunBunx":true,"canRunNode":true}' ]]; then
|
||||
echo "Expected default launcher to hide host PATH, got: ${default_output}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${inherit_output} != '{"hasHostSentinel":true}' ]]; then
|
||||
if [[ ${inherit_output} != '{"hasHostSentinel":true,"canRunBun":true,"canRunBunx":true,"canRunNode":true}' ]]; then
|
||||
echo "Expected inherit_host_path launcher to preserve host PATH, got: ${inherit_output}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,8 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
rule_file="$1"
|
||||
build_file="$2"
|
||||
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
|
||||
RUNFILES_DIR="${TEST_SRCDIR}"
|
||||
fi
|
||||
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
if [[ -d "$0.runfiles" ]]; then
|
||||
RUNFILES_DIR="$0.runfiles"
|
||||
elif [[ -f "$0.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
|
||||
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
|
||||
fi
|
||||
fi
|
||||
|
||||
resolve_runfile() {
|
||||
local path="${1:-}"
|
||||
local candidate
|
||||
local resolved
|
||||
|
||||
if [[ -z ${path} ]]; then
|
||||
echo "Error: missing runfile path" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -e ${path} ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for candidate in \
|
||||
"${path}" \
|
||||
"${TEST_WORKSPACE:-}/${path}" \
|
||||
"_main/${path}"; do
|
||||
[[ -z ${candidate} ]] && continue
|
||||
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
|
||||
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
resolved="$(
|
||||
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
|
||||
"${RUNFILES_MANIFEST_FILE}"
|
||||
)"
|
||||
if [[ -n ${resolved} ]]; then
|
||||
printf '%s\n' "${resolved}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Error: unable to resolve runfile: ${path}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
rule_file="$(resolve_runfile "${1:-}")"
|
||||
build_file="$(resolve_runfile "${2:-}")"
|
||||
|
||||
grep -Eq 'extra_files = ctx\.files\.data \+ ctx\.files\.preload \+ ctx\.files\.env_files \+ \[bun_bin\]' "${rule_file}"
|
||||
grep -Eq 'name = "hello_js_with_data_bin"' "${build_file}"
|
||||
|
||||
@@ -60,7 +60,7 @@ sh_test(
|
||||
name = "bun_test_failing_suite_test",
|
||||
size = "small",
|
||||
srcs = ["failing_suite_shape.sh"],
|
||||
args = ["$(location //tests/bun_test_test:BUILD.bazel)"],
|
||||
args = ["$(rlocationpath //tests/bun_test_test:BUILD.bazel)"],
|
||||
data = ["//tests/bun_test_test:BUILD.bazel"],
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
build_file="$1"
|
||||
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
|
||||
RUNFILES_DIR="${TEST_SRCDIR}"
|
||||
fi
|
||||
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
if [[ -d "$0.runfiles" ]]; then
|
||||
RUNFILES_DIR="$0.runfiles"
|
||||
elif [[ -f "$0.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
|
||||
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
|
||||
fi
|
||||
fi
|
||||
|
||||
resolve_runfile() {
|
||||
local path="${1:-}"
|
||||
local candidate
|
||||
local resolved
|
||||
|
||||
if [[ -z ${path} ]]; then
|
||||
echo "Error: missing runfile path" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -e ${path} ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for candidate in \
|
||||
"${path}" \
|
||||
"${TEST_WORKSPACE:-}/${path}" \
|
||||
"_main/${path}"; do
|
||||
[[ -z ${candidate} ]] && continue
|
||||
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
|
||||
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
resolved="$(
|
||||
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
|
||||
"${RUNFILES_MANIFEST_FILE}"
|
||||
)"
|
||||
if [[ -n ${resolved} ]]; then
|
||||
printf '%s\n' "${resolved}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Error: unable to resolve runfile: ${path}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
build_file="$(resolve_runfile "${1:-}")"
|
||||
|
||||
grep -Eq 'name = "failing_suite"' "${build_file}"
|
||||
if grep -Eq 'tags = \["manual"\]' "${build_file}"; then
|
||||
|
||||
@@ -197,11 +197,16 @@ sh_test(
|
||||
name = "bundle_sourcemap_shape_test",
|
||||
size = "small",
|
||||
srcs = ["verify_sourcemap_shape.sh"],
|
||||
tags = [
|
||||
"exclusive",
|
||||
"no-sandbox",
|
||||
],
|
||||
data = [
|
||||
"BUILD.bazel",
|
||||
"//:repo_runtime_files",
|
||||
"//bun:repo_runtime_files",
|
||||
"//internal:repo_runtime_files",
|
||||
"//tests:nested_bazel_test.sh",
|
||||
"//tests/bundle_test/sourcemap_case:BUILD.bazel",
|
||||
"//tests/bundle_test/sourcemap_case:entry.ts",
|
||||
],
|
||||
@@ -236,6 +241,10 @@ sh_test(
|
||||
name = "bun_build_compile_flag_shape_test",
|
||||
size = "small",
|
||||
srcs = ["verify_flag_aquery.sh"],
|
||||
tags = [
|
||||
"exclusive",
|
||||
"no-sandbox",
|
||||
],
|
||||
data = [
|
||||
"BUILD.bazel",
|
||||
"cli.ts",
|
||||
@@ -246,6 +255,7 @@ sh_test(
|
||||
"//:repo_runtime_files",
|
||||
"//bun:repo_runtime_files",
|
||||
"//internal:repo_runtime_files",
|
||||
"//tests:nested_bazel_test.sh",
|
||||
],
|
||||
env_inherit = ["PATH"],
|
||||
)
|
||||
|
||||
@@ -1,49 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if command -v bazel >/dev/null 2>&1; then
|
||||
bazel_cmd=(bazel)
|
||||
elif command -v bazelisk >/dev/null 2>&1; then
|
||||
bazel_cmd=(bazelisk)
|
||||
else
|
||||
echo "bazel or bazelisk is required on PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find_workspace_root() {
|
||||
local candidate
|
||||
local module_path
|
||||
local script_dir
|
||||
|
||||
for candidate in \
|
||||
"${TEST_SRCDIR:-}/${TEST_WORKSPACE:-}" \
|
||||
"${TEST_SRCDIR:-}/_main"; do
|
||||
if [[ -n ${candidate} && -f "${candidate}/MODULE.bazel" ]]; then
|
||||
printf '%s\n' "${candidate}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n ${TEST_SRCDIR:-} ]]; then
|
||||
module_path="$(find "${TEST_SRCDIR}" -maxdepth 3 -name MODULE.bazel -print -quit 2>/dev/null || true)"
|
||||
if [[ -n ${module_path} ]]; then
|
||||
dirname "${module_path}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
candidate="$(cd "${script_dir}/../.." && pwd -P)"
|
||||
if [[ -f "${candidate}/MODULE.bazel" ]]; then
|
||||
printf '%s\n' "${candidate}"
|
||||
return 0
|
||||
fi
|
||||
# shellcheck source=../nested_bazel_test.sh
|
||||
source "${script_dir}/../nested_bazel_test.sh"
|
||||
setup_nested_bazel_cmd
|
||||
|
||||
echo "Unable to locate rules_bun workspace root" >&2
|
||||
exit 1
|
||||
rules_bun_root="$(find_nested_bazel_workspace_root "${BASH_SOURCE[0]}")"
|
||||
|
||||
cleanup() {
|
||||
local status="$1"
|
||||
trap - EXIT
|
||||
shutdown_nested_bazel_workspace "${rules_bun_root}"
|
||||
exit "${status}"
|
||||
}
|
||||
|
||||
rules_bun_root="$(find_workspace_root)"
|
||||
trap 'cleanup $?' EXIT
|
||||
|
||||
run_aquery() {
|
||||
local mnemonic="$1"
|
||||
|
||||
@@ -1,49 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if command -v bazel >/dev/null 2>&1; then
|
||||
bazel_cmd=(bazel)
|
||||
elif command -v bazelisk >/dev/null 2>&1; then
|
||||
bazel_cmd=(bazelisk)
|
||||
else
|
||||
echo "bazel or bazelisk is required on PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find_workspace_root() {
|
||||
local candidate
|
||||
local module_path
|
||||
local script_dir
|
||||
|
||||
for candidate in \
|
||||
"${TEST_SRCDIR:-}/${TEST_WORKSPACE:-}" \
|
||||
"${TEST_SRCDIR:-}/_main"; do
|
||||
if [[ -n ${candidate} && -f "${candidate}/MODULE.bazel" ]]; then
|
||||
printf '%s\n' "${candidate}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n ${TEST_SRCDIR:-} ]]; then
|
||||
module_path="$(find "${TEST_SRCDIR}" -maxdepth 3 -name MODULE.bazel -print -quit 2>/dev/null || true)"
|
||||
if [[ -n ${module_path} ]]; then
|
||||
dirname "${module_path}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
candidate="$(cd "${script_dir}/../.." && pwd -P)"
|
||||
if [[ -f "${candidate}/MODULE.bazel" ]]; then
|
||||
printf '%s\n' "${candidate}"
|
||||
return 0
|
||||
fi
|
||||
# shellcheck source=../nested_bazel_test.sh
|
||||
source "${script_dir}/../nested_bazel_test.sh"
|
||||
setup_nested_bazel_cmd
|
||||
|
||||
echo "Unable to locate rules_bun workspace root" >&2
|
||||
exit 1
|
||||
rules_bun_root="$(find_nested_bazel_workspace_root "${BASH_SOURCE[0]}")"
|
||||
|
||||
cleanup() {
|
||||
local status="$1"
|
||||
trap - EXIT
|
||||
shutdown_nested_bazel_workspace "${rules_bun_root}"
|
||||
exit "${status}"
|
||||
}
|
||||
|
||||
rules_bun_root="$(find_workspace_root)"
|
||||
trap 'cleanup $?' EXIT
|
||||
|
||||
bundle_output="$(
|
||||
cd "${rules_bun_root}" &&
|
||||
|
||||
@@ -4,10 +4,18 @@ sh_test(
|
||||
name = "phase8_ci_matrix_shape_test",
|
||||
size = "small",
|
||||
srcs = ["phase8_ci_matrix_shape_test.sh"],
|
||||
args = ["$(location //.github/workflows:ci.yml)"],
|
||||
args = ["$(rlocationpath //.github/workflows:ci.yml)"],
|
||||
data = ["//.github/workflows:ci.yml"],
|
||||
)
|
||||
|
||||
sh_test(
|
||||
name = "phase8_ci_targets_test",
|
||||
size = "small",
|
||||
srcs = ["phase8_ci_targets_test.sh"],
|
||||
args = ["$(rlocationpath :phase8_ci_targets.sh)"],
|
||||
data = [":phase8_ci_targets.sh"],
|
||||
)
|
||||
|
||||
sh_test(
|
||||
name = "native_wrapper_shape_test",
|
||||
size = "small",
|
||||
|
||||
@@ -1,7 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
workflow_file="$1"
|
||||
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
|
||||
RUNFILES_DIR="${TEST_SRCDIR}"
|
||||
fi
|
||||
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
if [[ -d "$0.runfiles" ]]; then
|
||||
RUNFILES_DIR="$0.runfiles"
|
||||
elif [[ -f "$0.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
|
||||
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
|
||||
fi
|
||||
fi
|
||||
|
||||
resolve_runfile() {
|
||||
local path="${1:-}"
|
||||
local candidate
|
||||
local resolved
|
||||
|
||||
if [[ -z ${path} ]]; then
|
||||
echo "Error: missing runfile path" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -e ${path} ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for candidate in \
|
||||
"${path}" \
|
||||
"${TEST_WORKSPACE:-}/${path}" \
|
||||
"_main/${path}"; do
|
||||
[[ -z ${candidate} ]] && continue
|
||||
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
|
||||
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
resolved="$(
|
||||
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
|
||||
"${RUNFILES_MANIFEST_FILE}"
|
||||
)"
|
||||
if [[ -n ${resolved} ]]; then
|
||||
printf '%s\n' "${resolved}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Error: unable to resolve runfile: ${path}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
workflow_file="$(resolve_runfile "${1:-}")"
|
||||
if [ -z "${workflow_file}" ]; then
|
||||
echo "Error: workflow file path required as first argument" >&2
|
||||
exit 1
|
||||
@@ -17,11 +73,22 @@ check_pattern() {
|
||||
}
|
||||
|
||||
check_pattern '^name:[[:space:]]+CI$' "missing workflow name CI"
|
||||
check_pattern 'USE_BAZEL_VERSION:[[:space:]]+9\.0\.0' "missing Bazel 9.0.0 pin"
|
||||
check_pattern 'USE_BAZEL_VERSION:[[:space:]]+9\.0\.1' "missing Bazel 9.0.1 pin"
|
||||
check_pattern 'os:[[:space:]]+ubuntu-latest' "missing ubuntu matrix entry"
|
||||
check_pattern 'phase8_target:[[:space:]]+linux-x64' "missing linux-x64 matrix target"
|
||||
check_pattern 'os:[[:space:]]+macos-14' "missing macos matrix entry"
|
||||
check_pattern 'phase8_target:[[:space:]]+darwin-arm64' "missing darwin-arm64 matrix target"
|
||||
check_pattern 'os:[[:space:]]+windows-latest' "missing windows matrix entry"
|
||||
check_pattern 'phase8_target:[[:space:]]+windows' "missing windows matrix target"
|
||||
|
||||
has_windows_os=0
|
||||
has_windows_target=0
|
||||
if grep -Eq 'os:[[:space:]]+windows-latest' "${workflow_file}"; then
|
||||
has_windows_os=1
|
||||
fi
|
||||
if grep -Eq 'phase8_target:[[:space:]]+windows' "${workflow_file}"; then
|
||||
has_windows_target=1
|
||||
fi
|
||||
if [[ ${has_windows_os} -ne ${has_windows_target} ]]; then
|
||||
echo "Error: windows matrix entry and windows phase8 target must be added or removed together" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "CI matrix shape checks passed"
|
||||
|
||||
27
tests/ci_test/phase8_ci_targets.sh
Executable file
27
tests/ci_test/phase8_ci_targets.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
phase8_target="${1:-}"
|
||||
if [[ -z ${phase8_target} ]]; then
|
||||
echo "Error: phase8 target required as first argument" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "${phase8_target}" in
|
||||
linux-x64 | darwin-arm64)
|
||||
printf '%s\n' "//tests/..."
|
||||
;;
|
||||
windows)
|
||||
printf '%s\n' \
|
||||
"//tests/binary_test/..." \
|
||||
"//tests/bun_test_test/..." \
|
||||
"//tests/ci_test/..." \
|
||||
"//tests/js_compat_test/..." \
|
||||
"//tests/script_test/..." \
|
||||
"//tests/toolchain_test/..."
|
||||
;;
|
||||
*)
|
||||
echo "Error: unsupported phase8 target: ${phase8_target}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
100
tests/ci_test/phase8_ci_targets_test.sh
Executable file
100
tests/ci_test/phase8_ci_targets_test.sh
Executable file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
|
||||
RUNFILES_DIR="${TEST_SRCDIR}"
|
||||
fi
|
||||
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
if [[ -d "$0.runfiles" ]]; then
|
||||
RUNFILES_DIR="$0.runfiles"
|
||||
elif [[ -f "$0.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
|
||||
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
|
||||
fi
|
||||
fi
|
||||
|
||||
resolve_runfile() {
|
||||
local path="${1:-}"
|
||||
local candidate
|
||||
local resolved
|
||||
|
||||
if [[ -z ${path} ]]; then
|
||||
echo "Error: missing runfile path" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -e ${path} ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for candidate in \
|
||||
"${path}" \
|
||||
"${TEST_WORKSPACE:-}/${path}" \
|
||||
"_main/${path}"; do
|
||||
[[ -z ${candidate} ]] && continue
|
||||
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
|
||||
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
resolved="$(
|
||||
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
|
||||
"${RUNFILES_MANIFEST_FILE}"
|
||||
)"
|
||||
if [[ -n ${resolved} ]]; then
|
||||
printf '%s\n' "${resolved}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Error: unable to resolve runfile: ${path}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
resolver="$(resolve_runfile "${1:-}")"
|
||||
if [[ -z ${resolver} ]]; then
|
||||
echo "Error: resolver path required as first argument" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
linux_targets="$("${resolver}" linux-x64)"
|
||||
if [[ ${linux_targets} != "//tests/..." ]]; then
|
||||
echo "Error: linux-x64 should resolve to //tests/..." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
darwin_targets="$("${resolver}" darwin-arm64)"
|
||||
if [[ ${darwin_targets} != "//tests/..." ]]; then
|
||||
echo "Error: darwin-arm64 should resolve to //tests/..." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
windows_targets="$("${resolver}" windows)"
|
||||
expected_windows_targets="$(
|
||||
cat <<'EOF'
|
||||
//tests/binary_test/...
|
||||
//tests/bun_test_test/...
|
||||
//tests/ci_test/...
|
||||
//tests/js_compat_test/...
|
||||
//tests/script_test/...
|
||||
//tests/toolchain_test/...
|
||||
EOF
|
||||
)"
|
||||
if [[ ${windows_targets} != "${expected_windows_targets}" ]]; then
|
||||
echo "Error: unexpected windows targets" >&2
|
||||
printf 'Expected:\n%s\nActual:\n%s\n' "${expected_windows_targets}" "${windows_targets}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if "${resolver}" unsupported >/dev/null 2>&1; then
|
||||
echo "Error: unsupported phase8 target should fail" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Phase 8 CI targets resolve correctly"
|
||||
@@ -32,6 +32,14 @@ config_setting(
|
||||
],
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "windows_x86_64",
|
||||
constraint_values = [
|
||||
"@platforms//os:windows",
|
||||
"@platforms//cpu:x86_64",
|
||||
],
|
||||
)
|
||||
|
||||
sh_test(
|
||||
name = "bun_install_clean_install_test",
|
||||
size = "small",
|
||||
@@ -41,6 +49,7 @@ sh_test(
|
||||
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
||||
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
||||
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
||||
":windows_x86_64": ["$(location @bun_windows_x64//:bun)"],
|
||||
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
||||
}),
|
||||
data = select({
|
||||
@@ -48,6 +57,7 @@ sh_test(
|
||||
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
||||
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
||||
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
||||
":windows_x86_64": ["@bun_windows_x64//:bun"],
|
||||
"//conditions:default": ["@bun_linux_x64//:bun"],
|
||||
}),
|
||||
)
|
||||
@@ -61,6 +71,7 @@ sh_test(
|
||||
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
||||
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
||||
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
||||
":windows_x86_64": ["$(location @bun_windows_x64//:bun)"],
|
||||
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
||||
}),
|
||||
data = select({
|
||||
@@ -68,6 +79,7 @@ sh_test(
|
||||
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
||||
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
||||
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
||||
":windows_x86_64": ["@bun_windows_x64//:bun"],
|
||||
"//conditions:default": ["@bun_linux_x64//:bun"],
|
||||
}),
|
||||
)
|
||||
@@ -97,6 +109,7 @@ sh_test(
|
||||
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
||||
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
||||
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
||||
":windows_x86_64": ["$(location @bun_windows_x64//:bun)"],
|
||||
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
||||
}),
|
||||
data = select({
|
||||
@@ -104,6 +117,7 @@ sh_test(
|
||||
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
||||
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
||||
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
||||
":windows_x86_64": ["@bun_windows_x64//:bun"],
|
||||
"//conditions:default": ["@bun_linux_x64//:bun"],
|
||||
}),
|
||||
)
|
||||
@@ -117,6 +131,7 @@ sh_test(
|
||||
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
||||
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
||||
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
||||
":windows_x86_64": ["$(location @bun_windows_x64//:bun)"],
|
||||
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
||||
}),
|
||||
data = select({
|
||||
@@ -124,18 +139,25 @@ sh_test(
|
||||
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
||||
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
||||
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
||||
":windows_x86_64": ["@bun_windows_x64//:bun"],
|
||||
"//conditions:default": ["@bun_linux_x64//:bun"],
|
||||
}),
|
||||
)
|
||||
|
||||
sh_test(
|
||||
name = "bun_install_workspace_parity_test",
|
||||
size = "large",
|
||||
srcs = ["workspace_parity.sh"],
|
||||
tags = [
|
||||
"exclusive",
|
||||
"no-sandbox",
|
||||
],
|
||||
args = select({
|
||||
":linux_x86_64": ["$(location @bun_linux_x64//:bun)"],
|
||||
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
||||
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
||||
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
||||
":windows_x86_64": ["$(location @bun_windows_x64//:bun)"],
|
||||
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
||||
}),
|
||||
data = select({
|
||||
@@ -143,11 +165,13 @@ sh_test(
|
||||
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
||||
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
||||
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
||||
":windows_x86_64": ["@bun_windows_x64//:bun"],
|
||||
"//conditions:default": ["@bun_linux_x64//:bun"],
|
||||
}) + [
|
||||
"//:repo_runtime_files",
|
||||
"//bun:repo_runtime_files",
|
||||
"//internal:repo_runtime_files",
|
||||
"//tests:nested_bazel_test.sh",
|
||||
],
|
||||
env_inherit = ["PATH"],
|
||||
)
|
||||
@@ -164,11 +188,16 @@ sh_test(
|
||||
name = "bun_install_repeatability_test",
|
||||
size = "small",
|
||||
srcs = ["repeatability.sh"],
|
||||
tags = [
|
||||
"exclusive",
|
||||
"no-sandbox",
|
||||
],
|
||||
args = select({
|
||||
":linux_x86_64": ["$(location @bun_linux_x64//:bun)"],
|
||||
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
||||
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
||||
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
||||
":windows_x86_64": ["$(location @bun_windows_x64//:bun)"],
|
||||
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
||||
}),
|
||||
data = select({
|
||||
@@ -176,11 +205,13 @@ sh_test(
|
||||
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
||||
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
||||
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
||||
":windows_x86_64": ["@bun_windows_x64//:bun"],
|
||||
"//conditions:default": ["@bun_linux_x64//:bun"],
|
||||
}) + [
|
||||
"//:repo_runtime_files",
|
||||
"//bun:repo_runtime_files",
|
||||
"//internal:repo_runtime_files",
|
||||
"//tests:nested_bazel_test.sh",
|
||||
],
|
||||
env_inherit = ["PATH"],
|
||||
)
|
||||
@@ -189,11 +220,16 @@ sh_test(
|
||||
name = "bun_install_lifecycle_scripts_test",
|
||||
size = "small",
|
||||
srcs = ["lifecycle_scripts.sh"],
|
||||
tags = [
|
||||
"exclusive",
|
||||
"no-sandbox",
|
||||
],
|
||||
args = select({
|
||||
":linux_x86_64": ["$(location @bun_linux_x64//:bun)"],
|
||||
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
||||
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
||||
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
||||
":windows_x86_64": ["$(location @bun_windows_x64//:bun)"],
|
||||
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
||||
}),
|
||||
data = select({
|
||||
@@ -201,11 +237,13 @@ sh_test(
|
||||
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
||||
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
||||
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
||||
":windows_x86_64": ["@bun_windows_x64//:bun"],
|
||||
"//conditions:default": ["@bun_linux_x64//:bun"],
|
||||
}) + [
|
||||
"//:repo_runtime_files",
|
||||
"//bun:repo_runtime_files",
|
||||
"//internal:repo_runtime_files",
|
||||
"//tests:nested_bazel_test.sh",
|
||||
],
|
||||
env_inherit = ["PATH"],
|
||||
)
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
# shellcheck source=../nested_bazel_test.sh
|
||||
source "${script_dir}/../nested_bazel_test.sh"
|
||||
setup_nested_bazel_cmd
|
||||
|
||||
bun_path="$1"
|
||||
|
||||
if command -v bazel >/dev/null 2>&1; then
|
||||
bazel_cmd=(bazel)
|
||||
elif command -v bazelisk >/dev/null 2>&1; then
|
||||
bazel_cmd=(bazelisk)
|
||||
else
|
||||
echo "bazel or bazelisk is required on PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
||||
rules_bun_root="$(find_nested_bazel_workspace_root "${BASH_SOURCE[0]}")"
|
||||
|
||||
workdir="$(mktemp -d)"
|
||||
trap 'rm -rf "${workdir}"' EXIT
|
||||
cleanup() {
|
||||
local status="$1"
|
||||
trap - EXIT
|
||||
shutdown_nested_bazel_workspace "${fixture_dir:-}"
|
||||
rm -rf "${workdir}"
|
||||
exit "${status}"
|
||||
}
|
||||
trap 'cleanup $?' EXIT
|
||||
|
||||
fixture_dir="${workdir}/fixture"
|
||||
mkdir -p "${fixture_dir}"
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
# shellcheck source=../nested_bazel_test.sh
|
||||
source "${script_dir}/../nested_bazel_test.sh"
|
||||
setup_nested_bazel_cmd
|
||||
|
||||
bun_path="$1"
|
||||
|
||||
if command -v bazel >/dev/null 2>&1; then
|
||||
bazel_cmd=(bazel)
|
||||
elif command -v bazelisk >/dev/null 2>&1; then
|
||||
bazel_cmd=(bazelisk)
|
||||
else
|
||||
echo "bazel or bazelisk is required on PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
||||
rules_bun_root="$(find_nested_bazel_workspace_root "${BASH_SOURCE[0]}")"
|
||||
|
||||
workdir="$(mktemp -d)"
|
||||
trap 'rm -rf "${workdir}"' EXIT
|
||||
cleanup() {
|
||||
local status="$1"
|
||||
trap - EXIT
|
||||
shutdown_nested_bazel_workspace "${fixture_dir:-}"
|
||||
rm -rf "${workdir}"
|
||||
exit "${status}"
|
||||
}
|
||||
trap 'cleanup $?' EXIT
|
||||
|
||||
fixture_dir="${workdir}/fixture"
|
||||
mkdir -p "${fixture_dir}"
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
# shellcheck source=../nested_bazel_test.sh
|
||||
source "${script_dir}/../nested_bazel_test.sh"
|
||||
setup_nested_bazel_cmd
|
||||
|
||||
bun_path="${1:-bun}"
|
||||
|
||||
if command -v bazel >/dev/null 2>&1; then
|
||||
bazel_cmd=(bazel)
|
||||
elif command -v bazelisk >/dev/null 2>&1; then
|
||||
bazel_cmd=(bazelisk)
|
||||
else
|
||||
echo "bazel or bazelisk is required on PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
||||
rules_bun_root="$(find_nested_bazel_workspace_root "${BASH_SOURCE[0]}")"
|
||||
|
||||
workdir="$(mktemp -d)"
|
||||
trap 'rm -rf "${workdir}"' EXIT
|
||||
cleanup() {
|
||||
local status="$1"
|
||||
trap - EXIT
|
||||
shutdown_nested_bazel_workspace "${bazel_dir:-}"
|
||||
rm -rf "${workdir}"
|
||||
exit "${status}"
|
||||
}
|
||||
trap 'cleanup $?' EXIT
|
||||
|
||||
fixture_dir="${workdir}/fixture"
|
||||
plain_dir="${workdir}/plain"
|
||||
|
||||
@@ -19,12 +19,7 @@ start_launcher() {
|
||||
local log_target="$2"
|
||||
shift 2
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" >"${log_target}" 2>&1 &
|
||||
cmd.exe /c call "${launcher}" "$@" >"${log_target}" 2>&1 &
|
||||
else
|
||||
"${launcher}" "$@" >"${log_target}" 2>&1 &
|
||||
fi
|
||||
|
||||
@@ -22,12 +22,7 @@ start_launcher() {
|
||||
local log_target="$2"
|
||||
shift 2
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" >"${log_target}" 2>&1 &
|
||||
cmd.exe /c call "${launcher}" "$@" >"${log_target}" 2>&1 &
|
||||
else
|
||||
"${launcher}" "$@" >"${log_target}" 2>&1 &
|
||||
fi
|
||||
|
||||
@@ -3,4 +3,17 @@ set -euo pipefail
|
||||
|
||||
workflow_file="$1"
|
||||
|
||||
grep -Eq 'bazel test //(tests/)?\.\.\.' "${workflow_file}"
|
||||
assert_contains() {
|
||||
local expected="$1"
|
||||
|
||||
if ! grep -Fq "${expected}" "${workflow_file}"; then
|
||||
echo "Error: expected workflow snippet not found:" >&2
|
||||
printf ' %s\n' "${expected}" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
assert_contains './tests/ci_test/phase8_ci_targets.sh "${{ matrix.phase8_target }}"'
|
||||
assert_contains 'mapfile -t targets < <(./tests/ci_test/phase8_ci_targets.sh "${{ matrix.phase8_target }}")'
|
||||
assert_contains 'nix develop --accept-flake-config -c bazel test --test_output=errors "${targets[@]}"'
|
||||
assert_contains 'bazel test --test_output=errors "${targets[@]}"'
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
108
tests/nested_bazel_test.sh
Normal file
108
tests/nested_bazel_test.sh
Normal file
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_nested_bazel_cmd() {
|
||||
local bazel_bin
|
||||
local nested_bazel_base
|
||||
local -a scrubbed_env_vars
|
||||
|
||||
if bazel_bin="$(command -v bazel 2>/dev/null)"; then
|
||||
:
|
||||
elif bazel_bin="$(command -v bazelisk 2>/dev/null)"; then
|
||||
:
|
||||
else
|
||||
echo "bazel or bazelisk is required on PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nested_bazel_base="${TEST_TMPDIR:-${TMPDIR:-/tmp}}/rules_bun_nested_bazel"
|
||||
mkdir -p "${nested_bazel_base}"
|
||||
nested_bazel_root="$(mktemp -d "${nested_bazel_base}/session.XXXXXX")"
|
||||
mkdir -p "${nested_bazel_root}/tmp"
|
||||
|
||||
scrubbed_env_vars=(
|
||||
BAZEL_TEST
|
||||
BUILD_EXECROOT
|
||||
COVERAGE_DIR
|
||||
GTEST_OUTPUT
|
||||
GTEST_SHARD_INDEX
|
||||
GTEST_SHARD_STATUS_FILE
|
||||
GTEST_TMP_DIR
|
||||
GTEST_TOTAL_SHARDS
|
||||
JAVA_RUNFILES
|
||||
PYTHON_RUNFILES
|
||||
RUNFILES_DIR
|
||||
RUNFILES_MANIFEST_FILE
|
||||
RUNFILES_MANIFEST_ONLY
|
||||
TEST_BINARY
|
||||
TEST_INFRASTRUCTURE_FAILURE_FILE
|
||||
TEST_LOGSPLITTER_OUTPUT_FILE
|
||||
TEST_PREMATURE_EXIT_FILE
|
||||
TEST_SHARD_INDEX
|
||||
TEST_SHARD_STATUS_FILE
|
||||
TEST_SRCDIR
|
||||
TEST_TARGET
|
||||
TEST_TMPDIR
|
||||
TEST_TOTAL_SHARDS
|
||||
TEST_UNDECLARED_OUTPUTS_ANNOTATIONS
|
||||
TEST_UNDECLARED_OUTPUTS_ANNOTATIONS_DIR
|
||||
TEST_UNDECLARED_OUTPUTS_DIR
|
||||
TEST_UNDECLARED_OUTPUTS_MANIFEST
|
||||
TEST_UNDECLARED_OUTPUTS_ZIP
|
||||
TEST_UNUSED_RUNFILES_LOG_FILE
|
||||
TEST_WARNINGS_OUTPUT_FILE
|
||||
XML_OUTPUT_FILE
|
||||
)
|
||||
|
||||
nested_bazel_env=(env)
|
||||
for env_var in "${scrubbed_env_vars[@]}"; do
|
||||
nested_bazel_env+=("-u" "${env_var}")
|
||||
done
|
||||
nested_bazel_env+=("TMPDIR=${nested_bazel_root}/tmp")
|
||||
|
||||
bazel_cmd=(
|
||||
"${nested_bazel_env[@]}"
|
||||
"${bazel_bin}"
|
||||
"--batch"
|
||||
"--ignore_all_rc_files"
|
||||
"--output_user_root=${nested_bazel_root}/output_user_root"
|
||||
)
|
||||
}
|
||||
|
||||
find_nested_bazel_workspace_root() {
|
||||
local script_path="${1:-${BASH_SOURCE[0]}}"
|
||||
local candidate
|
||||
local script_dir
|
||||
|
||||
for candidate in \
|
||||
"${TEST_SRCDIR:-}/${TEST_WORKSPACE:-}" \
|
||||
"${TEST_SRCDIR:-}/_main"; do
|
||||
if [[ -n ${candidate} && -f "${candidate}/MODULE.bazel" ]]; then
|
||||
printf '%s\n' "${candidate}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
script_dir="$(cd "$(dirname "${script_path}")" && pwd -P)"
|
||||
candidate="$(cd "${script_dir}/../.." && pwd -P)"
|
||||
if [[ -f "${candidate}/MODULE.bazel" ]]; then
|
||||
printf '%s\n' "${candidate}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Unable to locate rules_bun workspace root" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
shutdown_nested_bazel_workspace() {
|
||||
local workspace_dir="${1:-}"
|
||||
if [[ -n ${workspace_dir} && -d ${workspace_dir} ]]; then
|
||||
(
|
||||
cd "${workspace_dir}"
|
||||
"${bazel_cmd[@]}" shutdown >/dev/null 2>&1
|
||||
) || true
|
||||
fi
|
||||
|
||||
if [[ -n ${nested_bazel_root:-} && -d ${nested_bazel_root} ]]; then
|
||||
rm -rf "${nested_bazel_root}"
|
||||
fi
|
||||
}
|
||||
@@ -32,15 +32,28 @@ config_setting(
|
||||
],
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "windows_x86_64",
|
||||
constraint_values = [
|
||||
"@platforms//os:windows",
|
||||
"@platforms//cpu:x86_64",
|
||||
],
|
||||
)
|
||||
|
||||
sh_test(
|
||||
name = "npm_translate_lock_workspace_test",
|
||||
size = "small",
|
||||
srcs = ["npm_translate_lock_workspace_test.sh"],
|
||||
tags = [
|
||||
"exclusive",
|
||||
"no-sandbox",
|
||||
],
|
||||
args = select({
|
||||
":linux_x86_64": ["$(location @bun_linux_x64//:bun)"],
|
||||
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
||||
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
||||
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
||||
":windows_x86_64": ["$(location @bun_windows_x64//:bun)"],
|
||||
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
||||
}),
|
||||
data = select({
|
||||
@@ -48,6 +61,7 @@ sh_test(
|
||||
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
||||
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
||||
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
||||
":windows_x86_64": ["@bun_windows_x64//:bun"],
|
||||
"//conditions:default": ["@bun_linux_x64//:bun"],
|
||||
}) + [
|
||||
"//:repo_runtime_files",
|
||||
@@ -55,6 +69,7 @@ sh_test(
|
||||
"//internal:repo_runtime_files",
|
||||
"//js:repo_runtime_files",
|
||||
"//npm:repo_runtime_files",
|
||||
"//tests:nested_bazel_test.sh",
|
||||
],
|
||||
env_inherit = ["PATH"],
|
||||
)
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if command -v bazel >/dev/null 2>&1; then
|
||||
bazel_bin="$(command -v bazel)"
|
||||
elif command -v bazelisk >/dev/null 2>&1; then
|
||||
bazel_bin="$(command -v bazelisk)"
|
||||
else
|
||||
echo "bazel or bazelisk is required on PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bun_path="${1:-bun}"
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
||||
# shellcheck source=../nested_bazel_test.sh
|
||||
source "${script_dir}/../nested_bazel_test.sh"
|
||||
setup_nested_bazel_cmd
|
||||
|
||||
rules_bun_root="$(find_nested_bazel_workspace_root "${BASH_SOURCE[0]}")"
|
||||
|
||||
workdir="$(mktemp -d)"
|
||||
trap 'rm -rf "${workdir}"' EXIT
|
||||
cleanup() {
|
||||
local status="$1"
|
||||
trap - EXIT
|
||||
shutdown_nested_bazel_workspace "${fixture_dir:-}"
|
||||
rm -rf "${workdir}"
|
||||
exit "${status}"
|
||||
}
|
||||
trap 'cleanup $?' EXIT
|
||||
|
||||
fixture_dir="${workdir}/fixture"
|
||||
mkdir -p "${fixture_dir}"
|
||||
@@ -100,7 +102,7 @@ EOF
|
||||
|
||||
output="$(
|
||||
cd "${fixture_dir}" &&
|
||||
"${bazel_bin}" run //:app
|
||||
"${bazel_cmd[@]}" run //:app
|
||||
)"
|
||||
|
||||
if [[ ${output} != *"compat:true"* ]]; then
|
||||
@@ -110,7 +112,7 @@ fi
|
||||
|
||||
query_output="$(
|
||||
cd "${fixture_dir}" &&
|
||||
"${bazel_bin}" query //:npm__is_number
|
||||
"${bazel_cmd[@]}" query //:npm__is_number
|
||||
)"
|
||||
if ! grep -Fxq "//:npm__is_number" <<<"${query_output}"; then
|
||||
echo "expected npm_link_all_packages to create //:npm__is_number" >&2
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -14,12 +14,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -8,12 +8,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -19,12 +19,7 @@ start_launcher() {
|
||||
local log_target="$2"
|
||||
shift 2
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" >"${log_target}" 2>&1 &
|
||||
cmd.exe /c call "${launcher}" "$@" >"${log_target}" 2>&1 &
|
||||
else
|
||||
"${launcher}" "$@" >"${log_target}" 2>&1 &
|
||||
fi
|
||||
|
||||
@@ -22,12 +22,7 @@ start_launcher() {
|
||||
local log_target="$2"
|
||||
shift 2
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" >"${log_target}" 2>&1 &
|
||||
cmd.exe /c call "${launcher}" "$@" >"${log_target}" 2>&1 &
|
||||
else
|
||||
"${launcher}" "$@" >"${log_target}" 2>&1 &
|
||||
fi
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -32,22 +32,32 @@ config_setting(
|
||||
],
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "windows_x86_64",
|
||||
constraint_values = [
|
||||
"@platforms//os:windows",
|
||||
"@platforms//cpu:x86_64",
|
||||
],
|
||||
)
|
||||
|
||||
sh_test(
|
||||
name = "bun_version_test",
|
||||
size = "small",
|
||||
srcs = ["toolchain_version.sh"],
|
||||
args = select({
|
||||
":linux_x86_64": ["$(location @bun_linux_x64//:bun)"],
|
||||
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
||||
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
||||
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
||||
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
||||
":linux_x86_64": ["$(rlocationpath @bun_linux_x64//:bun)"],
|
||||
":linux_aarch64": ["$(rlocationpath @bun_linux_aarch64//:bun)"],
|
||||
":darwin_x86_64": ["$(rlocationpath @bun_darwin_x64//:bun)"],
|
||||
":darwin_aarch64": ["$(rlocationpath @bun_darwin_aarch64//:bun)"],
|
||||
":windows_x86_64": ["$(rlocationpath @bun_windows_x64//:bun)"],
|
||||
"//conditions:default": ["$(rlocationpath @bun_linux_x64//:bun)"],
|
||||
}),
|
||||
data = select({
|
||||
":linux_x86_64": ["@bun_linux_x64//:bun"],
|
||||
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
||||
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
||||
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
||||
":windows_x86_64": ["@bun_windows_x64//:bun"],
|
||||
"//conditions:default": ["@bun_linux_x64//:bun"],
|
||||
}),
|
||||
)
|
||||
@@ -56,6 +66,6 @@ sh_test(
|
||||
name = "toolchain_resolution_matrix_test",
|
||||
size = "small",
|
||||
srcs = ["toolchain_resolution_matrix.sh"],
|
||||
args = ["$(location //tests/toolchain_test:BUILD.bazel)"],
|
||||
args = ["$(rlocationpath //tests/toolchain_test:BUILD.bazel)"],
|
||||
data = ["//tests/toolchain_test:BUILD.bazel"],
|
||||
)
|
||||
|
||||
@@ -1,7 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
build_file="$1"
|
||||
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
|
||||
RUNFILES_DIR="${TEST_SRCDIR}"
|
||||
fi
|
||||
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
if [[ -d "$0.runfiles" ]]; then
|
||||
RUNFILES_DIR="$0.runfiles"
|
||||
elif [[ -f "$0.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
|
||||
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
|
||||
fi
|
||||
fi
|
||||
|
||||
resolve_runfile() {
|
||||
local path="${1:-}"
|
||||
local candidate
|
||||
local resolved
|
||||
|
||||
if [[ -z ${path} ]]; then
|
||||
echo "Error: missing runfile path" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -e ${path} ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for candidate in \
|
||||
"${path}" \
|
||||
"${TEST_WORKSPACE:-}/${path}" \
|
||||
"_main/${path}"; do
|
||||
[[ -z ${candidate} ]] && continue
|
||||
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
|
||||
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
resolved="$(
|
||||
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
|
||||
"${RUNFILES_MANIFEST_FILE}"
|
||||
)"
|
||||
if [[ -n ${resolved} ]]; then
|
||||
printf '%s\n' "${resolved}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Error: unable to resolve runfile: ${path}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
build_file="$(resolve_runfile "${1:-}")"
|
||||
|
||||
grep -Eq 'name = "linux_x86_64"' "${build_file}"
|
||||
grep -Eq 'name = "linux_aarch64"' "${build_file}"
|
||||
|
||||
@@ -1,8 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
bun_path="$1"
|
||||
version="$(${bun_path} --version)"
|
||||
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
|
||||
RUNFILES_DIR="${TEST_SRCDIR}"
|
||||
fi
|
||||
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
if [[ -d "$0.runfiles" ]]; then
|
||||
RUNFILES_DIR="$0.runfiles"
|
||||
elif [[ -f "$0.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
|
||||
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
|
||||
fi
|
||||
fi
|
||||
|
||||
resolve_runfile() {
|
||||
local path="${1:-}"
|
||||
local candidate
|
||||
local resolved
|
||||
|
||||
if [[ -z ${path} ]]; then
|
||||
echo "Error: missing runfile path" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -e ${path} ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for candidate in \
|
||||
"${path}" \
|
||||
"${TEST_WORKSPACE:-}/${path}" \
|
||||
"_main/${path}"; do
|
||||
[[ -z ${candidate} ]] && continue
|
||||
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
|
||||
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
resolved="$(
|
||||
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
|
||||
"${RUNFILES_MANIFEST_FILE}"
|
||||
)"
|
||||
if [[ -n ${resolved} ]]; then
|
||||
printf '%s\n' "${resolved}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Error: unable to resolve runfile: ${path}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
bun_path="$(resolve_runfile "${1:-}")"
|
||||
version="$("${bun_path}" --version)"
|
||||
|
||||
if [[ ! ${version} =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
||||
echo "Unexpected bun version output: ${version}" >&2
|
||||
|
||||
Reference in New Issue
Block a user