From 19c113be25dd27a821a88e5ca78bdbbccbde1b94 Mon Sep 17 00:00:00 2001 From: Victoria <32179813+victoriafomina@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:34:24 +0300 Subject: [PATCH 1/3] Create Dockerfile_c_family_cli --- docker/Dockerfile_c_family_cli | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docker/Dockerfile_c_family_cli diff --git a/docker/Dockerfile_c_family_cli b/docker/Dockerfile_c_family_cli new file mode 100644 index 000000000..c73ebf243 --- /dev/null +++ b/docker/Dockerfile_c_family_cli @@ -0,0 +1,35 @@ +FROM ubuntu:bionic-20220531 + +ARG ACCESS_TOKEN + +RUN apt-get update \ + && apt-get install -y build-essential \ + software-properties-common \ + && add-apt-repository -y ppa:ubuntu-toolchain-r/test \ + && apt-get update \ + && apt-get install -y gcc-9 \ + g++-9 \ + curl \ + unzip \ + python3 \ + python3-requests \ + && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9 \ + && update-alternatives --config gcc \ + && apt-get clean + +WORKDIR /usr/src/ + +# Install UTBot C/C++ CLI +COPY docker/get_c_family_cli_download_url.py . + +ENV C_FAMILY_CLI_ZIP_NAME "utbot_distr.zip" + +RUN curl -H "Authorization: Bearer ${ACCESS_TOKEN}" \ + -L $(python3 get_c_family_cli_download_url.py) \ + -o "${C_FAMILY_CLI_ZIP_NAME}" \ + && unzip -q "${C_FAMILY_CLI_ZIP_NAME}" \ + && find . ! -name 'utbot_distr.tar.gz' -type f -exec rm -f {} + \ + && mkdir utbot-cli \ + && tar -xf utbot_distr.tar.gz -C utbot-cli \ + && chmod +x utbot-cli/utbot_distr/utbot_online_cli.sh \ + && chmod +x utbot-cli/utbot_distr/utbot_run_system.sh From d7df027215c5d5226e189c6ef488c9c992b21ca6 Mon Sep 17 00:00:00 2001 From: Victoria <32179813+victoriafomina@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:34:50 +0300 Subject: [PATCH 2/3] Create get_c_family_cli_download_url.py --- docker/get_c_family_cli_download_url.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docker/get_c_family_cli_download_url.py diff --git a/docker/get_c_family_cli_download_url.py b/docker/get_c_family_cli_download_url.py new file mode 100644 index 000000000..e3cc58a6b --- /dev/null +++ b/docker/get_c_family_cli_download_url.py @@ -0,0 +1,13 @@ +import json +import requests + +C_FAMILY_ARTIFACTS_URL="https://api.github.com/repos/UnitTestBot/UTBotCPP/actions/artifacts" + +request = requests.get(url = C_FAMILY_ARTIFACTS_URL) +data = request.json() +artifacts = data['artifacts'] + +for artifact in artifacts: + if "utbot-dev" in artifact['name']: + print(artifact['archive_download_url']) + break From 56651c3ae4414357565293d61c05ed224f8280d0 Mon Sep 17 00:00:00 2001 From: Victoria <32179813+victoriafomina@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:36:06 +0300 Subject: [PATCH 3/3] Create publish-c-family-cli-image.yml --- .../workflows/publish-c-family-cli-image.yml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/publish-c-family-cli-image.yml diff --git a/.github/workflows/publish-c-family-cli-image.yml b/.github/workflows/publish-c-family-cli-image.yml new file mode 100644 index 000000000..057161b5e --- /dev/null +++ b/.github/workflows/publish-c-family-cli-image.yml @@ -0,0 +1,72 @@ +name: Publish UTBot CLI image +on: + push: + branches: [main] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: utbot_c_family_cli + DOCKERFILE_PATH: docker/Dockerfile_c_family_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