@@ -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
0 commit comments