Skip to content

Commit 5c9b2d5

Browse files
authored
Add python and js docker images building #942 (#1764)
1 parent f99ceb7 commit 5c9b2d5

File tree

6 files changed

+120
-54
lines changed

6 files changed

+120
-54
lines changed

.github/workflows/build-and-run-tests.yml

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ on:
1212

1313
env:
1414
REGISTRY: ghcr.io
15-
IMAGE_NAME: utbot_java_cli
16-
DOCKERFILE_PATH: docker/Dockerfile_java_cli
1715

1816
jobs:
1917
build-and-run-tests:
@@ -32,36 +30,40 @@ jobs:
3230
publish-cli-image:
3331
needs: build-and-run-tests
3432
if: ${{ github.event_name == 'push' }}
33+
strategy:
34+
fail-fast: false # force to execute all jobs even though some of them have failed
35+
matrix:
36+
configuration:
37+
- image_name: utbot_java_cli
38+
directory: utbot-cli
39+
extra_options: ""
40+
- image_name: utbot_js_cli
41+
directory: utbot-cli-js
42+
extra_options: "-PbuildType=ALL"
43+
# we can't use utbot_python_cli image name because of the bug while pushing image
44+
# ERROR: unexpected status: 403 Forbidden
45+
- image_name: utbot_py_cli
46+
directory: utbot-cli-python
47+
extra_options: ""
3548
runs-on: ubuntu-20.04
3649
container: unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
3750
steps:
38-
- name: Print environment variables
39-
run: printenv
40-
4151
- uses: actions/checkout@v3
4252

53+
# "You can make an environment variable available to any subsequent steps in a workflow job by
54+
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
4355
- name: Set environment variables
4456
run: |
45-
# "You can make an environment variable available to any subsequent steps in a workflow job by
46-
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
4757
echo VERSION="$(date +%Y).$(date +%-m)" >> $GITHUB_ENV
48-
49-
- name: Build UTBot Java CLI
50-
run: |
51-
cd utbot-cli
52-
gradle build --no-daemon --build-cache --no-parallel -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -x test -PsemVer=${{ env.VERSION }}
53-
- name: Set docker tag
54-
run:
55-
# "You can make an environment variable available to any subsequent steps in a workflow job by
56-
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
57-
echo DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ github.sha }}" >> $GITHUB_ENV
58+
echo DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-$(echo -n ${GITHUB_SHA} | cut -c 1-7)" >> $GITHUB_ENV
5859
59-
- name: Log in to the Container registry
60-
uses: docker/login-action@v2
61-
with:
62-
registry: ${{ env.REGISTRY }}
63-
username: ${{ github.actor }}
64-
password: ${{ secrets.GITHUB_TOKEN }}
60+
- name: Print environment variables
61+
run: printenv
62+
63+
- name: Build UTBot CLI
64+
run: |
65+
cd ${{ matrix.configuration.directory }}
66+
gradle build --no-daemon --build-cache --no-parallel ${{ matrix.configuration.extra_options }} -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -x test -PsemVer=${{ env.VERSION }}
6567
6668
- name: Set up Docker Buildx
6769
uses: docker/setup-buildx-action@v2
@@ -71,32 +73,45 @@ jobs:
7173
driver-opts: |
7274
image=moby/buildkit:v0.10.6
7375
76+
- name: Log in to the Container registry
77+
uses: docker/login-action@v2
78+
with:
79+
registry: ${{ env.REGISTRY }}
80+
username: ${{ github.actor }}
81+
password: ${{ secrets.GITHUB_TOKEN }}
82+
7483
- name: Cache Docker layers
7584
uses: actions/cache@v3
7685
with:
7786
path: /tmp/.buildx-cache
78-
key: ${{ runner.os }}-buildx-${{ github.sha }}
87+
key: ${{ runner.os }}-buildx-${{ matrix.configuration.image_name }}-${{ github.sha }}
7988
restore-keys: |
80-
${{ runner.os }}-buildx-
89+
${{ runner.os }}-buildx-${{ matrix.configuration.image_name }}-
90+
8191
- name: Docker meta
8292
id: meta
8393
uses: docker/metadata-action@v3
8494
with:
85-
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
95+
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.configuration.image_name }}
8696
tags: |
8797
type=raw,value=${{ env.DOCKER_TAG }}
88-
- name: Docker Buildx (build and push)
89-
run: |
90-
docker buildx build \
91-
-f ${{ env.DOCKERFILE_PATH }} \
92-
--cache-from "type=local,src=/tmp/.buildx-cache" \
93-
--cache-to "type=local,dest=/tmp/.buildx-cache-new" \
94-
--tag ${{ steps.meta.outputs.tags }} \
95-
--build-arg UTBOT_JAVA_CLI=utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar \
96-
--push .
97-
# Temp fix
98-
# https://github.com/docker/build-push-action/issues/252
99-
# https://github.com/moby/buildkit/issues/1896
98+
99+
- name: Build and push
100+
uses: docker/build-push-action@v4
101+
with:
102+
context: .
103+
push: true
104+
tags: |
105+
${{ steps.meta.outputs.tags }}
106+
cache-from: type=local,src=/tmp/.buildx-cache
107+
cache-to: type=local,dest=/tmp/.buildx-cache-new
108+
file: ${{ matrix.configuration.directory }}/Dockerfile
109+
build-args: |
110+
ARTIFACT_PATH=${{ matrix.configuration.directory }}/build/libs/${{ matrix.configuration.directory }}-${{ env.VERSION }}.jar
111+
112+
# Temp fix
113+
# https://github.com/docker/build-push-action/issues/252
114+
# https://github.com/moby/buildkit/issues/1896
100115
- name: Move cache
101116
run: |
102117
rm -rf /tmp/.buildx-cache

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ kotlin.code.style=official
33
# IU, IC, PC, PY
44
# IC for AndroidStudio
55
ideType=IC
6+
# ALL, NOJS
7+
buildType=NOJS
68
ideVersion=222.4167.29
79

810
pythonIde=IC,IU,PC,PY
911
jsIde=IU,PY,WS
12+
jsBuild=ALL
1013
goIde=IU
1114

1215
# In order to run Android Studion instead of Intellij Community, specify the path to your Android Studio installation

settings.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
val ideType: String by settings
2+
val buildType: String by settings
23

34
val pythonIde: String by settings
45
val jsIde: String by settings
6+
val jsBuild: String by settings
57
val includeRiderInBuild: String by settings
68
val goIde: String by settings
79

@@ -56,7 +58,7 @@ if (pythonIde.split(",").contains(ideType)) {
5658
include("utbot-python-parser")
5759
}
5860

59-
if (jsIde.split(",").contains(ideType)) {
61+
if (jsBuild == buildType || jsIde.split(",").contains(ideType)) {
6062
include("utbot-js")
6163
include("utbot-cli-js")
6264
include("utbot-intellij-js")

utbot-cli-js/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM azul/zulu-openjdk:11.0.15-11.56.19
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
WORKDIR /usr/src/
6+
7+
RUN apt-get update \
8+
&& apt-get install -y -q --no-install-recommends \
9+
curl \
10+
&& curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh \
11+
&& /bin/sh nodesource_setup.sh \
12+
&& apt-get install -y -q --no-install-recommends \
13+
nodejs \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# Install UTBot Javascript CLI
17+
18+
ARG ARTIFACT_PATH
19+
COPY ${ARTIFACT_PATH} .
20+
21+
RUN UTBOT_JS_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \
22+
&& ln -s "${UTBOT_JS_CLI_PATH}" /usr/src/utbot-cli.jar \

utbot-cli-python/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM azul/zulu-openjdk:11.0.15-11.56.19
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
WORKDIR /usr/src/
6+
7+
RUN apt-get update \
8+
&& apt-get install -y -q --no-install-recommends \
9+
curl \
10+
python3.9 \
11+
python3.9-distutils \
12+
&& rm -rf /var/lib/apt/lists/* \
13+
&& curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
14+
&& python3.9 get-pip.py \
15+
&& pip install -U \
16+
pytest
17+
18+
# Install UTBot Python CLI
19+
20+
ARG ARTIFACT_PATH
21+
COPY ${ARTIFACT_PATH} .
22+
23+
RUN UTBOT_PYTHON_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \
24+
&& ln -s "${UTBOT_PYTHON_CLI_PATH}" /usr/src/utbot-cli.jar
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
FROM azul/zulu-openjdk:11.0.15-11.56.19
22

3-
ARG UTBOT_JAVA_CLI
3+
ARG DEBIAN_FRONTEND=noninteractive
44

55
WORKDIR /usr/src/
66

7-
# Install UTBot Java CLI
8-
9-
COPY ${UTBOT_JAVA_CLI} .
10-
11-
RUN UTBOT_JAVA_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \
12-
&& ln -s "${UTBOT_JAVA_CLI_PATH}" /usr/src/utbot-cli.jar
13-
14-
# Install dependencies
15-
167
RUN apt-get update \
17-
&& apt-get install -y -q wget unzip \
18-
&& apt-get clean
8+
&& apt-get install -y -q --no-install-recommends \
9+
wget \
10+
unzip \
11+
&& rm -rf /var/lib/apt/lists/*
1912

2013
# Install Kotlin compiler
2114

2215
ENV KOTLIN_COMPILER_VERSION=1.7.0
2316
ENV KOTLIN_HOME="/opt/kotlin/kotlinc"
17+
ENV PATH="${KOTLIN_HOME}/bin:${PATH}"
2418

25-
RUN wget --no-verbose https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_COMPILER_VERSION}/kotlin-compiler-${KOTLIN_COMPILER_VERSION}.zip -O /tmp/${KOTLIN_COMPILER_VERSION}.zip && \
26-
unzip -q -d /opt/kotlin /tmp/${KOTLIN_COMPILER_VERSION}.zip
19+
RUN wget --no-verbose https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_COMPILER_VERSION}/kotlin-compiler-${KOTLIN_COMPILER_VERSION}.zip -O /tmp/${KOTLIN_COMPILER_VERSION}.zip \
20+
&& unzip -q -d /opt/kotlin /tmp/${KOTLIN_COMPILER_VERSION}.zip
2721

28-
ENV PATH="${KOTLIN_HOME}/bin:${PATH}"
22+
# Install UTBot Java CLI
23+
24+
ARG ARTIFACT_PATH
25+
COPY ${ARTIFACT_PATH} .
26+
27+
RUN UTBOT_JAVA_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \
28+
&& ln -s "${UTBOT_JAVA_CLI_PATH}" /usr/src/utbot-cli.jar

0 commit comments

Comments
 (0)