diff --git a/.github/workflows/build-and-run-tests.yml b/.github/workflows/build-and-run-tests.yml index 328b225625..5a3949e757 100644 --- a/.github/workflows/build-and-run-tests.yml +++ b/.github/workflows/build-and-run-tests.yml @@ -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: @@ -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 @@ -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 diff --git a/gradle.properties b/gradle.properties index 5525b6883f..56447555bc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/settings.gradle.kts b/settings.gradle.kts index 7edadaef5c..8337e46250 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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 @@ -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") diff --git a/utbot-cli-js/Dockerfile b/utbot-cli-js/Dockerfile new file mode 100644 index 0000000000..6eb099837d --- /dev/null +++ b/utbot-cli-js/Dockerfile @@ -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 \ diff --git a/utbot-cli-python/Dockerfile b/utbot-cli-python/Dockerfile new file mode 100644 index 0000000000..6a76e29d21 --- /dev/null +++ b/utbot-cli-python/Dockerfile @@ -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 diff --git a/docker/Dockerfile_java_cli b/utbot-cli/Dockerfile similarity index 61% rename from docker/Dockerfile_java_cli rename to utbot-cli/Dockerfile index efa85d5cad..81d1df8855 100644 --- a/docker/Dockerfile_java_cli +++ b/utbot-cli/Dockerfile @@ -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