Skip to content

Commit 81f0b2e

Browse files
committed
Java 11 migration
1 parent 4a34d82 commit 81f0b2e

File tree

80 files changed

+1215
-655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1215
-655
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,145 @@
11
name: "[M] UTBot Java: build and run tests"
22

33
on:
4-
workflow_dispatch
5-
4+
workflow_dispatch:
5+
inputs:
6+
commit_sha:
7+
required: false
8+
type: string
9+
description: "Commit SHA (optional -- otherwise the last commit from the branch will be taken)"
10+
11+
workflow_call:
12+
inputs:
13+
commit_sha:
14+
required: false
15+
type: string
16+
17+
env:
18+
REGISTRY: ghcr.io
19+
IMAGE_NAME: utbot_java_cli
20+
DOCKERFILE_PATH: docker/Dockerfile_java_cli
21+
# Environment variable setting gradle options.
22+
GRADLE_OPTS: "-XX:MaxHeapSize=2048m -Dorg.gradle.jvmargs='-XX:MaxHeapSize=2048m -XX:MaxPermSize=512m -javaagent:/tmp/jmx-exporter.jar=12345:/tmp/jmx-exporter.yml -Dorg.gradle.daemon=false' -Dorg.gradle.daemon=false"
23+
624
jobs:
7-
build-and-run-tests:
8-
runs-on: ubuntu-20.04
25+
prepare-tests-matrix:
26+
runs-on: ubuntu-latest
27+
# Outputs are used for passing data to dependent jobs.
28+
outputs:
29+
matrix: ${{ steps.set-matrix.outputs.matrix }}
930
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-java@v2
12-
with:
13-
java-version: '8'
14-
distribution: 'zulu'
15-
java-package: jdk+fx
16-
cache: gradle
17-
- uses: gradle/gradle-build-action@v2
18-
with:
19-
gradle-version: 6.8
31+
- name: Print environment variables
32+
run: printenv
2033

21-
- name: Build and run tests in UTBot Java
34+
- name: Checkout repository
35+
uses: actions/checkout@v3
36+
37+
- name: Check out ${{ github.event.inputs.commit_sha }} commit
38+
if: github.event.inputs.commit_sha != ''
39+
run: |
40+
git fetch
41+
git checkout ${{ github.event.inputs.commit_sha }}
42+
- id: set-matrix
43+
name: Read and print config from framework-tests-matrix.json
44+
run: |
45+
TASKS=$(echo $(cat .github/workflows/framework-tests-matrix.json))
46+
echo "::set-output name=matrix::$TASKS"
47+
echo $TASKS
48+
framework:
49+
# This job does not need to wait for 'prepare-tests-matrix' result.
50+
# GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them
51+
# to start execution early.
52+
needs: prepare-tests-matrix
53+
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
54+
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
55+
strategy:
56+
# The option forces to execute all jobs even though some of them have failed.
57+
fail-fast: false
58+
matrix: ${{ fromJson(needs.prepare-tests-matrix.outputs.matrix) }}
59+
runs-on: ubuntu-20.04
60+
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
61+
steps:
62+
- name: Print environment variables
63+
run: printenv
64+
65+
- name: Checkout repository
66+
uses: actions/checkout@v3
67+
68+
- name: Check out ${{ github.event.inputs.commit_sha }} commit
69+
if: github.event.inputs.commit_sha != ''
2270
run: |
23-
export KOTLIN_HOME="/usr"
24-
gradle clean build --no-daemon
25-
26-
- name: Upload utbot-framework logs
71+
git fetch
72+
git checkout ${{ github.event.inputs.commit_sha }}
73+
- name: Run monitoring
74+
run: |
75+
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
76+
chmod +x ./scripts/monitoring.sh
77+
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
78+
- name: Run tests
79+
run: |
80+
gradle --no-daemon :utbot-framework:test ${{ matrix.project.TESTS_TO_RUN }}
81+
- name: Upload logs
2782
if: ${{ always() }}
28-
uses: actions/upload-artifact@v2
83+
uses: actions/upload-artifact@v3
2984
with:
30-
name: utbot_framework_logs
85+
name: logs ${{ matrix.project.PART_NAME }}
3186
path: utbot-framework/logs/*
32-
33-
- name: Upload utbot-framework tests report artifacts if tests have failed
87+
88+
- name: Upload UTBot temp directory content
89+
if: ${{ always() }}
90+
uses: actions/upload-artifact@v3
91+
with:
92+
name: utbot_temp ${{ matrix.project.PART_NAME }}
93+
path: |
94+
/tmp/UTBot/generated*/*
95+
/tmp/UTBot/utbot-childprocess-errors/*
96+
- name: Upload test report if tests have failed
3497
if: ${{ failure() }}
35-
uses: actions/upload-artifact@v2
98+
uses: actions/upload-artifact@v3
3699
with:
37-
name: utbot_framework_tests_report
100+
name: test_report ${{ matrix.project.PART_NAME }}
38101
path: utbot-framework/build/reports/tests/test/*
39-
40-
- name: Upload utbot-intellij tests report artifacts if tests have failed
102+
103+
104+
project:
105+
needs: prepare-tests-matrix
106+
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
107+
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
108+
strategy:
109+
# The option forces to execute all jobs even though some of them have failed.
110+
fail-fast: false
111+
matrix:
112+
project: [utbot-api, utbot-cli, utbot-core, utbot-framework-api, utbot-fuzzers, utbot-gradle, utbot-instrumentation, utbot-instrumentation-tests, utbot-intellij, utbot-junit-contest, utbot-sample, utbot-summary, utbot-summary-tests]
113+
runs-on: ubuntu-20.04
114+
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
115+
steps:
116+
- name: Print environment variables
117+
run: printenv
118+
119+
- name: Checkout repository
120+
uses: actions/checkout@v3
121+
122+
- name: Check out ${{ github.event.inputs.commit_sha }} commit
123+
if: github.event.inputs.commit_sha != ''
124+
run: |
125+
git fetch
126+
git checkout ${{ github.event.inputs.commit_sha }}
127+
- uses: actions/checkout@v3
128+
with:
129+
ref: ${{ env.COMMIT_SHA }}
130+
131+
- name: Run monitoring
132+
run: |
133+
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
134+
chmod +x ./scripts/monitoring.sh
135+
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
136+
- name: Run tests
137+
run: |
138+
cd ${{ matrix.project }}
139+
gradle build --no-daemon
140+
- name: Upload test report if tests have failed
41141
if: ${{ failure() }}
42-
uses: actions/upload-artifact@v2
142+
uses: actions/upload-artifact@v3
43143
with:
44-
name: utbot_intellij_tests_report
45-
path: utbot-intellij/build/reports/tests/test/*
144+
name: test_report ${{ matrix.project }}
145+
path: ${{ matrix.project }}/build/reports/tests/test/*
+72-32
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,87 @@
11
name: "UTBot Java: build and run tests"
22

3-
on:
3+
on:
44
push:
55
branches: [main]
66
pull_request:
77
branches: [main]
88

9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: utbot_java_cli
12+
DOCKERFILE_PATH: docker/Dockerfile_java_cli
13+
# Environment variable setting gradle options.
14+
GRADLE_OPTS: "-XX:MaxHeapSize=2048m -Dorg.gradle.jvmargs='-XX:MaxHeapSize=2048m -XX:MaxPermSize=512m -javaagent:/tmp/jmx-exporter.jar=12345:/tmp/jmx-exporter.yml -Dorg.gradle.daemon=false' -Dorg.gradle.daemon=false"
15+
916
jobs:
10-
build_and_run_tests:
17+
build-and-run-tests:
18+
uses: ./.github/workflows/build-and-run-tests-from-branch.yml
19+
20+
21+
publish-cli-image:
22+
needs: build-and-run-tests
23+
if: ${{ github.event_name == 'push' }}
1124
runs-on: ubuntu-20.04
25+
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
1226
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-java@v2
15-
with:
16-
java-version: '8'
17-
distribution: 'zulu'
18-
java-package: jdk+fx
19-
- uses: gradle/gradle-build-action@v2
20-
with:
21-
gradle-version: 6.8
22-
23-
- name: Build and run tests in UTBot Java
27+
- name: Print environment variables
28+
run: printenv
29+
30+
- uses: actions/checkout@v3
31+
32+
- name: Set environment variables
2433
run: |
25-
export KOTLIN_HOME="/usr"
26-
gradle clean build --no-daemon
34+
# "You can make an environment variable available to any subsequent steps in a workflow job by
35+
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
36+
echo VERSION="$(date +%Y).$(date +%-m)" >> $GITHUB_ENV
2737
28-
- name: Upload utbot-framework logs
29-
if: ${{ always() }}
30-
uses: actions/upload-artifact@v2
38+
- name: Build UTBot Java CLI
39+
run: |
40+
cd utbot-cli
41+
gradle build --no-daemon -x test -PsemVer=${{ env.VERSION }}
42+
- name: Set docker tag
43+
run:
44+
# "You can make an environment variable available to any subsequent steps in a workflow job by
45+
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
46+
echo DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ github.sha }}" >> $GITHUB_ENV
47+
48+
- name: Log in to the Container registry
49+
uses: docker/login-action@v2
3150
with:
32-
name: utbot_framework_logs
33-
path: utbot-framework/logs/*
34-
35-
- name: Upload utbot-framework tests report artifacts if tests have failed
36-
if: ${{ failure() }}
37-
uses: actions/upload-artifact@v2
51+
registry: ${{ env.REGISTRY }}
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v2
57+
58+
- name: Cache Docker layers
59+
uses: actions/cache@v3
3860
with:
39-
name: utbot_framework_tests_report
40-
path: utbot-framework/build/reports/tests/test/*
41-
42-
- name: Upload utbot-intellij tests report artifacts if tests have failed
43-
if: ${{ failure() }}
44-
uses: actions/upload-artifact@v2
61+
path: /tmp/.buildx-cache
62+
key: ${{ runner.os }}-buildx-${{ github.sha }}
63+
restore-keys: |
64+
${{ runner.os }}-buildx-
65+
- name: Docker meta
66+
id: meta
67+
uses: docker/metadata-action@v3
4568
with:
46-
name: utbot_intellij_tests_report
47-
path: utbot-intellij/build/reports/tests/test/*
69+
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
70+
tags: |
71+
type=raw,value=${{ env.DOCKER_TAG }}
72+
- name: Docker Buildx (build and push)
73+
run: |
74+
docker buildx build \
75+
-f ${{ env.DOCKERFILE_PATH }} \
76+
--cache-from "type=local,src=/tmp/.buildx-cache" \
77+
--cache-to "type=local,dest=/tmp/.buildx-cache-new" \
78+
--tag ${{ steps.meta.outputs.tags }} \
79+
--build-arg UTBOT_JAVA_CLI=utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar \
80+
--push .
81+
# Temp fix
82+
# https://github.com/docker/build-push-action/issues/252
83+
# https://github.com/moby/buildkit/issues/1896
84+
- name: Move cache
85+
run: |
86+
rm -rf /tmp/.buildx-cache
87+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"project": [
3+
{
4+
"PART_NAME": "composite",
5+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.manual.*\" --tests \"org.utbot.examples.stream.*\" --tests \"org.utbot.engine.*\" --tests \"org.utbot.framework.*\" --tests \"org.utbot.sarif.*\"",
6+
},
7+
{
8+
"PART_NAME": "collections-part1",
9+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.CustomerExamplesTest\" --tests \"org.utbot.examples.collections.GenericListsExampleTest\" --tests \"org.utbot.examples.collections.LinkedListsTest\" --tests \"org.utbot.examples.collections.ListAlgorithmsTest\" --tests \"org.utbot.examples.collections.ListIteratorsTest\" --tests \"org.utbot.examples.collections.ListWrapperReturnsVoidTest\" --tests \"org.utbot.examples.collections.MapEntrySetTest\" --tests \"org.utbot.examples.collections.MapKeySetTest\"",
10+
},
11+
{
12+
"PART_NAME": "collections-part2",
13+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapValuesTest\" --tests \"org.utbot.examples.collections.OptionalsTest\" --tests \"org.utbot.examples.collections.SetIteratorsTest\"",
14+
},
15+
{
16+
"PART_NAME": "collections-part3",
17+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.SetsTest\"",
18+
},
19+
{
20+
"PART_NAME": "examples-part1",
21+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.algorithms.*\" --tests \"org.utbot.examples.annotations.*\" --tests \"org.utbot.examples.arrays.*\" --tests \"org.utbot.examples.casts.*\" --tests \"org.utbot.examples.codegen.*\" --tests \"org.utbot.examples.controlflow.*\" --tests \"org.utbot.examples.enums.*\"",
22+
},
23+
{
24+
"PART_NAME": "examples-part2",
25+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.exceptions.*\" --tests \"org.utbot.examples.invokes.*\" --tests \"org.utbot.examples.lambda.*\" --tests \"org.utbot.examples.make.symbolic.*\" --tests \"org.utbot.examples.math.*\"",
26+
},
27+
{
28+
"PART_NAME": "examples-part3",
29+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.mixed.*\" --tests \"org.utbot.examples.mock.*\" --tests \"org.utbot.examples.models.*\" --tests \"org.utbot.examples.natives.*\" --tests \"org.utbot.examples.objects.*\" --tests \"org.utbot.examples.primitives.*\" --tests \"org.utbot.examples.recursion.*\"",
30+
},
31+
{
32+
"PART_NAME": "examples-part4",
33+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.statics.substitution.*\" --tests \"org.utbot.examples.stdlib.*\" --tests \"org.utbot.examples.structures.*\" --tests \"org.utbot.examples.thirdparty.numbers.*\" --tests \"org.utbot.examples.types.*\" --tests \"org.utbot.examples.unsafe.*\" --tests \"org.utbot.examples.wrappers.*\"",
34+
},
35+
{
36+
"PART_NAME": "examples-lists-part1",
37+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.ListsPart1Test\"",
38+
},
39+
{
40+
"PART_NAME": "examples-lists-part2",
41+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.ListsPart2Test\"",
42+
},
43+
{
44+
"PART_NAME": "examples-lists-part3",
45+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.ListsPart3Test\"",
46+
},
47+
{
48+
"PART_NAME": "examples-maps-part1",
49+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapsPart1Test\"",
50+
},
51+
{
52+
"PART_NAME": "examples-maps-part2",
53+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapsPart2Test\"",
54+
},
55+
{
56+
"PART_NAME": "examples-strings",
57+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.strings.*\"",
58+
}
59+
]
60+
}

0 commit comments

Comments
 (0)