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

Merged
merged 1 commit into from
Sep 20, 2024
Merged

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?

Copy link
Contributor Author

@ermshiperete ermshiperete Sep 20, 2024

Choose a reason for hiding this comment

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

~/.cache is the default location for caches on Linux. In contrast to the path for nvm (where the directory contains links to the actual executable). MESON_PACKAGE_CACHE_DIR serves as a real cache that caches the files we have to download. If the files don't exist they'll get downloaded (again). In either case they get extracted/copied to the subprojects folder in e.g. core/src. This means it's safe to delete the files from ~/.cache/keyman/builder, whereas I think the build will fail if ~/.keyman/node doesn't exist. So I'd prefer to put the files under ~/.cache/....

@ermshiperete ermshiperete merged commit 03e2ba0 into master Sep 20, 2024
28 checks passed
@ermshiperete ermshiperete deleted the chore/common/offline branch September 20, 2024 14:16
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.116-alpha

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

Successfully merging this pull request may close these issues.

3 participants