Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(common): Allow to build offline #12439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ermshiperete
Copy link
Contributor

A lot of the configure actions rely on node dependencies and so call npm install. Without a internet connection this hangs forever, even if you had successfully installed the dependencies before and nothing changed since then. This change adds a --offline parameter that passes --prefer-offline to npm, which causes npm to use the cached dependencies.

Also sets the MESON_PACKAGE_CACHE_DIR environment variable so that all (sub-)projects share the same package cache dir. This will speed up regular builds a bit (e.g. developer/src/kmcmplib and core both have icu4c as a dependency), but will also help with offline builds.

MESON_PACKAGE_CACHE_DIR requires Meson 1.3, however older Meson versions ignore this environment variable and simply continue to use a cache per subproject, so will continue to work (minus offline builds).

@keymanapp-test-bot skip

@keymanapp-test-bot keymanapp-test-bot bot added this to the A18S11 milestone Sep 18, 2024
@ermshiperete ermshiperete marked this pull request as draft September 18, 2024 20:19
A lot of the `configure` actions rely on node dependencies and so call
`npm install`. Without a internet connection this hangs forever, even
if you had successfully installed the dependencies before and nothing
changed since then. This change adds a `--offline` parameter that passes
`--prefer-offline` to npm, which causes npm to use the cached
dependencies.

Also sets the `MESON_PACKAGE_CACHE_DIR` environment variable so that all
(sub-)projects share the same package cache dir. This will speed up regular
builds a bit (e.g. `developer/src/kmcmplib` and `core` both have `icu4c`
as a dependency), but will also help with offline builds.

`MESON_PACKAGE_CACHE_DIR` requires Meson 1.3, however older Meson
versions ignore this environment variable and simply continue to use a
cache per subproject, so will continue to work (minus offline builds).
builder_echo "Trying offline build"
offline_param=--prefer-offline
fi
try_multiple_times npm ${offline_param} ci
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could consider to always pass --prefer-offline which would probably help if nodejs.org has an outage, but I don't know if that has unwanted side-effects.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if that's a good idea for build agents?

@ermshiperete ermshiperete marked this pull request as ready for review September 18, 2024 21:41

# Set shared Meson package cache (works with Meson >= 1.3)
if [[ -z ${MESON_PACKAGE_CACHE_DIR:-} ]]; then
export MESON_PACKAGE_CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/keyman/builder"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ~/.cache a safe path? We have already a ~/.keyman path used for nvm (see

### Caveats on macOS/Linux
) so maybe it'd be better to share that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants