Skip to content

Commit 1ab8f2c

Browse files
authored
Gradle cache usage added #974 (#998)
1 parent 19b0f78 commit 1ab8f2c

3 files changed

+93
-60
lines changed

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

+78-45
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,41 @@ jobs:
6666

6767
- name: Checkout repository
6868
uses: actions/checkout@v3
69-
7069
- name: Check out ${{ github.event.inputs.commit_sha }} commit
7170
if: github.event.inputs.commit_sha != ''
7271
run: |
7372
git config --global --add safe.directory ${GITHUB_WORKSPACE}
7473
git fetch
7574
git checkout ${{ github.event.inputs.commit_sha }}
75+
7676
- name: Run monitoring
7777
run: |
7878
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
7979
chmod +x ./scripts/project/monitoring.sh
8080
./scripts/project/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
81+
82+
# cache will use the key you provided and contains the files you specify in path.
83+
#
84+
# When key matches an existing cache, it's called a cache hit, and the action
85+
# restores the cached files to the path directory.
86+
# When key doesn't match an existing cache, it's called a cache miss, and a new
87+
# cache is automatically created if the job completes successfully.
88+
#
89+
# The cache action first searches for cache hits for key and restore-keys in the
90+
# branch containing the workflow run. If there are no hits in the current branch,
91+
# the cache action searches for key and restore-keys in the parent branch and
92+
# upstream branches.
93+
- uses: actions/cache@v3
94+
with:
95+
path: /root/.gradle/caches
96+
# key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle', '*.gradle.kts', './*.gradle', './*.gradle.kts') }}
97+
# hashFiles returns a single hash for the set of files that matches the path pattern
98+
key: ${{ runner.os }}-gradle-framework-${{ hashFiles('./*.gradle*', './utbot-framework*/*.gradle*') }}
99+
restore-keys: ${{ runner.os }}-gradle-framework
81100
- name: Run tests
82101
run: |
83-
gradle --no-daemon :utbot-framework-test:test ${{ matrix.project.TESTS_TO_RUN }}
102+
gradle --build-cache --no-daemon :utbot-framework-test:test ${{ matrix.project.TESTS_TO_RUN }}
103+
84104
- name: Upload logs
85105
if: ${{ always() }}
86106
uses: actions/upload-artifact@v3
@@ -117,47 +137,54 @@ jobs:
117137
runs-on: ubuntu-20.04
118138
container: unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
119139
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 }}
132-
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/*
140+
- name: Print environment variables
141+
run: printenv
142+
143+
- name: Checkout repository
144+
uses: actions/checkout@v3
145+
- name: Check out ${{ github.event.inputs.commit_sha }} commit
146+
if: github.event.inputs.commit_sha != ''
147+
run: |
148+
git config --global --add safe.directory ${GITHUB_WORKSPACE}
149+
git fetch
150+
git checkout ${{ github.event.inputs.commit_sha }}
151+
152+
- name: Run monitoring
153+
run: |
154+
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
155+
chmod +x ./scripts/project/monitoring.sh
156+
./scripts/project/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
157+
158+
- uses: actions/cache@v3
159+
with:
160+
path: /root/.gradle/caches
161+
key: ${{ runner.os }}-gradle-combined-${{ hashFiles('./*.gradle*', './*/.gradle*') }}
162+
restore-keys: ${{ runner.os }}-gradle-combined-
163+
- name: Build project ${{ matrix.projects.first }}
164+
id: first-project
165+
run: |
166+
cd ${{ matrix.projects.first }}
167+
gradle build --build-cache --no-daemon
168+
169+
- name: Build project ${{ matrix.projects.second }}
170+
if: ${{ steps.first-project.outcome != 'cancelled' && steps.first-project.outcome != 'skipped' }}
171+
run: |
172+
cd ${{ matrix.projects.second }}
173+
gradle build --build-cache --no-daemon
174+
175+
- name: Upload test report if tests have failed
176+
if: ${{ failure() }}
177+
uses: actions/upload-artifact@v3
178+
with:
179+
name: test_report ${{ matrix.projects.first }}
180+
path: ${{ matrix.projects.first }}/build/reports/tests/test/*
181+
182+
- name: Upload test report if tests have failed
183+
if: ${{ failure() }}
184+
uses: actions/upload-artifact@v3
185+
with:
186+
name: test_report ${{ matrix.projects.second }}
187+
path: ${{ matrix.projects.second }}/build/reports/tests/test/*
161188

162189

163190
single-project:
@@ -180,7 +207,6 @@ jobs:
180207

181208
- name: Checkout repository
182209
uses: actions/checkout@v3
183-
184210
- name: Check out ${{ github.event.inputs.commit_sha }} commit
185211
if: github.event.inputs.commit_sha != ''
186212
run: |
@@ -193,10 +219,17 @@ jobs:
193219
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
194220
chmod +x ./scripts/project/monitoring.sh
195221
./scripts/project/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
222+
223+
- uses: actions/cache@v3
224+
with:
225+
path: /root/.gradle/caches
226+
key: ${{ runner.os }}-gradle-${{ matrix.project }}-${{ hashFiles('./*.gradle*', format('{0}{1}{2}', './', matrix.project, '/*.gradle*')) }}
227+
restore-keys: ${{ runner.os }}-gradle-${{ matrix.project }}-
196228
- name: Run tests
197229
run: |
198230
cd ${{ matrix.project }}
199-
gradle build --no-daemon
231+
gradle build --build-cache --no-daemon
232+
200233
- name: Upload test report if tests have failed
201234
if: ${{ failure() }}
202235
uses: actions/upload-artifact@v3

.github/workflows/combined-projects-matrix.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
"projects": [
33
{
44
"FIRST": "utbot-intellij",
5-
"SECOND": "utbot-cli",
5+
"SECOND": "utbot-cli"
66
},
77
{
88
"FIRST": "utbot-instrumentation",
9-
"SECOND": "utbot-instrumentation-tests",
9+
"SECOND": "utbot-instrumentation-tests"
1010
},
1111
{
1212
"FIRST": "utbot-summary",
13-
"SECOND": "utbot-summary-tests",
13+
"SECOND": "utbot-summary-tests"
1414
},
1515
{
1616
"FIRST": "utbot-api",
17-
"SECOND": "utbot-framework-api",
17+
"SECOND": "utbot-framework-api"
1818
}
1919
]
2020
}

.github/workflows/framework-tests-matrix.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@
22
"project": [
33
{
44
"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.*\"",
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.*\""
66
},
77
{
88
"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\"",
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\""
1010
},
1111
{
1212
"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\"",
13+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapValuesTest\" --tests \"org.utbot.examples.collections.OptionalsTest\" --tests \"org.utbot.examples.collections.SetIteratorsTest\""
1414
},
1515
{
1616
"PART_NAME": "collections-part3",
17-
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.SetsTest\"",
17+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.SetsTest\""
1818
},
1919
{
2020
"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.*\"",
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.*\""
2222
},
2323
{
2424
"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.*\" --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.*\"",
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.*\" --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.*\""
2626
},
2727
{
2828
"PART_NAME": "examples-part3",
29-
"TESTS_TO_RUN": "--tests \"org.utbot.examples.primitives.*\" --tests \"org.utbot.examples.recursion.*\" --tests \"org.utbot.examples.statics.substitution.*\" --tests \"org.utbot.examples.stdlib.*\" --tests \"org.utbot.examples.strings.*\" --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.*\"",
29+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.primitives.*\" --tests \"org.utbot.examples.recursion.*\" --tests \"org.utbot.examples.statics.substitution.*\" --tests \"org.utbot.examples.stdlib.*\" --tests \"org.utbot.examples.strings.*\" --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.*\""
3030
},
3131
{
32-
"PART_NAME": "examples-lists",
33-
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.ListsPart1Test\" --tests \"org.utbot.examples.collections.ListsPart2Test\" --tests \"org.utbot.examples.collections.ListsPart3Test\"",
32+
"PART_NAME": "examples-lists",
33+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.ListsPart1Test\" --tests \"org.utbot.examples.collections.ListsPart2Test\" --tests \"org.utbot.examples.collections.ListsPart3Test\""
3434
},
3535
{
3636
"PART_NAME": "examples-maps-part1",
37-
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapsPart1Test\"",
37+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapsPart1Test\""
3838
},
3939
{
4040
"PART_NAME": "examples-maps-part2",
41-
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapsPart2Test\"",
41+
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapsPart2Test\""
4242
}
4343
]
4444
}

0 commit comments

Comments
 (0)