Skip to content

Commit 985204b

Browse files
Update build-and-run-tests-from-branch.yml
1 parent b1919bc commit 985204b

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

.github/workflows/build-and-run-tests-from-branch.yml

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,69 @@ name: "[M] UTBot Java: build and run tests"
22

33
on:
44
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
519

620
env:
721
REGISTRY: ghcr.io
822
IMAGE_NAME: utbot_java_cli
923
DOCKERFILE_PATH: docker/Dockerfile_java_cli
24+
# Environment variable setting gradle options.
1025
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"
1126

1227
jobs:
1328
prepare-tests-matrix:
1429
runs-on: ubuntu-latest
30+
# Outputs are used for passing data to dependent jobs.
1531
outputs:
1632
matrix: ${{ steps.set-matrix.outputs.matrix }}
1733
steps:
34+
- name: Print environment variables
35+
run: printenv
36+
1837
- name: Checkout repository
1938
uses: actions/checkout@v3
39+
with:
40+
ref: ${{ github.event.inputs.commit_sha }}
41+
2042
- id: set-matrix
2143
name: Read and print config from framework-tests-matrix.json
2244
run: |
23-
TASKS=$(echo $(cat .github/workflows/framework-tests-matrix.json))
45+
TASKS=$(cat .github/workflows/framework-tests-matrix.json)
2446
echo "::set-output name=matrix::$TASKS"
2547
echo $TASKS
2648
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.
2752
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
2855
strategy:
56+
# The option forces to execute all jobs even though some of them have failed.
2957
fail-fast: false
3058
matrix: ${{ fromJson(needs.prepare-tests-matrix.outputs.matrix) }}
3159
runs-on: ubuntu-20.04
3260
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
3361
steps:
62+
- name: Print environment variables
63+
run: printenv
64+
3465
- uses: actions/checkout@v3
66+
with:
67+
ref: ${{ github.event.inputs.commit_sha }}
3568

3669
- name: Run monitoring
3770
run: |
@@ -41,7 +74,6 @@ jobs:
4174
- name: Run tests
4275
run: |
4376
gradle --no-daemon :utbot-framework:test ${{ matrix.project.TESTS_TO_RUN }}
44-
4577
- name: Upload logs
4678
if: ${{ always() }}
4779
uses: actions/upload-artifact@v3
@@ -57,7 +89,6 @@ jobs:
5789
path: |
5890
/tmp/UTBot/generated*/*
5991
/tmp/UTBot/utbot-childprocess-errors/*
60-
6192
- name: Upload test report if tests have failed
6293
if: ${{ failure() }}
6394
uses: actions/upload-artifact@v3
@@ -67,29 +98,33 @@ jobs:
6798

6899

69100
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).
72101
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
73104
strategy:
105+
# The option forces to execute all jobs even though some of them have failed.
74106
fail-fast: false
75107
matrix:
76108
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]
77109
runs-on: ubuntu-20.04
78110
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
79111
steps:
112+
- name: Print environment variables
113+
run: printenv
114+
80115
- uses: actions/checkout@v3
116+
with:
117+
ref: ${{ github.event.inputs.commit_sha }}
81118

82119
- name: Run monitoring
83120
run: |
84121
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
85122
chmod +x ./scripts/monitoring.sh
86123
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
87-
88124
- name: Run tests
89125
run: |
90126
cd ${{ matrix.project }}
91127
gradle build --no-daemon
92-
93128
- name: Upload test report if tests have failed
94129
if: ${{ failure() }}
95130
uses: actions/upload-artifact@v3

0 commit comments

Comments
 (0)