@@ -2,36 +2,69 @@ name: "[M] UTBot Java: build and run tests"
2
2
3
3
on :
4
4
workflow_dispatch :
5
+ inputs :
6
+ commit_sha :
7
+ # read more about contexts: https://docs.github.com/en/actions/learn-github-actions/contexts#about-contexts
8
+ default : ${{ github.sha }}
9
+ required : false
10
+ type : string
11
+ description : " Commit SHA (optional)"
12
+
13
+ workflow_call :
14
+ inputs :
15
+ commit_sha :
16
+ default : ${{ github.sha }}
17
+ required : false
18
+ type : string
5
19
6
20
env :
7
21
REGISTRY : ghcr.io
8
22
IMAGE_NAME : utbot_java_cli
9
23
DOCKERFILE_PATH : docker/Dockerfile_java_cli
24
+ # Environment variable setting gradle options.
10
25
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"
11
26
12
27
jobs :
13
28
prepare-tests-matrix :
14
29
runs-on : ubuntu-latest
30
+ # Outputs are used for passing data to dependent jobs.
15
31
outputs :
16
32
matrix : ${{ steps.set-matrix.outputs.matrix }}
17
33
steps :
34
+ - name : Print environment variables
35
+ run : printenv
36
+
18
37
- name : Checkout repository
19
38
uses : actions/checkout@v3
39
+ with :
40
+ ref : ${{ github.event.inputs.commit_sha }}
41
+
20
42
- id : set-matrix
21
43
name : Read and print config from framework-tests-matrix.json
22
44
run : |
23
- TASKS=$(echo $( cat .github/workflows/framework-tests-matrix.json) )
45
+ TASKS=$(cat .github/workflows/framework-tests-matrix.json)
24
46
echo "::set-output name=matrix::$TASKS"
25
47
echo $TASKS
26
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.
27
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
28
55
strategy :
56
+ # The option forces to execute all jobs even though some of them have failed.
29
57
fail-fast : false
30
58
matrix : ${{ fromJson(needs.prepare-tests-matrix.outputs.matrix) }}
31
59
runs-on : ubuntu-20.04
32
60
container : unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
33
61
steps :
62
+ - name : Print environment variables
63
+ run : printenv
64
+
34
65
- uses : actions/checkout@v3
66
+ with :
67
+ ref : ${{ github.event.inputs.commit_sha }}
35
68
36
69
- name : Run monitoring
37
70
run : |
41
74
- name : Run tests
42
75
run : |
43
76
gradle --no-daemon :utbot-framework:test ${{ matrix.project.TESTS_TO_RUN }}
44
-
45
77
- name : Upload logs
46
78
if : ${{ always() }}
47
79
uses : actions/upload-artifact@v3
57
89
path : |
58
90
/tmp/UTBot/generated*/*
59
91
/tmp/UTBot/utbot-childprocess-errors/*
60
-
61
92
- name : Upload test report if tests have failed
62
93
if : ${{ failure() }}
63
94
uses : actions/upload-artifact@v3
@@ -67,29 +98,33 @@ jobs:
67
98
68
99
69
100
project :
70
- # This job does not need to wait for 'prepare-tests-matrix' result.
71
- # This is a hack to force GitHub to allocate runners for framework project first (as the project build requires much time).
72
101
needs : prepare-tests-matrix
102
+ # Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
103
+ # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
73
104
strategy :
105
+ # The option forces to execute all jobs even though some of them have failed.
74
106
fail-fast : false
75
107
matrix :
76
108
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]
77
109
runs-on : ubuntu-20.04
78
110
container : unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
79
111
steps :
112
+ - name : Print environment variables
113
+ run : printenv
114
+
80
115
- uses : actions/checkout@v3
116
+ with :
117
+ ref : ${{ github.event.inputs.commit_sha }}
81
118
82
119
- name : Run monitoring
83
120
run : |
84
121
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
85
122
chmod +x ./scripts/monitoring.sh
86
123
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
87
-
88
124
- name : Run tests
89
125
run : |
90
126
cd ${{ matrix.project }}
91
127
gradle build --no-daemon
92
-
93
128
- name : Upload test report if tests have failed
94
129
if : ${{ failure() }}
95
130
uses : actions/upload-artifact@v3
0 commit comments