1212
1313env :
1414 REGISTRY : ghcr.io
15- IMAGE_NAME : utbot_java_cli
16- DOCKERFILE_PATH : docker/Dockerfile_java_cli
1715
1816jobs :
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
0 commit comments