diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 715686c..235f290 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Build toolchains - run: ./pleasew build //third_party/node:node //third_party/bun:bun //third_party/oxlint:oxlint + run: ./pleasew build //third_party/node:node //third_party/bun:bun - name: Test toolchains run: ./pleasew test //test/... - name: Format diff --git a/.plzconfig b/.plzconfig index 0594068..b3fae1b 100644 --- a/.plzconfig +++ b/.plzconfig @@ -28,11 +28,5 @@ DefaultValue = ///node//third_party/bun:bun|bun Help = Build label for the Bun binary, from bun_toolchain. Inherit = true -[PluginConfig "oxlint_tool"] -ConfigKey = OxlintTool -DefaultValue = ///node//third_party/oxlint:oxlint|oxlint -Help = Build label for the OXLint binary, from oxlint_toolchain. -Inherit = true - [Plugin "node"] Target = //plugins:node diff --git a/README.md b/README.md index c51c529..db8f533 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # node-rules -A Node.js, Bun and OXLint toolchain for the [Please](https://please.build) build system. +A Node.js and Bun toolchain for the [Please](https://please.build) build system. This plugin fetches pinned native executables for the host platform. It exposes -`node`, `npm`, `npx`, `corepack`, `bun` and `oxlint` as entry points. It has no +`node`, `npm`, `npx`, `corepack` and `bun` as entry points. It has no opinions about how JavaScript is built, checked or linted. ## Install @@ -44,14 +44,6 @@ subinclude("///node//build_defs:bun") bun_toolchain(name = "bun", version = "1.4.4") ``` -Declare OXLint in `third_party/oxlint/BUILD`: - -```python -subinclude("///node//build_defs:oxlint") - -oxlint_toolchain(name = "oxlint", version = "1.91.0") -``` - Then point the plugin config at it, so rules can find it: ```ini @@ -60,7 +52,6 @@ Target = //plugins:node NodeTool = //third_party/node:node|node NpmTool = //third_party/node:node|npm BunTool = //third_party/bun:bun|bun -OxlintTool = //third_party/oxlint:oxlint|oxlint ``` ## Using it in a rule @@ -93,8 +84,8 @@ The Node.js tarball ships `bin/npm` as a symlink to a `.js` file carrying a there is not. The entry points therefore name the scripts themselves, and the downloaded tree is left byte-identical to what nodejs.org shipped. -`bun` and `oxlint` are native binaries. Declare them as tools and invoke them -directly; no host Node.js executable or package installation is needed: +`bun` is a native binary. Declare it as a tool and invoke it directly; no host +Node.js executable or package installation is needed: ```python subinclude("///node//build_defs:bun") @@ -108,9 +99,8 @@ build_rule( ) ``` -Subinclude `///node//build_defs:bun` or `///node//build_defs:oxlint` in each -BUILD file that reads the respective config key. The default targets live in -`third_party/bun/BUILD` and `third_party/oxlint/BUILD` within this plugin. +Subinclude `///node//build_defs:bun` in each BUILD file that reads the config +key. The default target lives in `third_party/bun/BUILD` within this plugin. ## Configuration @@ -120,7 +110,6 @@ BUILD file that reads the respective config key. The default targets live in | `NpmTool` | `///node//third_party/node:node\|npm` | Build label for the npm CLI | | `DefaultVersion` | `22.23.2` | Version used when `node_toolchain` is called without one | | `BunTool` | `///node//third_party/bun:bun\|bun` | Build label for the Bun binary | -| `OxlintTool` | `///node//third_party/oxlint:oxlint\|oxlint` | Build label for the OXLint binary | ## Versions @@ -140,10 +129,9 @@ that is not pinned, pass `hashes` explicitly. Supported platforms: `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`. -`bun_toolchain` and `oxlint_toolchain` carry SHA256 hashes of their official -release archives in `build_defs/bun.build_defs` and -`build_defs/oxlint.build_defs`. Each rule requires an explicit version. The -same four platforms are supported. Bun's x64 baseline archives work on CPUs -without AVX2. Linux OXLint uses the glibc archives. Unsupported platforms and -versions fail during rule evaluation. The exact version, archive URL and digest -are in the action command, so a pin change invalidates its cache key. +`bun_toolchain` carries SHA256 hashes of its official release archives in +`build_defs/bun.build_defs`. It requires an explicit version and supports the +same four platforms. Bun's x64 baseline archives work on CPUs without AVX2. +Unsupported platforms and versions fail during rule evaluation. The exact +version, archive URL and digest are in the action command, so a pin change +invalidates its cache key. diff --git a/build_defs/BUILD b/build_defs/BUILD index 71f1e29..5e6ea1d 100644 --- a/build_defs/BUILD +++ b/build_defs/BUILD @@ -9,9 +9,3 @@ filegroup( srcs = ["bun.build_defs"], visibility = ["PUBLIC"], ) - -filegroup( - name = "oxlint", - srcs = ["oxlint.build_defs"], - visibility = ["PUBLIC"], -) diff --git a/build_defs/oxlint.build_defs b/build_defs/oxlint.build_defs deleted file mode 100644 index 8f6cf97..0000000 --- a/build_defs/oxlint.build_defs +++ /dev/null @@ -1,61 +0,0 @@ -"""Pinned OXLint distribution for Please actions.""" - -# SHA256 values are from the immutable oxlint_v1.91.0 GitHub release assets. -OXLINT_VERSIONS = { - "1.91.0": { - "darwin-arm64": ("oxlint-aarch64-apple-darwin.tar.gz", "d1f6037780a4d5e14a32d810083859ae691a5032f789381a5ff9b75f901f90e9"), - "darwin-x64": ("oxlint-x86_64-apple-darwin.tar.gz", "b422a6a5ffe753b117d7348a80e722ca35183ceb1b6c98766f0de14747727a26"), - "linux-arm64": ("oxlint-aarch64-unknown-linux-gnu.tar.gz", "c99c0e97edd40d5cd21840831d8eff2d4a5e84ce0cf73a6fdac58aaa9c1e1f20"), - "linux-x64": ("oxlint-x86_64-unknown-linux-gnu.tar.gz", "de059941526abeaab3c5aafa78caef80e5b4e7197274391d80cde38a1960a916"), - }, -} - - -def _oxlint_platform(): - if CONFIG.OS not in ["linux", "darwin"]: - fail("oxlint_toolchain supports linux and darwin only, not " + CONFIG.OS) - if CONFIG.ARCH == "amd64": - arch = "x64" - elif CONFIG.ARCH == "arm64": - arch = "arm64" - else: - fail("oxlint_toolchain does not support architecture " + CONFIG.ARCH) - return CONFIG.OS + "-" + arch - - -def oxlint_toolchain(name:str, version:str, visibility:list=["PUBLIC"]): - """Download verified OXLint and expose its native `oxlint` entry point. - - Usage: oxlint_toolchain(name = "oxlint", version = "1.91.0") - """ - if version not in OXLINT_VERSIONS: - fail("No pinned OXLint hashes for " + version + ". Known versions: " + - ", ".join(sorted(OXLINT_VERSIONS.keys()))) - platform = _oxlint_platform() - pin = OXLINT_VERSIONS[version][platform] - archive = pin[0] - hash = pin[1] - url = "https://github.com/oxc-project/oxc/releases/download/oxlint_v" + version + "/" + archive - executable = archive[:-7] - cmd = " && ".join([ - "curl -fsSL --retry 5 --retry-delay 2 -o oxlint.tar.gz '" + url + "'", - "digest=$(if command -v sha256sum >/dev/null 2>&1; then sha256sum oxlint.tar.gz | awk '{print $1}'; else openssl dgst -sha256 oxlint.tar.gz | awk '{print $NF}'; fi)", - "{ [ \"$digest\" = '" + hash + "' ] || { echo 'bad hash for " + url + "' >&2; exit 1; }; }", - "mkdir -p _archive $OUT", - "tar -xzf oxlint.tar.gz -C _archive", - "mv _archive/" + executable + " $OUT/oxlint", - "chmod +x $OUT/oxlint", - "rm -f oxlint.tar.gz", - ]) - return build_rule( - name = name, - outs = [name], - cmd = cmd, - entry_points = {"oxlint": name + "/oxlint"}, - binary = True, - local = True, - sandbox = False, - visibility = visibility, - labels = ["oxlint:" + version], - building_description = "Installing OXLint v" + version + "...", - ) diff --git a/test/BUILD b/test/BUILD index aaa8476..72682f8 100644 --- a/test/BUILD +++ b/test/BUILD @@ -13,13 +13,13 @@ build_rule( ) build_rule( - name = "native_tools_test", - srcs = ["native_tools_test.sh"], - data = ["//third_party/bun:bun", "//third_party/oxlint:oxlint"], - outs = ["native_tools_test"], + name = "bun_toolchain_test", + srcs = ["bun_toolchain_test.sh"], + data = ["//third_party/bun:bun"], + outs = ["bun_toolchain_test"], cmd = "cp $SRCS $OUT", binary = True, test = True, no_test_output = True, - test_cmd = "$TEST third_party/bun/bun 1.4.4 third_party/oxlint/oxlint 1.91.0", + test_cmd = "$TEST third_party/bun/bun 1.4.4", ) diff --git a/test/bun_toolchain_test.sh b/test/bun_toolchain_test.sh new file mode 100755 index 0000000..9502816 --- /dev/null +++ b/test/bun_toolchain_test.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu + +BUN="$(pwd)/$1/bun" +got=$(env -i PATH=/usr/bin:/bin "$BUN" --version) +[ "$got" = "$2" ] || { echo "Bun: expected $2, got $got" >&2; exit 1; } + +echo "Bun tool entry point is hermetic" diff --git a/test/native_tools_test.sh b/test/native_tools_test.sh deleted file mode 100644 index a20d32b..0000000 --- a/test/native_tools_test.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -set -eu - -BUN="$(pwd)/$1/bun" -OXLINT="$(pwd)/$3/oxlint" - -got=$(env -i PATH=/usr/bin:/bin "$BUN" --version) -[ "$got" = "$2" ] || { echo "Bun: expected $2, got $got" >&2; exit 1; } - -got=$(env -i PATH=/usr/bin:/bin "$OXLINT" --version) -case "$got" in - *"$4"*) ;; - *) echo "OXLint: expected $4, got $got" >&2; exit 1 ;; -esac - -echo "native tool entry points are hermetic" diff --git a/third_party/oxlint/BUILD b/third_party/oxlint/BUILD deleted file mode 100644 index db24134..0000000 --- a/third_party/oxlint/BUILD +++ /dev/null @@ -1,6 +0,0 @@ -subinclude("//build_defs:oxlint") - -oxlint_toolchain( - name = "oxlint", - version = "1.91.0", -)