Skip to content

Commit aa8f7a9

Browse files
Reduce concurrent jobs number for projects (#945)
1 parent 8345714 commit aa8f7a9

File tree

2 files changed

+98
-19
lines changed

2 files changed

+98
-19
lines changed

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

Lines changed: 78 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ env:
2222
GRADLE_OPTS: "-XX:MaxHeapSize=2048m -Dorg.gradle.jvmargs='-XX:MaxHeapSize=2048m -XX:MaxPermSize=512m -Dorg.gradle.daemon=false' -Dorg.gradle.daemon=false"
2323

2424
jobs:
25-
prepare-tests-matrix:
25+
prepare-matrices:
2626
runs-on: ubuntu-latest
2727
# Outputs are used for passing data to dependent jobs.
2828
outputs:
29-
matrix: ${{ steps.set-matrix.outputs.matrix }}
29+
framework-tests-matrix: ${{ steps.set-matrices.outputs.framework-tests-matrix }}
30+
combined-projects-matrix: ${{ steps.set-matrices.outputs.combined-projects-matrix }}
3031
steps:
3132
- name: Print environment variables
3233
run: printenv
@@ -40,24 +41,23 @@ jobs:
4041
git config --global --add safe.directory ${GITHUB_WORKSPACE}
4142
git fetch
4243
git checkout ${{ github.event.inputs.commit_sha }}
43-
- id: set-matrix
44-
name: Read and print config from framework-tests-matrix.json
44+
- id: set-matrices
45+
name: Read and print config from framework-tests-matrix.json and combined-projects-matrix.json
4546
run: |
46-
TASKS=$(echo $(cat .github/workflows/framework-tests-matrix.json))
47-
echo "::set-output name=matrix::$TASKS"
48-
echo $TASKS
49-
50-
framework-test:
51-
# This job does not need to wait for 'prepare-tests-matrix' result.
52-
# GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them
53-
# to start execution early.
54-
needs: prepare-tests-matrix
55-
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
47+
FRAMEWORK_TESTS=$(echo $(cat .github/workflows/framework-tests-matrix.json))
48+
COMBINED_PROJECTS=$(echo $(cat .github/workflows/combined-projects-matrix.json))
49+
echo "::set-output name=framework-tests-matrix::$FRAMEWORK_TESTS"
50+
echo "::set-output name=combined-projects-matrix::$COMBINED_PROJECTS"
51+
echo $FRAMEWORK_TESTS
52+
echo $COMBINED_PROJECTS
53+
framework-tests:
54+
needs: prepare-matrices
55+
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
5656
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
5757
strategy:
5858
# The option forces to execute all jobs even though some of them have failed.
5959
fail-fast: false
60-
matrix: ${{ fromJson(needs.prepare-tests-matrix.outputs.matrix) }}
60+
matrix: ${{ fromJson(needs.prepare-matrices.outputs.framework-tests-matrix) }}
6161
runs-on: ubuntu-20.04
6262
container: unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
6363
steps:
@@ -103,16 +103,75 @@ jobs:
103103
name: test_report ${{ matrix.project.PART_NAME }}
104104
path: utbot-framework-test/build/reports/tests/test/*
105105

106+
combined-projects:
107+
# This job does not need to wait for 'prepare-tests-matrix' result.
108+
# GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them
109+
# to start execution early.
110+
needs: prepare-matrices
111+
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
112+
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
113+
strategy:
114+
# The option forces to execute all jobs even though some of them have failed.
115+
fail-fast: false
116+
matrix: ${{ fromJson(needs.prepare-matrices.outputs.combined-projects-matrix) }}
117+
runs-on: ubuntu-20.04
118+
container: unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
119+
steps:
120+
- name: Print environment variables
121+
run: printenv
122+
123+
- name: Checkout repository
124+
uses: actions/checkout@v3
125+
126+
- name: Check out ${{ github.event.inputs.commit_sha }} commit
127+
if: github.event.inputs.commit_sha != ''
128+
run: |
129+
git config --global --add safe.directory ${GITHUB_WORKSPACE}
130+
git fetch
131+
git checkout ${{ github.event.inputs.commit_sha }}
106132
107-
project:
108-
needs: prepare-tests-matrix
109-
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
133+
- name: Run monitoring
134+
run: |
135+
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
136+
chmod +x ./scripts/project/monitoring.sh
137+
./scripts/project/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
138+
- name: Build project ${{ matrix.projects.first }}
139+
id: first-project
140+
run: |
141+
cd ${{ matrix.projects.first }}
142+
gradle build --no-daemon
143+
- name: Build project ${{ matrix.projects.second }}
144+
if: ${{ steps.first-project.outcome != 'cancelled' && steps.first-project.outcome != 'skipped' }}
145+
run: |
146+
cd ${{ matrix.projects.second }}
147+
gradle build --no-daemon
148+
- name: Upload test report if tests have failed
149+
if: ${{ failure() }}
150+
uses: actions/upload-artifact@v3
151+
with:
152+
name: test_report ${{ matrix.projects.first }}
153+
path: ${{ matrix.projects.first }}/build/reports/tests/test/*
154+
155+
- name: Upload test report if tests have failed
156+
if: ${{ failure() }}
157+
uses: actions/upload-artifact@v3
158+
with:
159+
name: test_report ${{ matrix.projects.second }}
160+
path: ${{ matrix.projects.second }}/build/reports/tests/test/*
161+
162+
163+
single-project:
164+
# This job does not need to wait for 'prepare-tests-matrix' result.
165+
# GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them
166+
# to start execution early.
167+
needs: prepare-matrices
168+
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
110169
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
111170
strategy:
112171
# The option forces to execute all jobs even though some of them have failed.
113172
fail-fast: false
114173
matrix:
115-
project: [utbot-api, utbot-cli, utbot-core, utbot-framework, utbot-framework-api, utbot-fuzzers, utbot-gradle, utbot-instrumentation, utbot-instrumentation-tests, utbot-intellij, utbot-junit-contest, utbot-rd, utbot-sample, utbot-summary, utbot-summary-tests]
174+
project: [utbot-core, utbot-fuzzers, utbot-gradle, utbot-junit-contest, utbot-sample]
116175
runs-on: ubuntu-20.04
117176
container: unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
118177
steps:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"projects": [
3+
{
4+
"FIRST": "utbot-intellij",
5+
"SECOND": "utbot-cli",
6+
},
7+
{
8+
"FIRST": "utbot-instrumentation",
9+
"SECOND": "utbot-instrumentation-tests",
10+
},
11+
{
12+
"FIRST": "utbot-summary",
13+
"SECOND": "utbot-summary-tests",
14+
},
15+
{
16+
"FIRST": "utbot-api",
17+
"SECOND": "utbot-framework-api",
18+
}
19+
]
20+
}

0 commit comments

Comments
 (0)