Skip to content

Add python and js docker images building #942 #1764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2ed69bc
New images added #942
bissquit Jan 16, 2023
b050631
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Jan 23, 2023
1f47151
new images added #942
bissquit Jan 24, 2023
0d25acf
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Jan 26, 2023
a2c11cb
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Jan 26, 2023
e0c426e
docker images for python and js added #942
bissquit Jan 26, 2023
09258dd
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Jan 27, 2023
3252b01
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Jan 31, 2023
e50f6c2
reworked to build 3 images
bissquit Jan 31, 2023
893edc7
fix artifact path
bissquit Feb 1, 2023
38d1897
debug: building without pushing
bissquit Feb 1, 2023
cb68798
add tmate debug
bissquit Feb 1, 2023
ac559e4
disable fail-fast strategy
bissquit Feb 1, 2023
f62b2ab
syntax typo
bissquit Feb 1, 2023
50ea9e6
Attempt to fix JS CLI build
zishkaz Feb 3, 2023
31fe260
Added a flag to CLI build workflow
zishkaz Feb 3, 2023
752a730
Switched -D to -P in prop set flag
zishkaz Feb 3, 2023
a923b37
Merge branch 'egor-vasiliev/942-add-images' of https://github.com/Uni…
bissquit Feb 6, 2023
77243bd
main options of gradle.properties reverted back
bissquit Feb 6, 2023
55071ca
extra_options param added
bissquit Feb 6, 2023
272baf9
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Feb 6, 2023
e5fca0d
dockerfile names fixed
bissquit Feb 6, 2023
06534c6
testing image publishing
bissquit Feb 6, 2023
f2f3a13
image push disabled; variable generation improved
bissquit Feb 6, 2023
61a85bc
fix typo
bissquit Feb 6, 2023
3b81f3f
fix conflict
bissquit Feb 7, 2023
198042f
try to push images
bissquit Feb 7, 2023
fab9111
variables set reworked
bissquit Feb 7, 2023
3de48e9
fix dot
bissquit Feb 7, 2023
f52ca43
add image push
bissquit Feb 7, 2023
e5b1320
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Feb 7, 2023
0d01f26
java and js images temporary commented
bissquit Feb 7, 2023
3b9ad6b
test with pat token
bissquit Feb 8, 2023
38ce50d
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Feb 10, 2023
14f6edb
revert pass back
bissquit Feb 10, 2023
35591d6
build without cache
bissquit Feb 10, 2023
ba2a267
build and push switched to action
bissquit Feb 10, 2023
7ce0d16
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Feb 10, 2023
f8befb7
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Feb 20, 2023
7f67568
try to push
bissquit Feb 20, 2023
cd561b6
add permissions explicitly
bissquit Feb 21, 2023
b0271be
reduce permissions
bissquit Feb 21, 2023
b36380b
python image name changed
bissquit Feb 21, 2023
c4989b7
enable caching
bissquit Feb 21, 2023
a9d9e96
remove explicit permissions
bissquit Feb 21, 2023
d51b600
description about a bu
bissquit Feb 21, 2023
997dee9
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Feb 21, 2023
2c92df8
tests enabled
bissquit Feb 21, 2023
a169fc1
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Feb 27, 2023
ca25c6b
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Feb 28, 2023
4b9e472
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Feb 28, 2023
5fed6cf
Merge branch 'main' of https://github.com/UnitTestBot/UTBotJava into …
bissquit Mar 1, 2023
6e8a499
Fixing error building intellij plugin
zishkaz Mar 2, 2023
cbaa376
switched to prod behaviour
bissquit Mar 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 53 additions & 38 deletions .github/workflows/build-and-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: utbot_java_cli
DOCKERFILE_PATH: docker/Dockerfile_java_cli

jobs:
build-and-run-tests:
Expand All @@ -32,36 +30,40 @@ jobs:
publish-cli-image:
needs: build-and-run-tests
if: ${{ github.event_name == 'push' }}
strategy:
fail-fast: false # force to execute all jobs even though some of them have failed
matrix:
configuration:
- image_name: utbot_java_cli
directory: utbot-cli
extra_options: ""
- image_name: utbot_js_cli
directory: utbot-cli-js
extra_options: "-PbuildType=ALL"
# we can't use utbot_python_cli image name because of the bug while pushing image
# ERROR: unexpected status: 403 Forbidden
- image_name: utbot_py_cli
directory: utbot-cli-python
extra_options: ""
runs-on: ubuntu-20.04
container: unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
steps:
- name: Print environment variables
run: printenv

- uses: actions/checkout@v3

# "You can make an environment variable available to any subsequent steps in a workflow job by
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
- name: Set environment variables
run: |
# "You can make an environment variable available to any subsequent steps in a workflow job by
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
echo VERSION="$(date +%Y).$(date +%-m)" >> $GITHUB_ENV

- name: Build UTBot Java CLI
run: |
cd utbot-cli
gradle build --no-daemon --build-cache --no-parallel -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -x test -PsemVer=${{ env.VERSION }}
- name: Set docker tag
run:
# "You can make an environment variable available to any subsequent steps in a workflow job by
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
echo DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ github.sha }}" >> $GITHUB_ENV
echo DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-$(echo -n ${GITHUB_SHA} | cut -c 1-7)" >> $GITHUB_ENV

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Print environment variables
run: printenv

- name: Build UTBot CLI
run: |
cd ${{ matrix.configuration.directory }}
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 }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -71,32 +73,45 @@ jobs:
driver-opts: |
image=moby/buildkit:v0.10.6

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
key: ${{ runner.os }}-buildx-${{ matrix.configuration.image_name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
${{ runner.os }}-buildx-${{ matrix.configuration.image_name }}-

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.configuration.image_name }}
tags: |
type=raw,value=${{ env.DOCKER_TAG }}
- name: Docker Buildx (build and push)
run: |
docker buildx build \
-f ${{ env.DOCKERFILE_PATH }} \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache-new" \
--tag ${{ steps.meta.outputs.tags }} \
--build-arg UTBOT_JAVA_CLI=utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar \
--push .
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
file: ${{ matrix.configuration.directory }}/Dockerfile
build-args: |
ARTIFACT_PATH=${{ matrix.configuration.directory }}/build/libs/${{ matrix.configuration.directory }}-${{ env.VERSION }}.jar

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ kotlin.code.style=official
# IU, IC, PC, PY
# IC for AndroidStudio
ideType=IC
# ALL, NOJS
buildType=NOJS
ideVersion=222.4167.29

pythonIde=IC,IU,PC,PY
jsIde=IU,PY,WS
jsBuild=ALL
goIde=IU

# In order to run Android Studion instead of Intellij Community, specify the path to your Android Studio installation
Expand Down
4 changes: 3 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
val ideType: String by settings
val buildType: String by settings

val pythonIde: String by settings
val jsIde: String by settings
val jsBuild: String by settings
val includeRiderInBuild: String by settings
val goIde: String by settings

Expand Down Expand Up @@ -56,7 +58,7 @@ if (pythonIde.split(",").contains(ideType)) {
include("utbot-python-parser")
}

if (jsIde.split(",").contains(ideType)) {
if (jsBuild == buildType || jsIde.split(",").contains(ideType)) {
include("utbot-js")
include("utbot-cli-js")
include("utbot-intellij-js")
Expand Down
22 changes: 22 additions & 0 deletions utbot-cli-js/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM azul/zulu-openjdk:11.0.15-11.56.19

ARG DEBIAN_FRONTEND=noninteractive

WORKDIR /usr/src/

RUN apt-get update \
&& apt-get install -y -q --no-install-recommends \
curl \
&& curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh \
&& /bin/sh nodesource_setup.sh \
&& apt-get install -y -q --no-install-recommends \
nodejs \
&& rm -rf /var/lib/apt/lists/*

# Install UTBot Javascript CLI

ARG ARTIFACT_PATH
COPY ${ARTIFACT_PATH} .

RUN UTBOT_JS_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \
&& ln -s "${UTBOT_JS_CLI_PATH}" /usr/src/utbot-cli.jar \
24 changes: 24 additions & 0 deletions utbot-cli-python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM azul/zulu-openjdk:11.0.15-11.56.19

ARG DEBIAN_FRONTEND=noninteractive

WORKDIR /usr/src/

RUN apt-get update \
&& apt-get install -y -q --no-install-recommends \
curl \
python3.9 \
python3.9-distutils \
&& rm -rf /var/lib/apt/lists/* \
&& curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& python3.9 get-pip.py \
&& pip install -U \
pytest

# Install UTBot Python CLI

ARG ARTIFACT_PATH
COPY ${ARTIFACT_PATH} .

RUN UTBOT_PYTHON_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \
&& ln -s "${UTBOT_PYTHON_CLI_PATH}" /usr/src/utbot-cli.jar
30 changes: 15 additions & 15 deletions docker/Dockerfile_java_cli → utbot-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
FROM azul/zulu-openjdk:11.0.15-11.56.19

ARG UTBOT_JAVA_CLI
ARG DEBIAN_FRONTEND=noninteractive

WORKDIR /usr/src/

# Install UTBot Java CLI

COPY ${UTBOT_JAVA_CLI} .

RUN UTBOT_JAVA_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \
&& ln -s "${UTBOT_JAVA_CLI_PATH}" /usr/src/utbot-cli.jar

# Install dependencies

RUN apt-get update \
&& apt-get install -y -q wget unzip \
&& apt-get clean
&& apt-get install -y -q --no-install-recommends \
wget \
unzip \
&& rm -rf /var/lib/apt/lists/*

# Install Kotlin compiler

ENV KOTLIN_COMPILER_VERSION=1.7.0
ENV KOTLIN_HOME="/opt/kotlin/kotlinc"
ENV PATH="${KOTLIN_HOME}/bin:${PATH}"

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 && \
unzip -q -d /opt/kotlin /tmp/${KOTLIN_COMPILER_VERSION}.zip
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 \
&& unzip -q -d /opt/kotlin /tmp/${KOTLIN_COMPILER_VERSION}.zip

ENV PATH="${KOTLIN_HOME}/bin:${PATH}"
# Install UTBot Java CLI

ARG ARTIFACT_PATH
COPY ${ARTIFACT_PATH} .

RUN UTBOT_JAVA_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \
&& ln -s "${UTBOT_JAVA_CLI_PATH}" /usr/src/utbot-cli.jar