1313 branches : [ main ]
1414 paths-ignore :
1515 - ' **.md'
16+ - ' .gitignore'
1617 pull_request :
1718 paths-ignore :
1819 - ' **.md'
20+ - ' .gitignore'
1921 workflow_dispatch :
2022
2123env :
2224 JAVA_VERSION : ' 17'
25+ GRADLE_OPTS : ' -Dorg.gradle.daemon=false'
2326
2427jobs :
28+ build :
29+ name : ' Build'
30+ runs-on : ubuntu-latest
31+ timeout-minutes : 15
32+ steps :
33+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
34+ with :
35+ persist-credentials : false
36+ - uses : actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
37+ with :
38+ java-version : ${{ env.JAVA_VERSION }}
39+ distribution : adopt
40+ - uses : gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
41+ with :
42+ cache-read-only : ${{ github.event_name == 'pull_request' }}
43+ - name : ' Build all modules'
44+ run : ./gradlew assemble --stacktrace --build-cache
45+ - uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
46+ with :
47+ name : sdk-artifacts
48+ path : |
49+ sdk/build/outputs/aar/sdk-release.aar
50+ sdk/build/intermediates/javac/release/compileReleaseJavaWithJavac/classes
51+ retention-days : 1
52+
2553 test :
2654 name : ' Test Unit'
2755 runs-on : ubuntu-latest
2856 timeout-minutes : 15
2957 steps :
30- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
58+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
59+ with :
60+ persist-credentials : false
61+ - uses : actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
62+ with :
63+ java-version : ${{ env.JAVA_VERSION }}
64+ distribution : adopt
65+ - uses : gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
66+ with :
67+ cache-read-only : ${{ github.event_name == 'pull_request' }}
68+ - name : ' Run Unit Tests'
69+ run : ./gradlew test --stacktrace --build-cache
70+
71+ quality :
72+ name : ' Code Quality'
73+ runs-on : ubuntu-latest
74+ timeout-minutes : 15
75+ steps :
76+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3177 with :
3278 persist-credentials : false
33- - uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7 .0
79+ - uses : actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2 .0
3480 with :
3581 java-version : ${{ env.JAVA_VERSION }}
3682 distribution : adopt
37- - uses : gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b
83+ - uses : gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
3884 with :
3985 cache-read-only : ${{ github.event_name == 'pull_request' }}
40- - name : ' Build'
41- run : ./gradlew build --stacktrace
86+ - name : ' Run Code Quality Checks'
87+ run : ./gradlew lint checkstyle pmd spotbugsDebug spotbugsRelease jacocoUnitTestReport --stacktrace --build-cache
88+
89+ validate :
90+ name : ' Validate (ES5, JitPack)'
91+ needs : build
92+ runs-on : ubuntu-latest
93+ timeout-minutes : 10
94+ steps :
95+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
96+ with :
97+ persist-credentials : false
98+ - uses : actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
99+ with :
100+ java-version : ${{ env.JAVA_VERSION }}
101+ distribution : adopt
102+ - uses : gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
103+ with :
104+ cache-read-only : ${{ github.event_name == 'pull_request' }}
105+ - uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
106+ with :
107+ name : sdk-artifacts
108+ path : sdk/build
109+ - name : Cache npm
110+ uses : actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
111+ with :
112+ path : ~/.npm
113+ key : npm-jshint-${{ runner.os }}
42114 - name : ' HTML ES5 test'
43115 run : |
44116 npm install -g jshint
117+ mkdir -p sdk/build/intermediates/javac/release/compileReleaseJavaWithJavac/classes
45118 java -cp sdk/build/intermediates/javac/release/compileReleaseJavaWithJavac/classes com.hcaptcha.sdk.HCaptchaHtml > sdk/build/hcaptcha-form.html
46119 jshint --extract=always sdk/build/hcaptcha-form.html
47120 - name : ' JitPack Test'
48- run : ./gradlew publishReleasePublicationToMavenLocal
121+ run : ./gradlew publishReleasePublicationToMavenLocal --stacktrace --build-cache
49122
50123 build-matrix :
51124 name : ' Build (target:${{ matrix.target }} compile:${{ matrix.compile }} appcompat: ${{ matrix.appcompat }})'
52- needs : test
53125 runs-on : ubuntu-latest
54126 timeout-minutes : 15
55127 strategy :
@@ -75,42 +147,46 @@ jobs:
75147 target : 30
76148 appcompat : 1.3.1
77149 steps :
78- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
150+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
79151 with :
80152 persist-credentials : false
81- - uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7 .0
153+ - uses : actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2 .0
82154 with :
83155 java-version : ${{ env.JAVA_VERSION }}
84156 distribution : adopt
85- - uses : gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b
157+ - uses : gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
86158 with :
87159 cache-read-only : ${{ github.event_name == 'pull_request' }}
88- - run : |
89- ./gradlew build -PexampleCompileSdkVersion=${{ matrix.compile }} \
160+ - name : ' Build with SDK ${{ matrix.target }}'
161+ run : |
162+ ./gradlew assemble \
163+ -x check -x test \
164+ -PexampleCompileSdkVersion=${{ matrix.compile }} \
90165 -PexampleTargetSdkVersion=${{ matrix.target }} \
91- -PexampleAppcompatVersion=${{ matrix.appcompat }}
166+ -PexampleAppcompatVersion=${{ matrix.appcompat }} \
167+ --stacktrace --build-cache
92168
93169 test-ui :
94170 name : ' Test UI'
95- needs : test
171+ needs : [build, test]
96172 runs-on : ubuntu-latest
97173 timeout-minutes : 20
98174 steps :
99- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
175+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
100176 with :
101177 persist-credentials : false
102- - uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7 .0
178+ - uses : actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2 .0
103179 with :
104180 java-version : ${{ env.JAVA_VERSION }}
105181 distribution : adopt
106- - uses : gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b
182+ - uses : gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
107183 with :
108184 cache-read-only : ${{ github.event_name == 'pull_request' }}
109185 - name : Run tests
110186 uses : ./.github/actions/android-emulator-run
111187 with :
112- script : " parallel --retries 3 ::: './gradlew test:connectedCheck'"
113- fresh-avd : true
188+ script : " parallel --retries 3 ::: './gradlew test:connectedCheck --build-cache '"
189+ fresh-avd : false
114190 - if : failure()
115191 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
116192 with :
@@ -121,25 +197,25 @@ jobs:
121197
122198 test-minified :
123199 name : ' Test UI Minified'
124- needs : [ test-ui ]
200+ needs : [build, test]
125201 runs-on : ubuntu-latest
126202 timeout-minutes : 20
127203 steps :
128- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
204+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
129205 with :
130206 persist-credentials : false
131- - uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7 .0
207+ - uses : actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2 .0
132208 with :
133209 java-version : ${{ env.JAVA_VERSION }}
134210 distribution : adopt
135- - uses : gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b
211+ - uses : gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
136212 with :
137213 cache-read-only : ${{ github.event_name == 'pull_request' }}
138214 - name : Run tests
139215 uses : ./.github/actions/android-emulator-run
140216 with :
141- script : " parallel --retries 3 ::: './gradlew test:connectedCheck -P testingMinimizedBuild=true -P android.enableR8.fullMode=false'"
142- fresh-avd : true
217+ script : " parallel --retries 3 ::: './gradlew test:connectedCheck -P testingMinimizedBuild=true -P android.enableR8.fullMode=false --build-cache '"
218+ fresh-avd : false
143219 - if : failure()
144220 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
145221 with :
@@ -150,7 +226,7 @@ jobs:
150226
151227 test-benchmark :
152228 name : ' Test Benchmark'
153- needs : test
229+ needs : [build, test]
154230 runs-on : macos-15-intel
155231 timeout-minutes : 30
156232 permissions :
@@ -159,24 +235,24 @@ jobs:
159235 issues : write
160236 actions : read
161237 steps :
162- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
238+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
163239 with :
164240 persist-credentials : false
165- - uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7 .0
241+ - uses : actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2 .0
166242 with :
167243 java-version : ${{ env.JAVA_VERSION }}
168244 distribution : adopt
169- - uses : gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b
245+ - uses : gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
170246 with :
171247 cache-read-only : ${{ github.event_name == 'pull_request' }}
172248 - name : Run tests
173249 uses : ./.github/actions/android-emulator-run
174250 with :
175251 api-level : 29
176- fresh-avd : true
252+ fresh-avd : false
177253 script : |
178254 adb uninstall com.hcaptcha.sdk.bench.test || true
179- ./gradlew benchmark:connectedReleaseAndroidTest
255+ ./gradlew benchmark:connectedReleaseAndroidTest --build-cache
180256 - if : always()
181257 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
182258 with :
@@ -216,35 +292,37 @@ jobs:
216292
217293 size-report :
218294 name : ' Diffuse report'
219- needs : [ test ]
295+ needs : build
220296 if : github.event_name == 'pull_request'
221297 runs-on : ubuntu-latest
222- timeout-minutes : 20
298+ timeout-minutes : 15
223299 permissions :
224300 pull-requests : write
225301 contents : read
226302 issues : write
227303 actions : read
228304 steps :
229- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
305+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
230306 with :
231307 fetch-depth : 0
232308 persist-credentials : false
233- - uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7 .0
309+ - uses : actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2 .0
234310 with :
235311 java-version : ${{ env.JAVA_VERSION }}
236312 distribution : adopt
237- - uses : gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b
313+ - uses : gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
238314 with :
239315 cache-read-only : ${{ github.event_name == 'pull_request' }}
240- - name : ' Build'
241- run : |
242- ./gradlew clean build --stacktrace
243- cp sdk/build/outputs/aar/sdk-release.aar sdk-pr.aar
244- - name : ' Build main'
316+ - uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
317+ with :
318+ name : sdk-artifacts
319+ path : sdk/build
320+ - name : ' Copy PR artifact'
321+ run : cp sdk/build/outputs/aar/sdk-release.aar sdk-pr.aar
322+ - name : ' Build main branch SDK'
245323 run : |
246324 git checkout origin/main
247- ./gradlew clean build --stacktrace
325+ ./gradlew sdk:assembleRelease --stacktrace --build-cache
248326 cp sdk/build/outputs/aar/sdk-release.aar sdk-main.aar
249327 - id : diffuse
250328 uses : usefulness/diffuse-action@41995fe8ff6be0a8847e63bdc5a4679c704b455c
0 commit comments