From 5685fd01c85023b11f7c66ce94c1c9268b8fbade Mon Sep 17 00:00:00 2001 From: Victoria <32179813+victoriafomina@users.noreply.github.com> Date: Tue, 2 Aug 2022 18:30:10 +0300 Subject: [PATCH 1/7] Delete get_java_cli_download_url.py --- docker/get_java_cli_download_url.py | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 docker/get_java_cli_download_url.py diff --git a/docker/get_java_cli_download_url.py b/docker/get_java_cli_download_url.py deleted file mode 100644 index ad2f6b03a5..0000000000 --- a/docker/get_java_cli_download_url.py +++ /dev/null @@ -1,14 +0,0 @@ -import json -import requests - -JAVA_ARTIFACTS_URL="https://api.github.com/repos/UnitTestBot/UTBotJava/actions/artifacts" - -request = requests.get(url = JAVA_ARTIFACTS_URL) -data = request.json() -artifacts = data['artifacts'] - -for artifact in artifacts: - if "utbot-cli" in artifact['name']: - print(artifact['archive_download_url']) - break - From 1fde2160b31cc0db6cc99a75512a90824c184c73 Mon Sep 17 00:00:00 2001 From: Victoria <32179813+victoriafomina@users.noreply.github.com> Date: Tue, 2 Aug 2022 18:30:28 +0300 Subject: [PATCH 2/7] Update Dockerfile_java_cli --- docker/Dockerfile_java_cli | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/docker/Dockerfile_java_cli b/docker/Dockerfile_java_cli index a084fcf0f9..500e019b40 100644 --- a/docker/Dockerfile_java_cli +++ b/docker/Dockerfile_java_cli @@ -1,25 +1,12 @@ FROM openjdk:8 -ARG ACCESS_TOKEN +ARG JAVA_CLI WORKDIR /usr/src/ -RUN apt-get update \ - && apt-get install -y curl \ - unzip \ - python3 \ - python3-requests \ - && apt-get clean - # Install UTBot Java CLI -COPY docker/get_java_cli_download_url.py . -ENV JAVA_CLI_ZIP_NAME "utbot_java_cli.zip" +COPY ${JAVA_CLI} . -RUN curl -H "Authorization: Bearer ${ACCESS_TOKEN}" \ - -L "$(python3 get_java_cli_download_url.py)" \ - -o "${JAVA_CLI_ZIP_NAME}" \ - && unzip "${JAVA_CLI_ZIP_NAME}" \ - && rm "${JAVA_CLI_ZIP_NAME}" \ - && JAVA_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \ +RUN JAVA_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \ && ln -s "${JAVA_CLI_PATH}" /usr/src/utbot-cli.jar From 06d92ec9bc5383c31636a73b2acfb67628984d30 Mon Sep 17 00:00:00 2001 From: Victoria <32179813+victoriafomina@users.noreply.github.com> Date: Tue, 2 Aug 2022 18:45:05 +0300 Subject: [PATCH 3/7] Java CLI Dockerfile: JAVA_CLI -> UTBOT_JAVA_CLI --- docker/Dockerfile_java_cli | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile_java_cli b/docker/Dockerfile_java_cli index 500e019b40..41ddf8d3d0 100644 --- a/docker/Dockerfile_java_cli +++ b/docker/Dockerfile_java_cli @@ -1,12 +1,12 @@ FROM openjdk:8 -ARG JAVA_CLI +ARG UTBOT_JAVA_CLI WORKDIR /usr/src/ # Install UTBot Java CLI -COPY ${JAVA_CLI} . +COPY ${UTBOT_JAVA_CLI} . -RUN JAVA_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \ - && ln -s "${JAVA_CLI_PATH}" /usr/src/utbot-cli.jar +RUN UTBOT_JAVA_CLI_PATH="$(find /usr/src -type f -name 'utbot-cli*')" \ + && ln -s "${UTBOT_JAVA_CLI_PATH}" /usr/src/utbot-cli.jar From fc0fb99b59a71f44f38ff513cbd6d8c99d10693d Mon Sep 17 00:00:00 2001 From: Victoria <32179813+victoriafomina@users.noreply.github.com> Date: Thu, 4 Aug 2022 11:07:47 +0300 Subject: [PATCH 4/7] Add build and publish CLI image --- .github/workflows/build-and-run-tests.yml | 59 +++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/.github/workflows/build-and-run-tests.yml b/.github/workflows/build-and-run-tests.yml index 30af5f45ad..3148560282 100644 --- a/.github/workflows/build-and-run-tests.yml +++ b/.github/workflows/build-and-run-tests.yml @@ -5,6 +5,11 @@ on: branches: [main] pull_request: branches: [main] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: utbot_java_cli + DOCKERFILE_PATH: docker/Dockerfile_java_cli jobs: build_and_run_tests: @@ -45,3 +50,57 @@ jobs: with: name: utbot_intellij_tests_report path: utbot-intellij/build/reports/tests/test/* + + - name: Set timezone + uses: szenius/set-timezone@v1.0 + with: + timezoneLinux: "Europe/Moscow" + + - name: Set environment variables + run: | + echo "COMMIT_SHORT_SHA="$(git rev-parse --short HEAD)"" >> $GITHUB_ENV + echo "VERSION="$(date +%Y).$(date +%-m)"" >> $GITHUB_ENV + - name: Set docker tag + run: + echo "DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ env.COMMIT_SHORT_SHA }}"" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.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: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache From 7031656747fd6b8dd59c32bded962f01433ff4ee Mon Sep 17 00:00:00 2001 From: Victoria <32179813+victoriafomina@users.noreply.github.com> Date: Thu, 4 Aug 2022 11:08:03 +0300 Subject: [PATCH 5/7] Delete publish-cli-image.yml --- .github/workflows/publish-cli-image.yml | 73 ------------------------- 1 file changed, 73 deletions(-) delete mode 100644 .github/workflows/publish-cli-image.yml diff --git a/.github/workflows/publish-cli-image.yml b/.github/workflows/publish-cli-image.yml deleted file mode 100644 index fbc98c35a9..0000000000 --- a/.github/workflows/publish-cli-image.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: "CLI: publish image" -on: - push: - branches: [main] - -env: - REGISTRY: ghcr.io - IMAGE_NAME: utbot_java_cli - DOCKERFILE_PATH: docker/Dockerfile_java_cli - -jobs: - build-and-publish-docker: - runs-on: ubuntu-20.04 - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set timezone - uses: szenius/set-timezone@v1.0 - with: - timezoneLinux: "Europe/Moscow" - - - name: Set environment variables - run: - echo "COMMIT_SHORT_SHA="$(git rev-parse --short HEAD)"" >> $GITHUB_ENV - - - name: Set docker tag - run: - echo "DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ env.COMMIT_SHORT_SHA }}"" >> $GITHUB_ENV - - - name: Log in to the Container registry - uses: docker/login-action@v1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Docker meta - id: meta - uses: docker/metadata-action@v3 - with: - images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.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 ACCESS_TOKEN=${{ secrets.GITHUB_TOKEN }} \ - --push . - - # 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 - mv /tmp/.buildx-cache-new /tmp/.buildx-cache From fd7a8eb8a13f13c0eeb2a4c8e5551e3d4149c02b Mon Sep 17 00:00:00 2001 From: Victoria <32179813+victoriafomina@users.noreply.github.com> Date: Thu, 4 Aug 2022 17:44:18 +0300 Subject: [PATCH 6/7] Add caching utbot-cli.jar --- .github/workflows/build-and-run-tests.yml | 41 +++++++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-run-tests.yml b/.github/workflows/build-and-run-tests.yml index 3148560282..71efd2e856 100644 --- a/.github/workflows/build-and-run-tests.yml +++ b/.github/workflows/build-and-run-tests.yml @@ -21,14 +21,31 @@ jobs: java-version: '8' distribution: 'zulu' java-package: jdk+fx + - uses: gradle/gradle-build-action@v2 with: gradle-version: 6.8 + + - name: Set project version + run: echo "VERSION="$(date +%Y).$(date +%-m)"" >> $GITHUB_ENV - name: Build and run tests in UTBot Java run: | export KOTLIN_HOME="/usr" - gradle clean build --no-daemon + gradle clean build --no-daemon -PsemVer=${{ env.VERSION }} + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + files: "**/build/test-results/**/*.xml" + + - name: Cache utbot-cli-${{ env.VERSION }}.jar + if: ${{ github.event_name != 'pull_request' }} + uses: actions/cache@v3 + with: + path: utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar + key: utbot-cli - name: Upload utbot-framework logs if: ${{ always() }} @@ -44,12 +61,13 @@ jobs: name: utbot_framework_tests_report path: utbot-framework/build/reports/tests/test/* - - name: Upload utbot-intellij tests report artifacts if tests have failed - if: ${{ failure() }} - uses: actions/upload-artifact@v2 - with: - name: utbot_intellij_tests_report - path: utbot-intellij/build/reports/tests/test/* + + publish_cli_image: + needs: build_and_run_tests + if: ${{ github.event_name != 'pull_request' }} + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 - name: Set timezone uses: szenius/set-timezone@v1.0 @@ -60,6 +78,12 @@ jobs: run: | echo "COMMIT_SHORT_SHA="$(git rev-parse --short HEAD)"" >> $GITHUB_ENV echo "VERSION="$(date +%Y).$(date +%-m)"" >> $GITHUB_ENV + + - uses: actions/cache@v3 + with: + path: utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar + key: utbot-cli + - name: Set docker tag run: echo "DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ env.COMMIT_SHORT_SHA }}"" >> $GITHUB_ENV @@ -81,6 +105,7 @@ jobs: key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- + - name: Docker meta id: meta uses: docker/metadata-action@v3 @@ -88,6 +113,7 @@ jobs: images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }} tags: | type=raw,value=${{ env.DOCKER_TAG }} + - name: Docker Buildx (build and push) run: | docker buildx build \ @@ -100,6 +126,7 @@ jobs: # 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 From 812169ed17fa6cbae19f8d9a5864bb283b195834 Mon Sep 17 00:00:00 2001 From: Victoria <32179813+victoriafomina@users.noreply.github.com> Date: Thu, 4 Aug 2022 17:52:08 +0300 Subject: [PATCH 7/7] Fix wordings in publish test results step --- .github/workflows/build-and-run-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-and-run-tests.yml b/.github/workflows/build-and-run-tests.yml index 71efd2e856..086842b618 100644 --- a/.github/workflows/build-and-run-tests.yml +++ b/.github/workflows/build-and-run-tests.yml @@ -34,14 +34,13 @@ jobs: export KOTLIN_HOME="/usr" gradle clean build --no-daemon -PsemVer=${{ env.VERSION }} - - name: Publish Test Results + - name: Publish test results uses: EnricoMi/publish-unit-test-result-action@v1 if: always() with: files: "**/build/test-results/**/*.xml" - name: Cache utbot-cli-${{ env.VERSION }}.jar - if: ${{ github.event_name != 'pull_request' }} uses: actions/cache@v3 with: path: utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar