@@ -19,7 +19,48 @@ elif echo "$NODEJS_VERSION" | grep '^v12\.'; then
19
19
MOCHA_VERSION=" @<10"
20
20
fi
21
21
22
+ npm config set loglevel verbose
23
+
22
24
# Install JavaScript dependencies
23
- npm install -g --loglevel verbose \
25
+ npm install -g \
24
26
" mocha$MOCHA_VERSION " \
25
27
iconv-lite
28
+
29
+ # Install the runtime library. We fetch
30
+ # https://www.npmjs.com/package/kaitai-struct/v/next and install it globally in
31
+ # the Docker image. This means that whenever we make a change in
32
+ # https://github.com/kaitai-io/kaitai_struct_javascript_runtime and want to test
33
+ # it in CI, we need to follow these steps:
34
+ #
35
+ # 1. Publish a new version to npm with the @next tag. In practice, this just
36
+ # means pushing a tag in [this
37
+ # format](https://github.com/kaitai-io/kaitai_struct_javascript_runtime/blob/2acb0d8b09fde9c95fc77ee3019f6d6b1c73f040/.github/workflows/build.yml#L6)
38
+ # to GitHub, which will trigger `npm publish --tag next` automatically.
39
+ # 2. Trigger the CI workflow in
40
+ # https://github.com/kaitai-io/kaitai_struct_docker_images to rebuild the
41
+ # JavaScript Docker images to fetch the new @next version.
42
+ #
43
+ # Admittedly, it's not ideal to rely on an embedded runtime library (as
44
+ # mentioned in
45
+ # https://github.com/kaitai-io/kaitai_struct/issues/187#issuecomment-2273725000).
46
+ # Most Docker images can dynamically use any version of the runtime library
47
+ # mounted at `/runtime`, which is very easy to work with. However, since the
48
+ # JavaScript runtime library was migrated to TypeScript (see
49
+ # https://github.com/kaitai-io/kaitai_struct_javascript_runtime/pull/25), this
50
+ # is not so easy because the TypeScript code must first be compiled into
51
+ # JavaScript. We may not be able to do that on old unsupported Node.js versions
52
+ # that we're still testing on (because it requires some npm dependencies and
53
+ # most npm packages don't work on old versions of Node.js unless you also use
54
+ # outdated versions of those packages).
55
+ #
56
+ # Installing our `kaitai-struct` npm package in the Docker image is much easier.
57
+ # If it causes problems in the future, we can come up with another solution.
58
+
59
+ npm install -g \
60
+ kaitai-struct@next
61
+
62
+ # Tell `npm` to use offline mode from now on (the
63
+ # [`docker-ci`](https://github.com/kaitai-io/kaitai_struct_tests/blob/f831283c0b9d84eb52f6e8ec593c496b0c254854/docker-ci)
64
+ # script runs the Docker containers with `--network none`, so if `npm` decided
65
+ # to access the network for some reason, it would lead to errors)
66
+ npm config set offline true
0 commit comments