https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
c

CLOVIS

03/09/2020, 7:24 PM
Hi! I'm trying to setup GitLab CI for a Multiplatform (for now just JVM & JS) project. The JVM side is going well (not my first time), but I'm new to Kotlin/JS and unsure how it should work. The JS test runs in a Dockerfile based on
node:alpine
(full dockerfile), with Gradle 6.0.1. I'm getting the following error message:
Copy code
Caused by: <http://java.io|java.io>.IOException: Cannot run program "/root/.gradle/nodejs/node-v10.15.3-linux-x64/bin/node" (in directory "/builds/clovis-ai/lib/build/js"): error=2, No such file or directory
 	at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
 	... 7 more
 Caused by: <http://java.io|java.io>.IOException: error=2, No such file or directory
 	... 8 more
when running
./gradlew jsBrowserTest --stacktrace --info
(on task ':kotlinNpmInstall', full stacktrace). (full build.gradle.kts) Does anyone know why that occurs? The error message doesn't really help me to understand what is going wrong...
e

Eivind Nilsbakken

03/10/2020, 6:31 AM
Where does that node path come from? I think it's probably not part of the filsystem at all for the CI user. The Docker image was most likely created by root, hence
/root/.gradle/etc/
, but GitLab changes that to a custom less privileged user. If you can change that path at all, I'd try
$HOME/.gradle/...
or something (eg. ``pwd`/.gradle/...` ).
If it's not something you can change, a workaround might be to skip tests in your gradle build, pass the intermediate JS build as artifacts to a next stage with a node image, and
npm run
those tests. You'd probably have to make a custom
package.json
for that to work though, which you might not want in your final build. I don't know how those tests are supposed to work though, or if they're generated by the multiplatform plugin, so that might not be a good solution for you. Otherwise, here's my current setup, where I'm doing something similar for publishing packages to npmjs: https://gitlab.com/fleskesvor/tabletop-enums/-/blob/ci-deploy-npm/.gitlab-ci.yml
s

sean

03/10/2020, 5:32 PM
One of things I found, not sure if it's still the case. Is that kotlin downloads a node to run via gradle. I'll check locally and post back When being run via alpine it won't run. I don't have the links right now. But I had to buiild a custom docker image to run js, native, and jvm tests in gitlab. This is a very large image, based off ubuntu https://gitlab.com/AnimusDesign/kotlin-mp-build
Still failing for me in a similar fashion. On alpine, not sure if that was the cause or not. I use that image for multi platform tests
i

Ilya Goncharov [JB]

03/10/2020, 9:20 PM
It can be related, that plugin tries to download node for your OS, and there is no node for alpine in official distribution. You can disable node downloading (https://kotlinlang.slack.com/archives/C0B8L3U69/p1582971665095700?thread_ts=1582749959.057400&amp;channel=C0B8L3U69&amp;message_ts=1582971665.095700), and try again. Additionally, you need browser (at least Google Chrome) to run tests in browser, you can find ready docker containers containing it
c

CLOVIS

03/11/2020, 12:53 PM
@Eivind Nilsbakken thanks, I'll take a look ^^
My docker image is built from
node:alpine
, so I assumed it would work...
e

Eivind Nilsbakken

03/11/2020, 1:09 PM
If there's a way to force the multiplatform plugin to use the installed version of node instead of the one it downloads (which doesn't work on alpine), that might work.
i

Ilya Goncharov [JB]

03/11/2020, 1:14 PM
You can disable download of node at all
c

CLOVIS

03/11/2020, 1:18 PM
@Ilya Goncharov [JB] in your opinion, would that invalidate the goal of the test? The point of running in a container is to be as neutral as possible, if it has a different code than the real users, it might not be representative? Also, is it possible to pass that “no download” option as a Gradle CLI flag? So it doesn't impact other users than this one test
i

Ilya Goncharov [JB]

03/11/2020, 1:25 PM
It depends on your purposes and kind of testing. When you develop Kotlin/JS application or js library, you get plain JavaScript file in the end. And this js file can be run in any js environment, for example at least other version of nodejs, or other browser which you tested, so it can be part of your system requirements, for example you declare that you tested it in Node 12.0 And if you get docker container with node with appropriate version like in gradle plugin (12.14.0 for 1.3.70), it should be ok. In fact nodejs is not accessible for all platforms, in official dist there are distributives for most popular platforms, but of corse not for all. And there is no official distributive for alpine, for example.
c

CLOVIS

03/11/2020, 1:28 PM
Thanks 👍
e

Eivind Nilsbakken

03/11/2020, 1:30 PM
You could check for the presence of the
CI
environment variable to check if the code is being built on CircleCI, and disable download of node if so. https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
Sorry, I forgot that you're using GitLab (yay! 🙂), but you can do the same thing there: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference
116 Views