Fork me on GitHub
#clojurescript
<
2022-12-05
>
caumond08:12:05

Hi, I'd like to test my clojurescript code, I tried with karma and it works well locally. But I don't succeed to make it work in my docker in environment (for a github action). I used puppeteer to create the headless browser but it does not work. Can somebody tell me what is the easy and standard way to do it? Ideally, I'd like to be able to test my clojure code and lint it in the same docker. For reference, this is my Dockerfile :

FROM alpine
WORKDIR /usr/app
ENV BB_VERSION=1.0.165
ENV CLJ_VERSION=1.11.1.1182
ENV JDK_VERSION=openjdk17
RUN apk update                           # Update available packages
RUN apk --no-cache add curl              # Install curl
RUN apk add --no-cache su-exec           # Install sudo
RUN apk add --no-cache bash              # install bash
RUN apk add --no-cache $JDK_VERSION      # Java
RUN apk add --no-cache --upgrade rlwrap  # rlwrap
RUN apk add --no-cache git               # Git
RUN apk add --update npm                 # NPM
RUN curl  -o linux-install.sh
RUN chmod +x linux-install.sh
RUN ./linux-install.sh
RUN clojure
RUN curl -sLO  \
    && chmod +x install \
    && ./install --version $BB_VERSION --static
COPY deps.edn .
RUN clj -P
COPY package.json .
RUN npm update
COPY shadow-cljs.edn .
RUN npx shadow-cljs classpath
RUN apk upgrade
ENTRYPOINT ["bb", "gha"]
and the karam.conf.js file:
process.env.CHROME_BIN = require('puppeteer').executablePath()

// 
module.exports = function (config) {
    config.set({
        browsers: ['ChromeHeadless'],
        // The directory where the output file lives
        basePath: 'target',
        // The file itself
        files: ['karma-test.js'],
        frameworks: ['cljs-test'],
        plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
        colors: true,
        logLevel: config.LOG_INFO,
        client: {
            args: ["shadow.test.karma.init"],
            singleRun: true
        }
    })
};
The npx karma start --single-run returns:
Cannot start ChromeHeadless
	Can not find the binary /usr/app/clojure/base/.cache/puppeteer/chrome/linux-1056772/chrome-linux/chrome
	Please set env variable CHROME_BIN
which is certainly due to the binary seems ko ldd /usr/app/clojure/base/.cache/puppeteer/chrome/linux-1056772/chrome-linux/chrome returns a bunch of
Error relocating /usr/app/clojure/base/.cache/puppeteer/chrome/linux-1056772/chrome-linux/chrome: g_value_get_float: symbol not found

borkdude08:12:14

In Alpine binaries must not be dynamically liked with glibc. Either choose static binaries (install bb with the —static flag too) or choose a different base image

👍 1
caumond08:12:58

I guess this is already what I did for bb with the --static suffix, but the pupetteer installation may fail to the reason you mention. I try with a different image so.

👍 1
hkjels11:12:15

Hey, I'm making a library with some examples without using shadow or figwheel etc. Everything builds successfully, but base.js is missing from the build. Any ideas how that can be?

caumond14:12:49

Hi, you need to tell us a little bit more I guess. How do you think your base.js is built, so?

Jérémie Salvucci20:12:07

Hi, I'm using cljs-ajax 0.8.4. I'm running the following code

(GET url
  {:response-format :raw
   :handler #(.log js/console "done.")
   :progress-handler #(.log js/console "ongoing...")
   :error-handler #(.log js/console "error")})
But the progress handler is never called. When I rewrite this using xhrio, it works perfectly. I see many "on going..." messages and one "done."
(events/listen xhr "complete" #(.log js/console "done"))
      (events/listen xhr "progress" #(.log js/console "on going..."))
      (.setProgressEventsEnabled xhr true)
      (.send xhr url)
When I look at the source code of cljs-ajax, it uses XhrIo by default so I don't know why I get two different behaviors… What am I missing?

phill22:12:35

Does cljs-ajax register the same ("progress") event? I think it might only do upload progress. https://github.com/JulianBirch/cljs-ajax/blob/a64603687558843b1a7bdaacbcc1d936857224a4/src/ajax/xhrio.cljs#L26

Jérémie Salvucci08:12:30

Oh I missed this. Thank you!