Skip to content

Commit 5d8a2fc

Browse files
committed
Display test results as a badge and action job summary
A single build executes ~9 million tests in order to cover the api, feature matrix, linearization, Guava compatibility, and 98^ code coverage. A build is performed on JDK 11 and 18 (x86) and 17 (arm64), where the ARM run assert that there are no latent bugs due to a weaker memory model. This takes ~2.5 hours despite using parallel tests and jobs. As it is hard to track our test size, the JDK 18 run is used as the reference. The test results are aggregated and published to have some visibility. We do not count the JDK 11 x86 and JDK 17 arm64 runs as repeats.
1 parent 2284be5 commit 5d8a2fc

6 files changed

Lines changed: 148 additions & 79 deletions

File tree

.github/scripts/test.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ GUAVA_STRONG_KEYS=
88
GUAVA_WEAK_KEYS=
99
GUAVA_CHECK=
1010

11+
if [[ -z "$@" ]]; then
12+
echo "Please specify the test suites to run"
13+
echo " --caffeine=[strongKeys, weakKeys, check]"
14+
echo " --guava=[strongKeys, weakKeys, check]"
15+
echo " --all"
16+
exit 1
17+
fi
18+
1119
for i in "$@"; do
1220
case $i in
1321
--caffeine=strongKeys)
@@ -37,7 +45,11 @@ for i in "$@"; do
3745
GUAVA_CHECK=true
3846
;;
3947
-*)
40-
echo "Unknown option $i; --caffeine=? or --guava=? with strongKeys, weakKeys, or check"
48+
echo "Please specify the test suites to run"
49+
echo " --caffeine=[strongKeys, weakKeys, check]"
50+
echo " --guava=[strongKeys, weakKeys, check]"
51+
echo " --all"
52+
echo "Unknown option $i"
4153
exit 1
4254
;;
4355
esac

.github/workflows/build.yml

Lines changed: 130 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,40 @@ jobs:
5757
- name: Setup Gradle
5858
uses: gradle/gradle-build-action@v2
5959
- name: Run tests
60-
run: ./.github/scripts/test.sh --caffeine=strongKeys --caffeine=weakKeys --caffeine=check
60+
run: |
61+
stopMarker=$(uuidgen)
62+
echo "::stop-commands::$stopMarker"
63+
trap "echo '::$stopMarker::'" EXIT
64+
./.github/scripts/test.sh \
65+
--caffeine=strongKeys \
66+
--caffeine=weakKeys \
67+
--caffeine=check
68+
- name: Compress test results
69+
uses: sibiraj-s/action-archiver@v1
70+
if: always() && (matrix.java == env.MAX_JVM)
71+
with:
72+
path: '**/results/*.xml'
73+
output: caffeine.tar.gz
74+
format: tar
75+
gzip: true
6176
- name: Upload test results
6277
uses: actions/upload-artifact@v3
63-
if: (matrix.java == env.MAX_JVM) && always()
78+
if: always() && (matrix.java == env.MAX_JVM)
6479
with:
6580
retention-days: 1
6681
name: caffeine-test-results
67-
path: '**/results/*.xml'
82+
path: caffeine.tar.gz
6883
- name: Publish Coverage
6984
if: >
7085
matrix.java == env.MAX_JVM
7186
&& github.event_name == 'push'
7287
env:
7388
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
74-
run: ./gradlew --daemon coveralls -S
89+
run: |
90+
stopMarker=$(uuidgen)
91+
echo "::stop-commands::$stopMarker"
92+
trap "echo '::$stopMarker::'" EXIT
93+
./gradlew --daemon coveralls -S
7594
continue-on-error: true
7695
- name: SonarQube
7796
if: >
@@ -81,6 +100,9 @@ jobs:
81100
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82101
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
83102
run: |
103+
stopMarker=$(uuidgen)
104+
echo "::stop-commands::$stopMarker"
105+
trap "echo '::$stopMarker::'" EXIT
84106
git fetch --unshallow
85107
./gradlew --daemon sonarqube -S -Dsonar.branch.name=${GITHUB_REF##*/}
86108
continue-on-error: true
@@ -129,14 +151,29 @@ jobs:
129151
- name: Setup Gradle
130152
uses: gradle/gradle-build-action@v2
131153
- name: Run tests
132-
run: ./.github/scripts/test.sh --guava=strongKeys --guava=weakKeys --guava=check
154+
run: |
155+
stopMarker=$(uuidgen)
156+
echo "::stop-commands::$stopMarker"
157+
trap "echo '::$stopMarker::'" EXIT
158+
./.github/scripts/test.sh \
159+
--guava=strongKeys \
160+
--guava=weakKeys \
161+
--guava=check
162+
- name: Compress test results
163+
uses: sibiraj-s/action-archiver@v1
164+
if: always() && (matrix.java == env.MAX_JVM)
165+
with:
166+
path: '**/results/*.xml'
167+
output: guava.tar.gz
168+
format: tar
169+
gzip: true
133170
- name: Upload test results
134171
uses: actions/upload-artifact@v3
135-
if: (matrix.java == env.MAX_JVM) && always()
172+
if: always() && (matrix.java == env.MAX_JVM)
136173
with:
137174
retention-days: 1
138175
name: guava-test-results
139-
path: '**/results/*.xml'
176+
path: guava.tar.gz
140177
- name: Stop Gradle daemon
141178
if: always()
142179
run: ./gradlew --stop
@@ -145,12 +182,91 @@ jobs:
145182
continue-on-error: true
146183
if: failure()
147184

148-
event_file:
149-
name: Event File
185+
lincheck:
186+
name: Linearization Tests
150187
runs-on: ubuntu-latest
151188
steps:
152-
- name: Upload
153-
uses: actions/upload-artifact@v2
154-
with:
155-
name: Event File
156-
path: ${{ github.event_path }}
189+
- uses: actions/checkout@v3
190+
- name: Set up JDK ${{ env.MAX_JVM }}
191+
uses: actions/setup-java@v3
192+
with:
193+
cache: 'gradle'
194+
distribution: 'zulu'
195+
java-version: ${{ env.MAX_JVM }}
196+
- name: Setup Gradle
197+
uses: gradle/gradle-build-action@v2
198+
- name: Run tests
199+
run: |
200+
stopMarker=$(uuidgen)
201+
echo "::stop-commands::$stopMarker"
202+
trap "echo '::$stopMarker::'" EXIT
203+
JAVA_VERSION=$MAX_JVM
204+
./gradlew lincheckTest
205+
- name: Compress test results
206+
uses: sibiraj-s/action-archiver@v1
207+
if: always()
208+
with:
209+
path: '**/results/*.xml'
210+
output: lincheck.tar.gz
211+
format: tar
212+
gzip: true
213+
- name: Upload test results
214+
uses: actions/upload-artifact@v3
215+
if: always()
216+
with:
217+
retention-days: 1
218+
name: lincheck-test-results
219+
path: lincheck.tar.gz
220+
221+
test-summary:
222+
name: Test Summary
223+
runs-on: ubuntu-latest
224+
needs: [caffeine, guava, lincheck]
225+
permissions:
226+
checks: write
227+
steps:
228+
- name: Download Guava Tests
229+
uses: actions/download-artifact@v3
230+
with:
231+
name: guava-test-results
232+
- name: Download Caffeine Tests
233+
uses: actions/download-artifact@v3
234+
with:
235+
name: caffeine-test-results
236+
- name: Download Lincheck Tests
237+
uses: actions/download-artifact@v3
238+
with:
239+
name: lincheck-test-results
240+
- name: Decompress
241+
run: |
242+
mkdir guava && tar -zxf guava.tar.gz --directory guava
243+
mkdir caffeine && tar -zxf caffeine.tar.gz --directory caffeine
244+
mkdir lincheck && tar -zxf lincheck.tar.gz --directory lincheck
245+
- name: Publish Test Results
246+
uses: EnricoMi/publish-unit-test-result-action@v1
247+
continue-on-error: true
248+
id: test-results
249+
with:
250+
comment_mode: off
251+
ignore_runs: true
252+
job_summary: true
253+
files: '**/*.xml'
254+
- name: Format Test Count
255+
run: |
256+
LANG=en_US.utf8
257+
COUNT=${{ fromJSON(steps.test-results.outputs.json).stats.runs }}
258+
echo "TEST_COUNT=$(printf "%'d" $COUNT)" >> $GITHUB_ENV
259+
- name: Create badge
260+
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
261+
with:
262+
label: tests
263+
color: 31c653
264+
path: badge.svg
265+
status: ${{ env.TEST_COUNT }}
266+
- name: Upload badge to Gist
267+
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
268+
if: endsWith(github.ref, github.event.repository.default_branch)
269+
with:
270+
gistURL: https://gist.githubusercontent.com/ben-manes/c20eb418f0e0bd6dfe1c25beb35faae4
271+
token: ${{ secrets.GIST_TOKEN }}
272+
file: badge.svg

.github/workflows/lincheck.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/test-report.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[![Build Status](https://github.com/ben-manes/caffeine/workflows/build/badge.svg)](https://github.com/ben-manes/caffeine/actions?query=workflow%3Abuild)
2+
[![Test Count](https://gist.githubusercontent.com/ben-manes/c20eb418f0e0bd6dfe1c25beb35faae4/raw/badge.svg)](https://github.com/ben-manes/caffeine/actions?query=workflow%3Abuild)
23
[![Coverage Status](https://img.shields.io/coveralls/ben-manes/caffeine.svg)](https://coveralls.io/r/ben-manes/caffeine?branch=master)
34
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.ben-manes.caffeine/caffeine/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.ben-manes.caffeine/caffeine)
4-
[![JavaDoc](http://www.javadoc.io/badge/com.github.ben-manes.caffeine/caffeine.svg)](http://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine)
5-
[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
6-
[![Stack Overflow](http://img.shields.io/:stack%20overflow-caffeine-brightgreen.svg)](http://stackoverflow.com/questions/tagged/caffeine)
5+
[![JavaDoc](https://www.javadoc.io/badge/com.github.ben-manes.caffeine/caffeine.svg)](http://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine)
6+
[![License](https://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
7+
[![Stack Overflow](https://img.shields.io/:stack%20overflow-caffeine-brightgreen.svg)](http://stackoverflow.com/questions/tagged/caffeine)
78
<a href="https://github.com/ben-manes/caffeine/wiki">
89
<img align="right" height="90px" src="https://raw.githubusercontent.com/ben-manes/caffeine/master/wiki/logo.png">
910
</a>

gradle/dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ext {
7777
mockito: '4.5.1',
7878
paxExam: '4.13.5',
7979
slf4jTest: '2.6.1',
80-
testng: '7.5',
80+
testng: '7.6.0',
8181
truth: '1.1.3',
8282
felix: '7.0.3',
8383
felixScr: '2.2.0',

0 commit comments

Comments
 (0)