Help running sbt from Ci/Cd

I’m trying to set up so that my scala tests are run on git push.
I run locally on MacOS, and the Ci/Cd is run on Linux, so some things are a bit of a mystery.

It appears sbt is not installed by default. So I took at look at this stack overflow question. It suggests I need to do the following:

wget http://apt.typesafe.com/repo-deb-build-0002.deb
sudo dpkg -i repo-deb-build-0002.deb
sudo apt-get update
sudo apt-get install sbt

But that seems to be problematic. The error messages claim there is something wrong on the typesafe side. Has anyone seen something like this before?

70 $ dpkg -i repo-deb-build-0002.deb
71 Selecting previously unselected package typesafe-repo.
72 (Reading database ... 4394 files and directories currently installed.)
73 Preparing to unpack repo-deb-build-0002.deb ...
74 Unpacking typesafe-repo (2.0-build-0003) ...
75 Setting up typesafe-repo (2.0-build-0003) ...
76 Warning: The postinst maintainerscript of the package typesafe-repo
77 Warning: seems to use apt-key (provided by apt) without depending on gnupg or gnupg2.
78 Warning: This will BREAK in the future and should be fixed by the package maintainer(s).
79 Note: Check first if apt-key functionality is needed at all - it probably isn't!
80 E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
81 dpkg: error processing package typesafe-repo (--install):
82  installed typesafe-repo package post-installation script subprocess returned error exit status 255
83 Errors were encountered while processing:
84  typesafe-repo
88 ERROR: Job failed: exit code 1

Try with

echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
sudo apt-get update
sudo apt-get install sbt

source.

1 Like

hmmm, curl not found.

I tried to install curl before running curl.
But I still get the problem with gnupg

I’ll see what happens if I try to apt-get gnupg before running curl.

That’s promising, but there is a warning about parsing the output of curl.

What do you intend to accomplish with ... | apt-key add? I fear it’s not working as you intended?

OK, now I have some success. Here is the content of the .gitlab.yml file which seems to work. Apparently apt-get install sbt installs scala but not java, so I have to also install default-jdk.

image: lokedhs/sbcl-quicklisp

stages:
  - test

before_script:
  - apt-get update -y
  - apt-get install -y csh
  - apt-get install -y curl
  - apt-get install -y gnupg
  - echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list
  - curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add
  - apt-get update -y
  - apt-get install -y default-jdk
  - apt-get install -y sbt
  - sbt sbtVersion
  - apt-get install -y graphviz
  - apt-get install -y gnuplot
  - apt-get install -y git

unit-scala:
  stage: test
  script: ./bin/auto-test-scala-on-push.csh

unit-cl:
  stage: test
  script: ./bin/auto-test-lisp-on-push.lisp
1 Like

Disclaimer I am not an expert in CI but you shouldn’t need to install all that every time.

I haven’t used gitlab, but the tools I have worked with usually run in some containerized environment which let you specify a base image which had the base tools already installed.

You can use my image, nafg/docker-sbt

(The Dockerfile is at https://github.com/nafg/docker-sbt/blob/master/Dockerfile if you want to peek at the recipe)

1 Like

Thanks for the suggestion. In the mean time, my system admin helped me set one up.
Here is the script file.

FROM lokedhs/sbcl-quicklisp

RUN apt-get update                              \
  && RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive  \
     apt-get install -y --no-install-recommends \
       graphviz \
       gnuplot \
       git \
       csh \
       curl \
       gnupg \
       default-jdk \
  && echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list \
  && curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add \
  && apt-get update \
  && RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive \
     apt-get install -y --no-install-recommends \
       sbt \
  && apt-get autoremove                         \
  && apt-get clean \
  && sbt sbtVersion
1 Like