bazelbuild / examples

Examples for Bazel
http://bazel.build
Apache License 2.0
800 stars 497 forks source link

feat: add astro example #419

Open pedrobarco opened 3 months ago

pedrobarco commented 3 months ago

I've originally created this repo to test it and shared it in slack but @alexeagle made me do this 😎

Let me know if there's anything you'd like to see in this particular example.

I still need to understand how to fix the following warning:

WARNING: <repo>/examples/frontend/BUILD.bazel:10:22: input 'package' to //:.aspect_rules_js/node_modules/@swc+core@1.3.100/lc is a directory; dependency checking of directories is unsound
alexeagle commented 3 months ago

From the CI failure

EPERM: operation not permitted, mkdir '/Users/buildkite/Library/Preferences/astro'
  Stack trace:
    at Object.mkdirSync (node:fs:1391:3)
    at get store [as store] (file:///private/var/tmp/_bazel_buildkite/a7160a15a89154e2ab8ab503e69ab355/sandbox/darwin-sandbox/2490/execroot/_main/bazel-out/darwin_x86_64-fastbuild/bin/node_modules/.aspect_rules_js/@astrojs+telemetry@3.0.4/node_modules/@astrojs/telemetry/dist/config.js:39:10)

it looks like the tool expects to modify the host machine filesystem, can it be configured not to do that?

pedrobarco commented 3 months ago

From the CI failure

EPERM: operation not permitted, mkdir '/Users/buildkite/Library/Preferences/astro'
  Stack trace:
    at Object.mkdirSync (node:fs:1391:3)
    at get store [as store] (file:///private/var/tmp/_bazel_buildkite/a7160a15a89154e2ab8ab503e69ab355/sandbox/darwin-sandbox/2490/execroot/_main/bazel-out/darwin_x86_64-fastbuild/bin/node_modules/.aspect_rules_js/@astrojs+telemetry@3.0.4/node_modules/@astrojs/telemetry/dist/config.js:39:10)

it looks like the tool expects to modify the host machine filesystem, can it be configured not to do that?

I've tracked it down to the way telemetry is stored in astro's global config and it's now working as expected. I've added the ASTRO_TELEMETRY_DISABLED=1 env var to disable collecting telemetry data so that there's no need to create a global astro preferences dir.

alexeagle commented 3 months ago

Looks like the node version you chose doesn't work on Ubuntu 18.04 - I think you need an older node to keep the glibc compat

rules_nodejs~6.0.5~node~nodejs_linux_amd64/bin/nodejs/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found
pedrobarco commented 3 months ago

Looks like the node version you chose doesn't work on Ubuntu 18.04 - I think you need an older node to keep the glibc compat

rules_nodejs~6.0.5~node~nodejs_linux_amd64/bin/nodejs/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found

I've tested a couple of versions and it looks like the last node version that uses the glibc version that comes with Ubuntu 18.04 is node 17, which unfortunately isn't supported by astro (v18.14.1 or higher).

root@c05651222d38:/# ldd --version
ldd (Ubuntu GLIBC 2.27-3ubuntu1.6) 2.27
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
root@c05651222d38:/# nvm use 17
Now using node v17.9.1 (npm v8.11.0)
root@c05651222d38:/# node --version
v17.9.1
root@c05651222d38:/# nvm use 18
Now using node v18.19.1
root@c05651222d38:/# node --version
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
root@c05651222d38:/# nvm use 20
Now using node v20.11.1
root@c05651222d38:/# node --version
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
alexeagle commented 3 months ago

I don't control the machines that run the presubmits here, that's someone at Google. The config just has https://github.com/bazelbuild/examples/blob/main/.bazelci/frontend.yml which doesn't let us pick a newer ubuntu.

It's really lame that node doesn't ship a statically-compiled binary (link against musl, for example)...