mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-10-20 07:08:56 +08:00
Compare commits
301 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
356abb47e7 | ||
|
fc9e8feb61 | ||
|
0e4b100458 | ||
|
82bc72e1e7 | ||
|
8be955ee80 | ||
|
531cc21aeb | ||
|
164712adb1 | ||
|
535b494721 | ||
|
d6110ecac2 | ||
|
cc60593845 | ||
|
fb549a8417 | ||
|
c64fe31590 | ||
|
6e56b59601 | ||
|
c77676cc69 | ||
|
f39ea084f9 | ||
|
27a2f232f6 | ||
|
b4c3d51488 | ||
|
99ec710825 | ||
|
d427a379a8 | ||
|
ed5f3e6998 | ||
|
11c5fa73ac | ||
|
3e3c80e9b4 | ||
|
25ec178747 | ||
|
3cc0a8f6bb | ||
|
915123c493 | ||
|
ef638c00fd | ||
|
05257c7a5f | ||
|
c1a6f51e61 | ||
|
865815e1b6 | ||
|
eb22e65b5b | ||
|
8a386f6915 | ||
|
84bc83e639 | ||
|
cd579d970f | ||
|
f0ec7fb780 | ||
|
bf2a15ee94 | ||
|
c85b5e1be7 | ||
|
330980897f | ||
|
9411346324 | ||
|
8f9b7c7d7f | ||
|
8df5664474 | ||
|
25e9b4d3f6 | ||
|
b49446f8e1 | ||
|
cbebff71e9 | ||
|
e4e8267f88 | ||
|
1e61c9a322 | ||
|
1a981dbaeb | ||
|
58e9059de1 | ||
|
a62a2e6297 | ||
|
daa635c20c | ||
|
9ee08ff30d | ||
|
f4ef189a47 | ||
|
8e9c25766c | ||
|
8ca744f938 | ||
|
f1b090783c | ||
|
8624823510 | ||
|
203397ae27 | ||
|
2aee3e724e | ||
|
a1707fcc88 | ||
|
b173558d72 | ||
|
d1ddcc2b6a | ||
|
1f2d557283 | ||
|
544b84f77b | ||
|
23d17c1372 | ||
|
ba3953a01d | ||
|
02e50e0dcd | ||
|
cd48d2d9f1 | ||
|
a81a96bcb6 | ||
|
7a5430f22f | ||
|
6b46ca579b | ||
|
933706c9f3 | ||
|
f524932f69 | ||
|
115127d4c2 | ||
|
115f70f942 | ||
|
1c23b66302 | ||
|
7a714ca5cb | ||
|
f559e1b425 | ||
|
5c38a9cbe9 | ||
|
ede6deb03b | ||
|
e3c7fbbbf0 | ||
|
a5bedc5d4f | ||
|
97590ddc37 | ||
|
41839de420 | ||
|
ad8dc7ef6a | ||
|
35da154adf | ||
|
3e0e3a6dea | ||
|
25d3ae13f9 | ||
|
5db8d22748 | ||
|
86acd2a1fd | ||
|
3f1275846c | ||
|
ef1e109eb6 | ||
|
5c54c52839 | ||
|
89ea1bd733 | ||
|
444dfef7d6 | ||
|
957e1cc621 | ||
|
731c4e9bf4 | ||
|
6700f3a162 | ||
|
1691ab51b6 | ||
|
27f9f12663 | ||
|
474cf85207 | ||
|
37c9711406 | ||
|
cd3cedc781 | ||
|
e54bfe60d4 | ||
|
d70ff19b06 | ||
|
45417006b1 | ||
|
925e60d017 | ||
|
47a028a7f5 | ||
|
7df347a3ca | ||
|
d742f2f6db | ||
|
e4c0d1d512 | ||
|
64a1064eca | ||
|
bc57473979 | ||
|
11ea84dec5 | ||
|
5a614fb332 | ||
|
d3a8ea948b | ||
|
fba23f26a1 | ||
|
683f9d4247 | ||
|
f87d5a33c9 | ||
|
42014fb4fa | ||
|
2da06d5689 | ||
|
792a93a5e3 | ||
|
86da5e6c4e | ||
|
6daf446e27 | ||
|
8a8f74b15c | ||
|
15453523bd | ||
|
b1b0eab63d | ||
|
f580ce7b99 | ||
|
2a7ffc9c95 | ||
|
ff6b0e0388 | ||
|
71e1e1b52b | ||
|
02b67b8bfe | ||
|
5ce69a34b6 | ||
|
e7f3e4d839 | ||
|
7645d3e274 | ||
|
be13141ec7 | ||
|
db33711f5a | ||
|
84dee23dd9 | ||
|
a603ab7405 | ||
|
bc41b8f654 | ||
|
32923891b5 | ||
|
fecf3693b5 | ||
|
6965e8ed4c | ||
|
884bca012f | ||
|
7f46dbd76f | ||
|
ea4554d4d2 | ||
|
d8b58e3519 | ||
|
4cb86e9712 | ||
|
eaed5520c4 | ||
|
ec939a8c10 | ||
|
6594e9d359 | ||
|
52e6e7d89f | ||
|
2bf1894aa3 | ||
|
795895fc71 | ||
|
98376690f1 | ||
|
67421db6bd | ||
|
ce3874fec9 | ||
|
67f42d16a1 | ||
|
56036f8577 | ||
|
1903bd4674 | ||
|
df4c1902a6 | ||
|
132237ba05 | ||
|
2335d51128 | ||
|
2f7e5c0d4b | ||
|
2248b3f239 | ||
|
7d8a9a65e5 | ||
|
bc39e4abaa | ||
|
26cd1c9794 | ||
|
5ccc7fa6a6 | ||
|
badf18c0a6 | ||
|
1ee84620f9 | ||
|
f1c1269910 | ||
|
c09f41c4bd | ||
|
829c7a236d | ||
|
c1ed8b1925 | ||
|
3d091fa7a8 | ||
|
a8d44c9749 | ||
|
6125b490f2 | ||
|
f75a77b009 | ||
|
3510b43886 | ||
|
61ba2ad220 | ||
|
4b449e5b54 | ||
|
b8f0ecc408 | ||
|
c2bd86551b | ||
|
92087b6bb6 | ||
|
9355458b6c | ||
|
4ec1021d58 | ||
|
f3e4903860 | ||
|
c5d80a628f | ||
|
ee54c1fd71 | ||
|
f33d84950e | ||
|
d20c5c0356 | ||
|
c207cf448f | ||
|
a534572737 | ||
|
acf6027bd2 | ||
|
f6ab09b0bf | ||
|
55ddd21594 | ||
|
33ed11e54c | ||
|
93c31ca3b5 | ||
|
7a15005377 | ||
|
e88ed3e650 | ||
|
de51428ba5 | ||
|
8096e65e0a | ||
|
9cd70b5460 | ||
|
63bcd47c1b | ||
|
306a7e4bb2 | ||
|
c34d4a9731 | ||
|
213bb63776 | ||
|
4ca4968624 | ||
|
fd1882690a | ||
|
0b5047ec4d | ||
|
a4a9a30e86 | ||
|
865c16699a | ||
|
52ebf2721a | ||
|
aea6ddad5b | ||
|
a7f880172e | ||
|
e644288a42 | ||
|
e234151ec9 | ||
|
44e1837ae3 | ||
|
b400dc555d | ||
|
3f2d9cde44 | ||
|
6001bc9edc | ||
|
5203a0b09d | ||
|
500607bc35 | ||
|
754892d4ae | ||
|
ea24a0ad75 | ||
|
748dc30fdc | ||
|
e4ed35bcaf | ||
|
ece69c52b2 | ||
|
14c898b500 | ||
|
00cdd4dcf9 | ||
|
b02f4f1968 | ||
|
0a36ca9fb8 | ||
|
fe92974cdf | ||
|
6aa41b32df | ||
|
4fa0803854 | ||
|
9ab4abd18c | ||
|
f375a232f2 | ||
|
85daf96c6d | ||
|
8b56c4af06 | ||
|
4da299730b | ||
|
dff0fe1b20 | ||
|
ae74c01440 | ||
|
cde0632795 | ||
|
6cc033f2b3 | ||
|
8aaf080d68 | ||
|
4378b83ae3 | ||
|
d3a78eb55f | ||
|
f4d1e351c0 | ||
|
7b79b2a752 | ||
|
143774290e | ||
|
a9a5bcf180 | ||
|
f9c8fcf79f | ||
|
86e82987ba | ||
|
5fe4df6233 | ||
|
d79b3ba8ae | ||
|
8f3c97e3f1 | ||
|
d95713bd5d | ||
|
bdf9736c53 | ||
|
7e85212f59 | ||
|
0c692feedb | ||
|
78da7b9646 | ||
|
992ccebeea | ||
|
c13dc6c789 | ||
|
5e6af67a5e | ||
|
e32d23f291 | ||
|
a880eab216 | ||
|
6c8fe00271 | ||
|
c37c1fb693 | ||
|
0c3292abfb | ||
|
66050d88b2 | ||
|
1771c6f669 | ||
|
acc77da702 | ||
|
bdb9f7fd28 | ||
|
f9e15febb7 | ||
|
1ba2a63e58 | ||
|
c838a38ea1 | ||
|
2e34e4f80f | ||
|
2bb20697b4 | ||
|
28b774ebdb | ||
|
12be8b4772 | ||
|
be62f7d934 | ||
|
c48eef1c6e | ||
|
544da49fda | ||
|
26ea4afa08 | ||
|
a0f1efaaad | ||
|
7645e6e536 | ||
|
c21b4ec861 | ||
|
30a933bf94 | ||
|
646074d659 | ||
|
d63db6a05e | ||
|
dc49976071 | ||
|
52bee6e472 | ||
|
57ec230092 | ||
|
549804ea2d | ||
|
fd7acd5c1e | ||
|
fb99e07d58 | ||
|
557c94c831 | ||
|
64508494d5 | ||
|
c0b2cb764a | ||
|
71be92f02d | ||
|
08fb6c874a | ||
|
94d04eaa0d |
16
.github/actions/build-dist/action.yml
vendored
Normal file
16
.github/actions/build-dist/action.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
name: 'Build and upload distribution'
|
||||||
|
# Builds the action distribution an uploads as an artifact for later download
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Build distribution
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
- name: Upload distribution
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: dist
|
||||||
|
path: dist/
|
||||||
|
|
12
.github/actions/download-dist/action.yml
vendored
Normal file
12
.github/actions/download-dist/action.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
name: 'Download dist'
|
||||||
|
# Downloads a 'dist' directory artifact that was uploaded in an earlier step
|
||||||
|
# We control this with an environment variable to allow for easier global configuration.
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Download dist
|
||||||
|
if: ${{ env.DOWNLOAD_DIST == 'true' }}
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: dist
|
||||||
|
path: dist/
|
8
.github/dependabot.yml
vendored
8
.github/dependabot.yml
vendored
@@ -9,7 +9,7 @@ updates:
|
|||||||
- package-ecosystem: "npm"
|
- package-ecosystem: "npm"
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "weekly"
|
||||||
open-pull-requests-limit: 10
|
open-pull-requests-limit: 10
|
||||||
ignore:
|
ignore:
|
||||||
- dependency-name: "@types/node"
|
- dependency-name: "@types/node"
|
||||||
@@ -49,3 +49,9 @@ updates:
|
|||||||
- gradle-plugin-portal
|
- gradle-plugin-portal
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
- package-ecosystem: "gradle"
|
||||||
|
directory: "test/init-scripts"
|
||||||
|
registries:
|
||||||
|
- gradle-plugin-portal
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionSha256Sum=29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda
|
distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@@ -205,6 +205,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionSha256Sum=29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda
|
distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
6
.github/workflow-samples/groovy-dsl/gradlew
vendored
6
.github/workflow-samples/groovy-dsl/gradlew
vendored
@@ -205,6 +205,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
14
.github/workflow-samples/groovy-dsl/gradlew.bat
vendored
14
.github/workflow-samples/groovy-dsl/gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
@@ -1 +1,14 @@
|
|||||||
rootProject.name = 'basic'
|
plugins {
|
||||||
|
id "com.gradle.enterprise" version "3.11.1"
|
||||||
|
id "com.gradle.common-custom-user-data-gradle-plugin" version "1.8"
|
||||||
|
}
|
||||||
|
|
||||||
|
gradleEnterprise {
|
||||||
|
buildScan {
|
||||||
|
termsOfServiceUrl = "https://gradle.com/terms-of-service"
|
||||||
|
termsOfServiceAgree = "yes"
|
||||||
|
publishAlways()
|
||||||
|
uploadInBackground = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootProject.name = 'groovy-dsl'
|
||||||
|
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionSha256Sum=29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda
|
distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@@ -205,6 +205,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
@@ -10,7 +10,7 @@ dependencies {
|
|||||||
api("org.apache.commons:commons-math3:3.6.1")
|
api("org.apache.commons:commons-math3:3.6.1")
|
||||||
implementation("com.google.guava:guava:31.1-jre")
|
implementation("com.google.guava:guava:31.1-jre")
|
||||||
|
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
|
testImplementation("org.junit.jupiter:junit-jupiter:5.9.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
|
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionSha256Sum=29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda
|
distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
6
.github/workflow-samples/kotlin-dsl/gradlew
vendored
6
.github/workflow-samples/kotlin-dsl/gradlew
vendored
@@ -205,6 +205,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
14
.github/workflow-samples/kotlin-dsl/gradlew.bat
vendored
14
.github/workflow-samples/kotlin-dsl/gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("com.gradle.enterprise") version "3.10"
|
id("com.gradle.enterprise") version "3.11.1"
|
||||||
|
id("com.gradle.common-custom-user-data-gradle-plugin") version "1.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
gradleEnterprise {
|
gradleEnterprise {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "com.gradle.build-scan" version "3.10"
|
id "com.gradle.build-scan" version "3.11.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
gradleEnterprise {
|
gradleEnterprise {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "com.gradle.enterprise" version "3.10"
|
id "com.gradle.enterprise" version "3.11.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
gradleEnterprise {
|
gradleEnterprise {
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
# the `language` matrix defined below to confirm you have the correct set of
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
# supported CodeQL languages.
|
# supported CodeQL languages.
|
||||||
#
|
#
|
||||||
name: "CodeQL"
|
name: CI-codeql
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -38,11 +38,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v1
|
uses: github/codeql-action/init@v2
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
@@ -53,7 +53,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v1
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -67,4 +67,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v2
|
80
.github/workflows/ci-full-check.yml
vendored
Normal file
80
.github/workflows/ci-full-check.yml
vendored
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
name: CI-full-check
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- assigned
|
||||||
|
- review_requested
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- '.github/**'
|
||||||
|
- 'dist/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
action-inputs:
|
||||||
|
uses: ./.github/workflows/integ-test-action-inputs.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
cache-cleanup:
|
||||||
|
uses: ./.github/workflows/integ-test-cache-cleanup.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
caching-config:
|
||||||
|
uses: ./.github/workflows/integ-test-action-inputs-caching.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
execution-with-caching:
|
||||||
|
uses: ./.github/workflows/integ-test-execution-with-caching.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
execution:
|
||||||
|
uses: ./.github/workflows/integ-test-execution.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
provision-gradle-versions:
|
||||||
|
uses: ./.github/workflows/integ-test-provision-gradle-versions.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
restore-configuration-cache:
|
||||||
|
uses: ./.github/workflows/integ-test-restore-configuration-cache.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
restore-custom-gradle-home:
|
||||||
|
uses: ./.github/workflows/integ-test-restore-custom-gradle-home.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
restore-containerized-gradle-home:
|
||||||
|
uses: ./.github/workflows/integ-test-restore-containerized-gradle-home.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
restore-gradle-home:
|
||||||
|
uses: ./.github/workflows/integ-test-restore-gradle-home.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
restore-java-toolchain:
|
||||||
|
uses: ./.github/workflows/integ-test-restore-java-toolchain.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
sample-kotlin-dsl:
|
||||||
|
uses: ./.github/workflows/integ-test-sample-kotlin-dsl.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
||||||
|
|
||||||
|
sample-gradle-plugin:
|
||||||
|
uses: ./.github/workflows/integ-test-sample-gradle-plugin.yml
|
||||||
|
with:
|
||||||
|
cache-key-prefix: ${{github.run_number}}-
|
26
.github/workflows/ci-init-script-check.yml
vendored
Normal file
26
.github/workflows/ci-init-script-check.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: CI-init-script-check
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/ci-init-script-check.yml'
|
||||||
|
- 'src/resources/init-scripts/**'
|
||||||
|
- 'test/init-scripts/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-init-scripts:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: 8
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/gradle-build-action@v2 # Use a released version to avoid breakages
|
||||||
|
- name: Run integration tests
|
||||||
|
working-directory: test/init-scripts
|
||||||
|
run: ./gradlew check
|
115
.github/workflows/ci-quick-check.yml
vendored
Normal file
115
.github/workflows/ci-quick-check.yml
vendored
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
name: CI-quick-check
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches-ignore: main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-distribution:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Build and upload distribution
|
||||||
|
uses: ./.github/actions/build-dist
|
||||||
|
|
||||||
|
run-unit-tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
npm run all
|
||||||
|
|
||||||
|
action-inputs:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-action-inputs.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
cache-cleanup:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-cache-cleanup.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
||||||
|
cache-key-prefix: ${{github.run_number}}- # Requires a fresh cache entry each run
|
||||||
|
|
||||||
|
caching-config:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-action-inputs-caching.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
execution-with-caching:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-execution-with-caching.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
execution:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-execution.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
provision-gradle-versions:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-provision-gradle-versions.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
restore-configuration-cache:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-restore-configuration-cache.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
restore-containerized-gradle-home:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-restore-containerized-gradle-home.yml
|
||||||
|
with:
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
restore-custom-gradle-home:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-restore-custom-gradle-home.yml
|
||||||
|
with:
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
restore-gradle-home:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-restore-gradle-home.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
restore-java-toolchain:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-restore-java-toolchain.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
sample-kotlin-dsl:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-sample-kotlin-dsl.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
||||||
|
|
||||||
|
sample-gradle-plugin:
|
||||||
|
needs: build-distribution
|
||||||
|
uses: ./.github/workflows/integ-test-sample-gradle-plugin.yml
|
||||||
|
with:
|
||||||
|
runner-os: '["ubuntu-latest"]'
|
||||||
|
download-dist: true
|
38
.github/workflows/ci-verify-outputs.yml
vendored
Normal file
38
.github/workflows/ci-verify-outputs.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
name: CI-verify-outputs
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- assigned
|
||||||
|
- review_requested
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dependabot/**
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
npm run all
|
||||||
|
|
||||||
|
- name: Compare the expected and actual dist/ directories
|
||||||
|
run: |
|
||||||
|
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||||
|
echo "Detected uncommitted changes after build. See status below:"
|
||||||
|
git diff
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
id: diff
|
||||||
|
|
||||||
|
# If index.js was different than expected, upload the expected version as an artifact
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||||
|
with:
|
||||||
|
name: dist
|
||||||
|
path: dist/
|
@@ -1,18 +1,27 @@
|
|||||||
name: Execute failure cases
|
name: demo-failure-cases
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
failing-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Test build failure
|
||||||
|
uses: ./
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
build-root-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
arguments: not-a-valid-task
|
||||||
|
|
||||||
wrapper-missing:
|
wrapper-missing:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Test wrapper missing
|
- name: Test wrapper missing
|
||||||
uses: ./
|
uses: ./
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -24,7 +33,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Test bad config value
|
- name: Test bad config value
|
||||||
uses: ./
|
uses: ./
|
||||||
continue-on-error: true
|
continue-on-error: true
|
43
.github/workflows/demo-job-summary.yml
vendored
Normal file
43
.github/workflows/demo-job-summary.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
name: Demo Job Summary for Gradle builds
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
|
||||||
|
env:
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-gradle-builds:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Build distribution
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
- name: Build kotlin-dsl project
|
||||||
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
run: ./gradlew assemble
|
||||||
|
- name: Build kotlin-dsl project without build scan
|
||||||
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
run: ./gradlew assemble check --no-scan
|
||||||
|
- name: Build kotlin-dsl project with build scan publish failure
|
||||||
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
run: ./gradlew check -Dgradle.enterprise.url=https://not.valid.server
|
||||||
|
- name: Build groovy-dsl project
|
||||||
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
run: ./gradlew assemble
|
||||||
|
- name: Build kotlin-dsl project with multiple gradle invocations
|
||||||
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
run: |
|
||||||
|
./gradlew tasks --no-daemon
|
||||||
|
./gradlew help check
|
||||||
|
- name: Fail groovy-dsl project
|
||||||
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
continue-on-error: true
|
||||||
|
run: ./gradlew not-a-real-task
|
@@ -1,4 +1,4 @@
|
|||||||
name: Add a build scan comment to PR
|
name: Demo adding build scan comment to PR
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [assigned, review_requested]
|
types: [assigned, review_requested]
|
||||||
@@ -7,7 +7,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout project sources
|
- name: Checkout project sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
- name: Run build with Gradle wrapper
|
- name: Run build with Gradle wrapper
|
||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
run: ./gradlew build --scan
|
run: ./gradlew build --scan
|
||||||
- name: "Add build scan URL as PR comment"
|
- name: "Add build scan URL as PR comment"
|
||||||
uses: actions/github-script@v5
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||||
script: |
|
script: |
|
24
.github/workflows/dev.yml
vendored
24
.github/workflows/dev.yml
vendored
@@ -1,24 +0,0 @@
|
|||||||
name: Verify generated outputs
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [assigned, review_requested]
|
|
||||||
push:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
npm install
|
|
||||||
npm run all
|
|
||||||
- name: Check for uncommitted changes
|
|
||||||
# Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed.
|
|
||||||
run: |
|
|
||||||
git diff --exit-code --stat -- . ':!node_modules' \
|
|
||||||
|| (echo "##[error] found changed files after build. please 'npm run all'" \
|
|
||||||
"and check in all changes" \
|
|
||||||
&& exit 1)
|
|
@@ -1,33 +1,37 @@
|
|||||||
name: Test caching configuration
|
name: Test action inputs for caching
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types: [assigned, review_requested]
|
inputs:
|
||||||
push:
|
cache-key-prefix:
|
||||||
paths:
|
type: string
|
||||||
- '.github/**'
|
runner-os:
|
||||||
- 'dist/**'
|
type: string
|
||||||
workflow_dispatch:
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
concurrency:
|
type: boolean
|
||||||
group: ${{ github.workflow }}
|
default: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: action-inputs-caching-${{ inputs.cache-key-prefix }}
|
||||||
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
seed-build:
|
seed-build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
# Add "enterprise" to main cache entry but omit "notifications"
|
# Add "enterprise" to main cache entry but omit "notifications"
|
||||||
gradle-home-cache-includes: |
|
gradle-home-cache-includes: |
|
||||||
caches
|
caches
|
||||||
@@ -44,11 +48,13 @@ jobs:
|
|||||||
needs: seed-build
|
needs: seed-build
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -67,11 +73,13 @@ jobs:
|
|||||||
cache-disabled:
|
cache-disabled:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -82,7 +90,7 @@ jobs:
|
|||||||
run: gradle help "-DgradleVersionCheck=${{matrix.gradle}}"
|
run: gradle help "-DgradleVersionCheck=${{matrix.gradle}}"
|
||||||
- name: Check build scan url is captured
|
- name: Check build scan url is captured
|
||||||
if: ${{ !steps.gradle.outputs.build-scan-url }}
|
if: ${{ !steps.gradle.outputs.build-scan-url }}
|
||||||
uses: actions/github-script@v3
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
core.setFailed('No build scan detected')
|
core.setFailed('No build scan detected')
|
||||||
@@ -92,7 +100,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Create dummy Gradle User Home
|
- name: Create dummy Gradle User Home
|
||||||
run: mkdir -p ~/.gradle/caches
|
run: mkdir -p ~/.gradle/caches
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
@@ -103,7 +113,7 @@ jobs:
|
|||||||
run: gradle help "-DgradleVersionCheck=${{matrix.gradle}}"
|
run: gradle help "-DgradleVersionCheck=${{matrix.gradle}}"
|
||||||
- name: Check build scan url is captured
|
- name: Check build scan url is captured
|
||||||
if: ${{ !steps.gradle.outputs.build-scan-url }}
|
if: ${{ !steps.gradle.outputs.build-scan-url }}
|
||||||
uses: actions/github-script@v3
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
core.setFailed('No build scan detected')
|
core.setFailed('No build scan detected')
|
||||||
@@ -111,14 +121,16 @@ jobs:
|
|||||||
# Test seed the cache with cache-write-only and verify with cache-read-only
|
# Test seed the cache with cache-write-only and verify with cache-read-only
|
||||||
seed-build-write-only:
|
seed-build-write-only:
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-write-only-
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{ inputs.cache-key-prefix }}-write-only-
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -129,15 +141,17 @@ jobs:
|
|||||||
|
|
||||||
verify-write-only-build:
|
verify-write-only-build:
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-write-only-
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{ inputs.cache-key-prefix }}-write-only-
|
||||||
needs: seed-build-write-only
|
needs: seed-build-write-only
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
41
.github/workflows/integ-test-action-inputs.yml
vendored
Normal file
41
.github/workflows/integ-test-action-inputs.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: Test action inputs
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
cache-key-prefix:
|
||||||
|
type: string
|
||||||
|
runner-os:
|
||||||
|
type: string
|
||||||
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: action-inputs-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
action-inputs:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Invoke with multi-line arguments
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
build-root-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
arguments: |
|
||||||
|
--configuration-cache
|
||||||
|
--build-cache
|
||||||
|
-DsystemProperty=FOO
|
||||||
|
-PgradleProperty=BAR
|
||||||
|
test
|
||||||
|
jar
|
87
.github/workflows/integ-test-cache-cleanup.yml
vendored
Normal file
87
.github/workflows/integ-test-cache-cleanup.yml
vendored
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
name: Test cache cleanup
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
cache-key-prefix:
|
||||||
|
type: string
|
||||||
|
runner-os:
|
||||||
|
type: string
|
||||||
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: integ-test-cache-cleanup-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
full-build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
|
- name: Build with 3.1
|
||||||
|
working-directory: test/jest/resources/cache-cleanup
|
||||||
|
run: gradle --no-daemon --build-cache -Dcommons_math3_version="3.1" build
|
||||||
|
|
||||||
|
# Second build will use the cache from the first build, but cleanup should remove unused artifacts
|
||||||
|
assemble-build:
|
||||||
|
needs: full-build
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false
|
||||||
|
gradle-home-cache-cleanup: true
|
||||||
|
- name: Build with 3.1.1
|
||||||
|
working-directory: test/jest/resources/cache-cleanup
|
||||||
|
run: gradle --no-daemon --build-cache -Dcommons_math3_version="3.1.1" build
|
||||||
|
|
||||||
|
check-clean-cache:
|
||||||
|
needs: assemble-build
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: true
|
||||||
|
- name: Report Gradle User Home
|
||||||
|
run: du -hc ~/.gradle/caches/modules-2
|
||||||
|
- name: Verify cleaned cache
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ ! -e ~/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1.1 ]; then
|
||||||
|
echo "::error ::Should find commons-math3 3.1.1 in cache"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -e ~/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1 ]; then
|
||||||
|
echo "::error ::Should NOT find commons-math3 3.1 in cache"
|
||||||
|
exit 1
|
||||||
|
fi
|
56
.github/workflows/integ-test-execution-with-caching.yml
vendored
Normal file
56
.github/workflows/integ-test-execution-with-caching.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: Test execution with caching
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
cache-key-prefix:
|
||||||
|
type: string
|
||||||
|
runner-os:
|
||||||
|
type: string
|
||||||
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: execution-with-caching-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
seed-build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Execute Gradle build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
|
build-root-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
arguments: test
|
||||||
|
|
||||||
|
# Test that the gradle-user-home is restored
|
||||||
|
verify-build:
|
||||||
|
needs: seed-build
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Execute Gradle build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: true
|
||||||
|
build-root-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
arguments: test --offline -DverifyCachedBuild=true
|
||||||
|
|
@@ -1,19 +1,21 @@
|
|||||||
name: Test Gradle execution
|
name: Test execution
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types: [assigned, review_requested]
|
inputs:
|
||||||
push:
|
cache-key-prefix:
|
||||||
paths:
|
type: string
|
||||||
- '.github/**'
|
runner-os:
|
||||||
- 'dist/**'
|
type: string
|
||||||
workflow_dispatch:
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
concurrency:
|
type: boolean
|
||||||
group: ${{ github.workflow }}
|
default: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: execution-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Tests for executing with different Gradle versions.
|
# Tests for executing with different Gradle versions.
|
||||||
@@ -21,17 +23,20 @@ jobs:
|
|||||||
gradle-execution:
|
gradle-execution:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
include:
|
include:
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
script-suffix: '.bat'
|
script-suffix: '.bat'
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Test use defined Gradle version
|
- name: Test use defined Gradle version
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
gradle-version: 6.9
|
gradle-version: 6.9
|
||||||
build-root-directory: .github/workflow-samples/no-wrapper
|
build-root-directory: .github/workflow-samples/no-wrapper
|
||||||
arguments: help -DgradleVersionCheck=6.9
|
arguments: help -DgradleVersionCheck=6.9
|
||||||
@@ -46,32 +51,42 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
gradle-executable: .github/workflow-samples/groovy-dsl/gradlew${{ matrix.script-suffix }}
|
gradle-executable: .github/workflow-samples/groovy-dsl/gradlew${{ matrix.script-suffix }}
|
||||||
build-root-directory: .github/workflow-samples/no-wrapper
|
build-root-directory: .github/workflow-samples/no-wrapper
|
||||||
arguments: help -DgradleVersionCheck=7.4.2
|
arguments: help
|
||||||
|
|
||||||
gradle-versions:
|
gradle-versions:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
gradle: [7.3, 6.9, 5.6.4, 4.10.3]
|
gradle: [7.5.1, 6.9.2, 5.6.4, 4.10.3, 3.5.1]
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
include:
|
include:
|
||||||
- gradle: 5.6.4
|
- gradle: 5.6.4
|
||||||
build-root-suffix: -gradle-5
|
build-root-suffix: -gradle-5
|
||||||
- gradle: 4.10.3
|
- gradle: 4.10.3
|
||||||
build-root-suffix: -gradle-4
|
build-root-suffix: -gradle-4
|
||||||
|
- gradle: 3.5.1
|
||||||
|
build-root-suffix: -gradle-4
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: 8
|
||||||
- name: Run Gradle build
|
- name: Run Gradle build
|
||||||
uses: ./
|
uses: ./
|
||||||
id: gradle
|
id: gradle
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
gradle-version: ${{matrix.gradle}}
|
gradle-version: ${{matrix.gradle}}
|
||||||
build-root-directory: .github/workflow-samples/no-wrapper${{ matrix.build-root-suffix }}
|
build-root-directory: .github/workflow-samples/no-wrapper${{ matrix.build-root-suffix }}
|
||||||
arguments: help -DgradleVersionCheck=${{matrix.gradle}}
|
arguments: help -DgradleVersionCheck=${{matrix.gradle}}
|
||||||
- name: Check build scan url
|
- name: Check build scan url
|
||||||
if: ${{ !steps.gradle.outputs.build-scan-url }}
|
if: ${{ !steps.gradle.outputs.build-scan-url }}
|
||||||
uses: actions/github-script@v3
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
core.setFailed('No build scan detected')
|
core.setFailed('No build scan detected')
|
@@ -1,19 +1,21 @@
|
|||||||
name: Test provision different Gradle versions
|
name: Test provision Gradle versions
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types: [assigned, review_requested]
|
inputs:
|
||||||
push:
|
cache-key-prefix:
|
||||||
paths:
|
type: string
|
||||||
- '.github/**'
|
runner-os:
|
||||||
- 'dist/**'
|
type: string
|
||||||
workflow_dispatch:
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
concurrency:
|
type: boolean
|
||||||
group: ${{ github.workflow }}
|
default: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: provision-gradle-versions-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Tests for executing with different Gradle versions.
|
# Tests for executing with different Gradle versions.
|
||||||
@@ -21,17 +23,20 @@ jobs:
|
|||||||
provision-gradle:
|
provision-gradle:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
include:
|
include:
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
script-suffix: '.bat'
|
script-suffix: '.bat'
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle with v6.9
|
- name: Setup Gradle with v6.9
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
gradle-version: 6.9
|
gradle-version: 6.9
|
||||||
- name: Test uses Gradle v6.9
|
- name: Test uses Gradle v6.9
|
||||||
working-directory: .github/workflow-samples/no-wrapper
|
working-directory: .github/workflow-samples/no-wrapper
|
||||||
@@ -54,20 +59,30 @@ jobs:
|
|||||||
gradle-versions:
|
gradle-versions:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
gradle: [7.3, 6.9, 5.6.4, 4.10.3]
|
gradle: [7.3, 6.9, 5.6.4, 4.10.3, 3.5.1]
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
include:
|
include:
|
||||||
- gradle: 5.6.4
|
- gradle: 5.6.4
|
||||||
build-root-suffix: -gradle-5
|
build-root-suffix: -gradle-5
|
||||||
- gradle: 4.10.3
|
- gradle: 4.10.3
|
||||||
build-root-suffix: -gradle-4
|
build-root-suffix: -gradle-4
|
||||||
|
- gradle: 3.5.1
|
||||||
|
build-root-suffix: -gradle-4
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: 8
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
gradle-version: ${{ matrix.gradle }}
|
gradle-version: ${{ matrix.gradle }}
|
||||||
- name: Run Gradle build
|
- name: Run Gradle build
|
||||||
id: gradle
|
id: gradle
|
||||||
@@ -75,7 +90,7 @@ jobs:
|
|||||||
run: gradle help "-DgradleVersionCheck=${{matrix.gradle}}"
|
run: gradle help "-DgradleVersionCheck=${{matrix.gradle}}"
|
||||||
- name: Check build scan url
|
- name: Check build scan url
|
||||||
if: ${{ !steps.gradle.outputs.build-scan-url }}
|
if: ${{ !steps.gradle.outputs.build-scan-url }}
|
||||||
uses: actions/github-script@v3
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
core.setFailed('No build scan detected')
|
core.setFailed('No build scan detected')
|
@@ -1,50 +1,56 @@
|
|||||||
name: Test save/restore configuration-cache state
|
name: Test restore configuration-cache
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types: [assigned, review_requested]
|
inputs:
|
||||||
push:
|
cache-key-prefix:
|
||||||
paths:
|
type: string
|
||||||
- '.github/**'
|
runner-os:
|
||||||
- 'dist/**'
|
type: string
|
||||||
workflow_dispatch:
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
concurrency:
|
type: boolean
|
||||||
group: ${{ github.workflow }}
|
default: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: restore-configuration-cache-${{ inputs.cache-key-prefix }}
|
||||||
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Run initial Gradle builds to push initial cache entries
|
|
||||||
# These builds should start fresh without cache hits, due to the seed injected into the cache key above.
|
|
||||||
seed-build-groovy:
|
seed-build-groovy:
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-groovy-
|
GRADLE_BUILD_ACTION_CACHE_KEY_JOB: restore-cc-groovy
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Groovy build with configuration-cache enabled
|
- name: Groovy build with configuration-cache enabled
|
||||||
working-directory: .github/workflow-samples/groovy-dsl
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
run: ./gradlew test --configuration-cache
|
run: ./gradlew test --configuration-cache
|
||||||
|
|
||||||
configuration-cache-groovy:
|
verify-build-groovy:
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-groovy-
|
GRADLE_BUILD_ACTION_CACHE_KEY_JOB: restore-cc-groovy
|
||||||
needs: seed-build-groovy
|
needs: seed-build-groovy
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -55,23 +61,25 @@ jobs:
|
|||||||
run: ./gradlew test --configuration-cache
|
run: ./gradlew test --configuration-cache
|
||||||
- name: Check that configuration-cache was used
|
- name: Check that configuration-cache was used
|
||||||
if: ${{ steps.execute.outputs.task_configured == 'yes' }}
|
if: ${{ steps.execute.outputs.task_configured == 'yes' }}
|
||||||
uses: actions/github-script@v5
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
core.setFailed('Configuration cache was not used - task was configured unexpectedly')
|
core.setFailed('Configuration cache was not used - task was configured unexpectedly')
|
||||||
|
|
||||||
# Check that the build can run when no extracted cache entries are restored
|
# Check that the build can run when no extracted cache entries are restored
|
||||||
no-extracted-cache-entries-restored:
|
gradle-user-home-not-fully-restored:
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-groovy-
|
GRADLE_BUILD_ACTION_CACHE_KEY_JOB: restore-cc-groovy
|
||||||
needs: seed-build-groovy
|
needs: seed-build-groovy
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle with no extracted cache entries restored
|
- name: Setup Gradle with no extracted cache entries restored
|
||||||
uses: ./
|
uses: ./
|
||||||
env:
|
env:
|
||||||
@@ -84,49 +92,59 @@ jobs:
|
|||||||
|
|
||||||
seed-build-kotlin:
|
seed-build-kotlin:
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-kotlin-
|
GRADLE_BUILD_ACTION_CACHE_KEY_JOB: restore-cc-kotlin
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Execute 'help' with configuration-cache enabled
|
- name: Execute 'help' with configuration-cache enabled
|
||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
run: ./gradlew help --configuration-cache
|
run: ./gradlew help --configuration-cache
|
||||||
|
|
||||||
modify-build-kotlin:
|
modify-build-kotlin:
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-kotlin-
|
GRADLE_BUILD_ACTION_CACHE_KEY_JOB: restore-cc-kotlin-modified
|
||||||
needs: seed-build-kotlin
|
needs: seed-build-kotlin
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Execute 'test' with configuration-cache enabled
|
- name: Execute 'test' with configuration-cache enabled
|
||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
run: ./gradlew test --configuration-cache
|
run: ./gradlew test --configuration-cache
|
||||||
|
|
||||||
# Test restore configuration-cache from the third build invocation
|
# Test restore configuration-cache from the third build invocation
|
||||||
configuration-cache-kotlin:
|
verify-build-kotlin:
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-kotlin-
|
GRADLE_BUILD_ACTION_CACHE_KEY_JOB: restore-cc-kotlin-modified
|
||||||
needs: modify-build-kotlin
|
needs: modify-build-kotlin
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -137,7 +155,7 @@ jobs:
|
|||||||
run: ./gradlew test --configuration-cache
|
run: ./gradlew test --configuration-cache
|
||||||
- name: Check that configuration-cache was used
|
- name: Check that configuration-cache was used
|
||||||
if: ${{ steps.execute.outputs.task_configured == 'yes' }}
|
if: ${{ steps.execute.outputs.task_configured == 'yes' }}
|
||||||
uses: actions/github-script@v5
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
core.setFailed('Configuration cache was not used - task was configured unexpectedly')
|
core.setFailed('Configuration cache was not used - task was configured unexpectedly')
|
60
.github/workflows/integ-test-restore-containerized-gradle-home.yml
vendored
Normal file
60
.github/workflows/integ-test-restore-containerized-gradle-home.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
name: Test restore custom Gradle Home
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
cache-key-prefix:
|
||||||
|
type: string
|
||||||
|
download-dist:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: restore-custom-gradle-home-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
seed-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: fedora:latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
distribution: temurin
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
|
- name: Build using Gradle wrapper
|
||||||
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
run: ./gradlew test
|
||||||
|
|
||||||
|
# Test that the gradle-user-home cache will cache dependencies, by running build with --offline
|
||||||
|
dependencies-cache:
|
||||||
|
needs: seed-build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: fedora:latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
distribution: temurin
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: true
|
||||||
|
- name: Execute Gradle build with --offline
|
||||||
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
run: ./gradlew test --offline
|
77
.github/workflows/integ-test-restore-custom-gradle-home.yml
vendored
Normal file
77
.github/workflows/integ-test-restore-custom-gradle-home.yml
vendored
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
name: Test restore custom Gradle Home
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
cache-key-prefix:
|
||||||
|
type: string
|
||||||
|
download-dist:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: restore-custom-gradle-home-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
seed-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set Gradle User Home
|
||||||
|
run: |
|
||||||
|
mkdir -p $GITHUB_WORKSPACE/gradle-user-home
|
||||||
|
echo "GRADLE_USER_HOME=$GITHUB_WORKSPACE/gradle-user-home" >> $GITHUB_ENV
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
|
- name: Build using Gradle wrapper
|
||||||
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
run: ./gradlew test --info
|
||||||
|
|
||||||
|
# Test that the gradle-user-home cache will cache dependencies, by running build with --offline
|
||||||
|
dependencies-cache:
|
||||||
|
needs: seed-build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set Gradle User Home
|
||||||
|
run: |
|
||||||
|
mkdir -p $GITHUB_WORKSPACE/gradle-user-home
|
||||||
|
echo "GRADLE_USER_HOME=$GITHUB_WORKSPACE/gradle-user-home" >> $GITHUB_ENV
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: true
|
||||||
|
- name: Execute Gradle build with --offline
|
||||||
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
run: ./gradlew test --offline --info
|
||||||
|
|
||||||
|
# Test that the gradle-user-home cache will cache and restore local build-cache
|
||||||
|
build-cache:
|
||||||
|
needs: seed-build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set Gradle User Home
|
||||||
|
run: |
|
||||||
|
mkdir -p $GITHUB_WORKSPACE/gradle-user-home
|
||||||
|
echo "GRADLE_USER_HOME=$GITHUB_WORKSPACE/gradle-user-home" >> $GITHUB_ENV
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: true
|
||||||
|
- name: Execute Gradle build and verify tasks from cache
|
||||||
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
run: ./gradlew test -DverifyCachedBuild=true --info
|
@@ -1,31 +1,38 @@
|
|||||||
name: Test save/restore Gradle Home directory
|
name: Test restore Gradle Home
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types: [assigned, review_requested]
|
inputs:
|
||||||
push:
|
cache-key-prefix:
|
||||||
paths:
|
type: string
|
||||||
- '.github/**'
|
runner-os:
|
||||||
- 'dist/**'
|
type: string
|
||||||
workflow_dispatch:
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
concurrency:
|
type: boolean
|
||||||
group: ${{ github.workflow }}
|
default: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: restore-gradle-home-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_JOB: restore-gradle-home
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
seed-build:
|
seed-build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Build using Gradle wrapper
|
- name: Build using Gradle wrapper
|
||||||
working-directory: .github/workflow-samples/groovy-dsl
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
run: ./gradlew test
|
run: ./gradlew test
|
||||||
@@ -35,11 +42,13 @@ jobs:
|
|||||||
needs: seed-build
|
needs: seed-build
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -53,11 +62,13 @@ jobs:
|
|||||||
needs: seed-build
|
needs: seed-build
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -71,11 +82,13 @@ jobs:
|
|||||||
needs: seed-build
|
needs: seed-build
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle with no extracted cache entries restored
|
- name: Setup Gradle with no extracted cache entries restored
|
||||||
uses: ./
|
uses: ./
|
||||||
env:
|
env:
|
57
.github/workflows/integ-test-restore-java-toolchain.yml
vendored
Normal file
57
.github/workflows/integ-test-restore-java-toolchain.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
name: Test restore java toolchains
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
cache-key-prefix:
|
||||||
|
type: string
|
||||||
|
runner-os:
|
||||||
|
type: string
|
||||||
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: restore-java-toolchain-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
seed-build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
|
- name: Build using Gradle wrapper
|
||||||
|
working-directory: .github/workflow-samples/java-toolchain
|
||||||
|
run: ./gradlew test --info
|
||||||
|
|
||||||
|
# Test that the gradle-user-home cache will cache the toolchain, by running build with --offline
|
||||||
|
toolchain-cache:
|
||||||
|
needs: seed-build
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: true
|
||||||
|
- name: Execute Gradle build with --offline
|
||||||
|
working-directory: .github/workflow-samples/java-toolchain
|
||||||
|
run: ./gradlew test --info --offline
|
56
.github/workflows/integ-test-sample-gradle-plugin.yml
vendored
Normal file
56
.github/workflows/integ-test-sample-gradle-plugin.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: Test sample Gradle Plugin project
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
cache-key-prefix:
|
||||||
|
type: string
|
||||||
|
runner-os:
|
||||||
|
type: string
|
||||||
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: sample-gradle-plugin-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
seed-build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
|
- name: Build gradle-plugin project
|
||||||
|
working-directory: .github/workflow-samples/gradle-plugin
|
||||||
|
run: ./gradlew build
|
||||||
|
|
||||||
|
verify-build:
|
||||||
|
needs: seed-build
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: true
|
||||||
|
- name: Build gradle-plugin project
|
||||||
|
working-directory: .github/workflow-samples/gradle-plugin
|
||||||
|
run: ./gradlew build --offline
|
56
.github/workflows/integ-test-sample-kotlin-dsl.yml
vendored
Normal file
56
.github/workflows/integ-test-sample-kotlin-dsl.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: Test sample Kotlin DSL project
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
cache-key-prefix:
|
||||||
|
type: string
|
||||||
|
runner-os:
|
||||||
|
type: string
|
||||||
|
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
|
||||||
|
download-dist:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: sample-kotlin-dsl-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
seed-build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
|
- name: Build kotlin-dsl project
|
||||||
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
run: ./gradlew build
|
||||||
|
|
||||||
|
verify-build:
|
||||||
|
needs: seed-build
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Download distribution if required
|
||||||
|
uses: ./.github/actions/download-dist
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: true
|
||||||
|
- name: Build kotlin-dsl project
|
||||||
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
run: ./gradlew build --offline
|
37
.github/workflows/integTest-action-inputs.yml
vendored
37
.github/workflows/integTest-action-inputs.yml
vendored
@@ -1,37 +0,0 @@
|
|||||||
name: Test different action inputs
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [assigned, review_requested]
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- '.github/**'
|
|
||||||
- 'dist/**'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}
|
|
||||||
|
|
||||||
env:
|
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
action-inputs:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Invoke with multi-line arguments
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
build-root-directory: .github/workflow-samples/groovy-dsl
|
|
||||||
arguments: |
|
|
||||||
--configuration-cache
|
|
||||||
--build-cache
|
|
||||||
-DsystemProperty=FOO
|
|
||||||
-PgradleProperty=BAR
|
|
||||||
test
|
|
||||||
jar
|
|
@@ -1,49 +0,0 @@
|
|||||||
name: Test save/restore java toolchains
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [assigned, review_requested]
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- '.github/**'
|
|
||||||
- 'dist/**'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}
|
|
||||||
|
|
||||||
env:
|
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
seed-build:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: ./
|
|
||||||
- name: Build using Gradle wrapper
|
|
||||||
working-directory: .github/workflow-samples/java-toolchain
|
|
||||||
run: ./gradlew test --info
|
|
||||||
|
|
||||||
# Test that the gradle-user-home cache will cache the toolchain, by running build with --offline
|
|
||||||
toolchain-cache:
|
|
||||||
needs: seed-build
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
cache-read-only: true
|
|
||||||
- name: Execute Gradle build with --offline
|
|
||||||
working-directory: .github/workflow-samples/java-toolchain
|
|
||||||
run: ./gradlew test --info --offline
|
|
@@ -1,49 +0,0 @@
|
|||||||
name: Test save/restore Gradle state with direct execution
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [assigned, review_requested]
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- '.github/**'
|
|
||||||
- 'dist/**'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}
|
|
||||||
|
|
||||||
env:
|
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
seed-build:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Execute Gradle build
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
build-root-directory: .github/workflow-samples/groovy-dsl
|
|
||||||
arguments: test
|
|
||||||
|
|
||||||
# Test that the gradle-user-home is restored
|
|
||||||
verify-build:
|
|
||||||
needs: seed-build
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Execute Gradle build
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
cache-read-only: true
|
|
||||||
build-root-directory: .github/workflow-samples/groovy-dsl
|
|
||||||
arguments: test --offline -DverifyCachedBuild=true
|
|
||||||
|
|
70
.github/workflows/integTest-gradle-user-home.yml
vendored
70
.github/workflows/integTest-gradle-user-home.yml
vendored
@@ -1,70 +0,0 @@
|
|||||||
name: Test caching with a custom GRADLE_USER_HOME
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [assigned, review_requested]
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- '.github/**'
|
|
||||||
- 'dist/**'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}
|
|
||||||
|
|
||||||
env:
|
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
|
||||||
GRADLE_USER_HOME: ${{github.workspace}}/custom/gradle/home
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
# Run initial Gradle builds to push initial cache entries
|
|
||||||
# These builds should start fresh without cache hits, due to the seed injected into the cache key above.
|
|
||||||
seed-build:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: ./
|
|
||||||
- name: Build using Gradle wrapper
|
|
||||||
working-directory: .github/workflow-samples/groovy-dsl
|
|
||||||
run: ./gradlew test --info
|
|
||||||
|
|
||||||
# Test that the gradle-user-home cache will cache dependencies, by running build with --offline
|
|
||||||
dependencies-cache:
|
|
||||||
needs: seed-build
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
cache-read-only: true
|
|
||||||
- name: Execute Gradle build with --offline
|
|
||||||
working-directory: .github/workflow-samples/groovy-dsl
|
|
||||||
run: ./gradlew test --offline --info
|
|
||||||
|
|
||||||
# Test that the gradle-user-home cache will cache and restore local build-cache
|
|
||||||
build-cache:
|
|
||||||
needs: seed-build
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
cache-read-only: true
|
|
||||||
- name: Execute Gradle build and verify tasks from cache
|
|
||||||
working-directory: .github/workflow-samples/groovy-dsl
|
|
||||||
run: ./gradlew test -DverifyCachedBuild=true --info
|
|
@@ -1,47 +0,0 @@
|
|||||||
name: Test caching with Gradle Plugin project using TestKit
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [assigned, review_requested]
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- '.github/**'
|
|
||||||
- 'dist/**'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}
|
|
||||||
|
|
||||||
env:
|
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
|
||||||
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
seed-build:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: ./
|
|
||||||
- name: Build gradle-plugin project
|
|
||||||
working-directory: .github/workflow-samples/gradle-plugin
|
|
||||||
run: ./gradlew build
|
|
||||||
|
|
||||||
verify-build:
|
|
||||||
needs: seed-build
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: ./
|
|
||||||
- name: Build gradle-plugin project
|
|
||||||
working-directory: .github/workflow-samples/gradle-plugin
|
|
||||||
run: ./gradlew build --offline
|
|
@@ -1,47 +0,0 @@
|
|||||||
name: Test caching with Kotlin DSL
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [assigned, review_requested]
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- '.github/**'
|
|
||||||
- 'dist/**'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}
|
|
||||||
|
|
||||||
env:
|
|
||||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}:${{github.run_attempt}}-
|
|
||||||
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
seed-build:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: ./
|
|
||||||
- name: Build kotlin-dsl project
|
|
||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
|
||||||
run: ./gradlew build
|
|
||||||
|
|
||||||
verify-build:
|
|
||||||
needs: seed-build
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: ./
|
|
||||||
- name: Build kotlin-dsl project
|
|
||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
|
||||||
run: ./gradlew build --offline
|
|
28
.github/workflows/purge-old-workflow-runs.yml
vendored
Normal file
28
.github/workflows/purge-old-workflow-runs.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: Purge old workflow runs
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
days:
|
||||||
|
description: 'Purge runs older than days'
|
||||||
|
required: true
|
||||||
|
default: 30
|
||||||
|
minimum_runs:
|
||||||
|
description: 'The minimum runs to keep for each workflow.'
|
||||||
|
required: true
|
||||||
|
default: 6
|
||||||
|
delete_workflow_pattern:
|
||||||
|
description: 'The name of the workflow. if not set then it will target all workflows.'
|
||||||
|
required: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
del_runs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Purge workflow runs
|
||||||
|
uses: Mattraks/delete-workflow-runs@v2
|
||||||
|
with:
|
||||||
|
token: ${{ github.token }}
|
||||||
|
repository: ${{ github.repository }}
|
||||||
|
retain_days: ${{ github.event.inputs.days }}
|
||||||
|
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
|
||||||
|
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
|
76
README.md
76
README.md
@@ -19,8 +19,8 @@ jobs:
|
|||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 11
|
java-version: 11
|
||||||
@@ -34,7 +34,7 @@ jobs:
|
|||||||
|
|
||||||
## Why use the `gradle-build-action`?
|
## Why use the `gradle-build-action`?
|
||||||
|
|
||||||
It is possible to directly invoke Gradle in your workflow, and the `actions/setup-java@v2` action provides a simple way to cache Gradle dependencies.
|
It is possible to directly invoke Gradle in your workflow, and the `actions/setup-java@v3` action provides a simple way to cache Gradle dependencies.
|
||||||
|
|
||||||
However, the `gradle-build-action` offers a number of advantages over this approach:
|
However, the `gradle-build-action` offers a number of advantages over this approach:
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ However, the `gradle-build-action` offers a number of advantages over this appro
|
|||||||
The `gradle-build-action` is designed to provide these benefits with minimal configuration.
|
The `gradle-build-action` is designed to provide these benefits with minimal configuration.
|
||||||
These features work both when Gradle is executed via the `gradle-build-action` and for any Gradle execution in subsequent steps.
|
These features work both when Gradle is executed via the `gradle-build-action` and for any Gradle execution in subsequent steps.
|
||||||
|
|
||||||
When using `gradle-build-action` we recommend that you _not_ use `actions/cache` or `actions/setup-java@v2` to explicitly cache the Gradle User Home. Doing so may interfere with the caching provided by this action.
|
When using `gradle-build-action` we recommend that you _not_ use `actions/cache` or `actions/setup-java@v3` to explicitly cache the Gradle User Home. Doing so may interfere with the caching provided by this action.
|
||||||
|
|
||||||
## Use a specific Gradle version
|
## Use a specific Gradle version
|
||||||
|
|
||||||
@@ -82,9 +82,10 @@ jobs:
|
|||||||
gradle-rc:
|
gradle-rc:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
|
distribution: temurin
|
||||||
java-version: 11
|
java-version: 11
|
||||||
- uses: gradle/gradle-build-action@v2
|
- uses: gradle/gradle-build-action@v2
|
||||||
with:
|
with:
|
||||||
@@ -108,9 +109,10 @@ jobs:
|
|||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
|
distribution: temurin
|
||||||
java-version: 11
|
java-version: 11
|
||||||
|
|
||||||
- name: Setup and execute Gradle 'test' task
|
- name: Setup and execute Gradle 'test' task
|
||||||
@@ -135,7 +137,7 @@ The initial Action step will perform the Gradle setup.
|
|||||||
|
|
||||||
### Gradle command-line arguments
|
### Gradle command-line arguments
|
||||||
|
|
||||||
The `arguments` input can used to pass arbitrary arguments to the `gradle` command line.
|
The `arguments` input can be used to pass arbitrary arguments to the `gradle` command line.
|
||||||
Arguments can be supplied in a single line, or as a multi-line input.
|
Arguments can be supplied in a single line, or as a multi-line input.
|
||||||
|
|
||||||
Here are some valid examples:
|
Here are some valid examples:
|
||||||
@@ -195,7 +197,7 @@ By default, this action aims to cache any and all reusable state that may be spe
|
|||||||
The state that is cached includes:
|
The state that is cached includes:
|
||||||
- Any distributions downloaded to satisfy a `gradle-version` parameter ;
|
- Any distributions downloaded to satisfy a `gradle-version` parameter ;
|
||||||
- A subset of the Gradle User Home directory, including downloaded dependencies, wrapper distributions, and the local build cache ;
|
- A subset of the Gradle User Home directory, including downloaded dependencies, wrapper distributions, and the local build cache ;
|
||||||
- Any [configuration-cache](https://docs.gradle.org/nightly/userguide/configuration_cache.html) data stored in the project `.gradle` directory.
|
- Any [configuration-cache](https://docs.gradle.org/nightly/userguide/configuration_cache.html) data stored in the project `.gradle` directory. (Only supported for Gradle 7 or higher.)
|
||||||
|
|
||||||
To reduce the space required for caching, this action makes a best effort to reduce duplication in cache entries.
|
To reduce the space required for caching, this action makes a best effort to reduce duplication in cache entries.
|
||||||
|
|
||||||
@@ -203,7 +205,6 @@ Caching is enabled by default. You can disable caching for the action as follows
|
|||||||
```yaml
|
```yaml
|
||||||
cache-disabled: true
|
cache-disabled: true
|
||||||
```
|
```
|
||||||
|
|
||||||
### Cache keys
|
### Cache keys
|
||||||
|
|
||||||
Distributions downloaded to satisfy a `gradle-version` parameter are stored outside of Gradle User Home and cached separately. The cache key is unique to the downloaded distribution and will not change over time.
|
Distributions downloaded to satisfy a `gradle-version` parameter are stored outside of Gradle User Home and cached separately. The cache key is unique to the downloaded distribution and will not change over time.
|
||||||
@@ -218,17 +219,27 @@ For example, this means that all jobs executing a particular version of the Grad
|
|||||||
|
|
||||||
### Using the caches read-only
|
### Using the caches read-only
|
||||||
|
|
||||||
In some circumstances, it makes sense for a Gradle invocation to read any existing cache entries but not to write changes back.
|
By default, the `gradle-build-action` will only write to the cache from Jobs on the default (`main`/`master`) branch.
|
||||||
For example, you may want to write cache entries for builds on your `main` branch, but not for any PR build invocations.
|
Jobs on other branches will read entries from the cache but will not write updated entries.
|
||||||
|
See [Optimizing cache effectiveness](#optimizing-cache-effectiveness) for a more detailed explanation.
|
||||||
|
|
||||||
You can enable read-only caching for any of the caches as follows:
|
In some circumstances it makes sense to change this default, and to configure a workflow Job to read existing cache entries but not to write changes back.
|
||||||
|
|
||||||
|
You can configure read-only caching for the `gradle-build-action` as follows:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Only write to the cache for builds on the 'main' branch.
|
# Only write to the cache for builds on the 'main' and 'release' branches. (Default is 'main' only.)
|
||||||
# Builds on other branches will only read existing entries from the cache.
|
# Builds on other branches will only read existing entries from the cache.
|
||||||
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
|
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/release' }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Stopping the Gradle daemon
|
||||||
|
|
||||||
|
By default, the action will stop all running Gradle daemons in the post-action step, prior to saving the Gradle User Home state.
|
||||||
|
This allows for any Gradle User Home cleanup to occur, and avoid file-locking issues on Windows.
|
||||||
|
|
||||||
|
If caching is unavailable or the cache is in read-only mode, the daemon will not be stopped and will continue running after the job is completed.
|
||||||
|
|
||||||
### Gradle User Home cache tuning
|
### Gradle User Home cache tuning
|
||||||
|
|
||||||
As well as any wrapper distributions, the action will attempt to save and restore the `caches` and `notifications` directories from Gradle User Home.
|
As well as any wrapper distributions, the action will attempt to save and restore the `caches` and `notifications` directories from Gradle User Home.
|
||||||
@@ -253,7 +264,7 @@ File pattern support is documented at https://docs.github.com/en/actions/learn-g
|
|||||||
|
|
||||||
Gradle User Home state will be restored from the cache during the first `gradle-build-action` step for any workflow job.
|
Gradle User Home state will be restored from the cache during the first `gradle-build-action` step for any workflow job.
|
||||||
This state will be saved back to the cache at the end of the job, after all Gradle executions have completed.
|
This state will be saved back to the cache at the end of the job, after all Gradle executions have completed.
|
||||||
A report of all cache entries restored and saved is printed to the action log when saving the cache entries.
|
A report of all cache entries restored and saved is printed to the Job Summary when saving the cache entries.
|
||||||
This report can provide valuable insignt into how much cache space is being used.
|
This report can provide valuable insignt into how much cache space is being used.
|
||||||
|
|
||||||
It is possible to enable additional debug logging for cache operations. You do via the `GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED` environment variable:
|
It is possible to enable additional debug logging for cache operations. You do via the `GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED` environment variable:
|
||||||
@@ -267,18 +278,25 @@ Note that this setting will also prevent certain cache operations from running i
|
|||||||
|
|
||||||
### Optimizing cache effectiveness
|
### Optimizing cache effectiveness
|
||||||
|
|
||||||
Cache storage space for GitHub actions is limited, and writing new cache entries can trigger the deletion of exising entries.
|
Cache storage space for GitHub actions is limited, and writing new cache entries can trigger the deletion of existing entries.
|
||||||
Eviction of shared cache entries can reduce cache effectiveness, slowing down your `gradle-build-action` steps.
|
Eviction of shared cache entries can reduce cache effectiveness, slowing down your `gradle-build-action` steps.
|
||||||
|
|
||||||
There are a number of actions you can take if your cache use is less effective due to entry eviction.
|
There are a number of actions you can take if your cache use is less effective due to entry eviction.
|
||||||
|
|
||||||
#### Only write to the cache from the default branch
|
#### Select branches that should write to the cache
|
||||||
|
|
||||||
GitHub cache entries are not shared between builds on different branches. This means that identical cache entries will be stored separately for different branches.
|
GitHub cache entries are not shared between builds on different branches.
|
||||||
The exception to the is cache entries for the default (`master`/`main`) branch can be read by actions invoked for other branches.
|
This means that each PR branch will have it's own Gradle User Home cache, and will not benefit from cache entries written by other PR branches.
|
||||||
|
An exception to this is that cache entries written in parent and upstream branches are visible to child branches, and cache entries for the default (`master`/`main`) branch can be read by actions invoked for any other branch.
|
||||||
|
|
||||||
An easy way to reduce cache usage when you run builds on many different branches is to only permit your default branch to write to the cache,
|
By default, the `gradle-build-action` will only _write_ to the cache for builds run on the default (`master`/`main`) branch.
|
||||||
with all other branch builds using `cache-read-only`. See [Using the caches read-only](#using-the-caches-read-only) for more details.
|
Jobs run on other branches will only read from the cache. In most cases, this is the desired behaviour,
|
||||||
|
because Jobs run against other branches will benefit from the cache Gradle User Home from `main`,
|
||||||
|
without writing private cache entries that could lead to evicting shared entries.
|
||||||
|
|
||||||
|
If you have other long-lived development branches that would benefit from writing to the cache,
|
||||||
|
you can configure these by overriding the `cache-read-only` action parameter.
|
||||||
|
See [Using the caches read-only](#using-the-caches-read-only) for more details.
|
||||||
|
|
||||||
Similarly, you could use `cache-read-only` for certain jobs in the workflow, and instead have these jobs reuse the cache content from upstream jobs.
|
Similarly, you could use `cache-read-only` for certain jobs in the workflow, and instead have these jobs reuse the cache content from upstream jobs.
|
||||||
|
|
||||||
@@ -302,7 +320,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout project sources
|
- name: Checkout project sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/gradle-build-action@v2
|
uses: gradle/gradle-build-action@v2
|
||||||
- name: Run build with Gradle wrapper
|
- name: Run build with Gradle wrapper
|
||||||
@@ -331,7 +349,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout project sources
|
- name: Checkout project sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/gradle-build-action@v2
|
uses: gradle/gradle-build-action@v2
|
||||||
- name: Run build with Gradle wrapper
|
- name: Run build with Gradle wrapper
|
||||||
@@ -350,3 +368,11 @@ jobs:
|
|||||||
body: '❌ ${{ github.workflow }} failed: ${{ steps.gradle.outputs.build-scan-url }}'
|
body: '❌ ${{ github.workflow }} failed: ${{ steps.gradle.outputs.build-scan-url }}'
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Support for GitHub Enterprise Server (GHES)
|
||||||
|
|
||||||
|
You can use the `gradle-build-action` on GitHub Enterprise Server, and benefit from the improved integration with Gradle. Depending on the version of GHES you are running, certain features may be limited:
|
||||||
|
- Build scan links are captured and displayed in the GitHub Actions UI
|
||||||
|
- Easily run your build with different versions of Gradle
|
||||||
|
- Save/restore of Gradle User Home (requires GHES v3.5+ : GitHub Actions cache was introduced in GHES 3.5)
|
||||||
|
- Support for GitHub Actions Job Summary is not yet available in any version of GHES. Instead of producing a Job Summary, the build-results summary and caching report will be written to the workflow log, as part of the post-action step.
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'java'
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testImplementation('junit:junit:4.12')
|
|
||||||
}
|
|
185
__tests__/data/crypto-utils-test/gradlew
vendored
185
__tests__/data/crypto-utils-test/gradlew
vendored
@@ -1,185 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright 2015 the original author or authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
##
|
|
||||||
## Gradle start up script for UN*X
|
|
||||||
##
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
PRG="$0"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=`basename "$0"`
|
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD="maximum"
|
|
||||||
|
|
||||||
warn () {
|
|
||||||
echo "$*"
|
|
||||||
}
|
|
||||||
|
|
||||||
die () {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
nonstop=false
|
|
||||||
case "`uname`" in
|
|
||||||
CYGWIN* )
|
|
||||||
cygwin=true
|
|
||||||
;;
|
|
||||||
Darwin* )
|
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
|
||||||
else
|
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
|
||||||
fi
|
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
JAVACMD="java"
|
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
|
||||||
if [ $? -eq 0 ] ; then
|
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
ulimit -n $MAX_FD
|
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Escape application args
|
|
||||||
save () {
|
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
|
||||||
echo " "
|
|
||||||
}
|
|
||||||
APP_ARGS=`save "$@"`
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
@@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file was generated by the Gradle 'init' task.
|
|
||||||
*
|
|
||||||
* The settings file is used to specify which projects to include in your build.
|
|
||||||
*
|
|
||||||
* Detailed information about configuring a multi-project build in Gradle can be found
|
|
||||||
* in the user manual at https://docs.gradle.org/6.5/userguide/multi_project_builds.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
rootProject.name = 'basic'
|
|
@@ -1,10 +0,0 @@
|
|||||||
package basic;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class BasicTest {
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
assert true;
|
|
||||||
}
|
|
||||||
}
|
|
26
action.yml
26
action.yml
@@ -14,11 +14,18 @@ inputs:
|
|||||||
default: false
|
default: false
|
||||||
|
|
||||||
cache-read-only:
|
cache-read-only:
|
||||||
description: When 'true', existing entries will be read from the cache but no entries will be written.
|
description: |
|
||||||
|
When 'true', existing entries will be read from the cache but no entries will be written.
|
||||||
|
By default this value is 'false' for workflows on the GitHub default branch and 'true' for workflows on other branches.
|
||||||
|
required: false
|
||||||
|
default: ${{ github.event.repository != null && github.ref_name != github.event.repository.default_branch }}
|
||||||
|
|
||||||
|
cache-write-only:
|
||||||
|
description: |
|
||||||
|
When 'true', entries will not be restored from the cache but will be saved at the end of the Job.
|
||||||
|
Setting this to 'true' implies cache-read-only will be 'false'.
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
# e.g. Use the following setting to only write cache entries from your 'main' branch
|
|
||||||
# cache-read-only: ${{ github.ref != 'refs/heads/main' }}
|
|
||||||
|
|
||||||
gradle-home-cache-includes:
|
gradle-home-cache-includes:
|
||||||
description: Paths within Gradle User Home to cache.
|
description: Paths within Gradle User Home to cache.
|
||||||
@@ -46,14 +53,15 @@ inputs:
|
|||||||
description: Path to the Gradle executable
|
description: Path to the Gradle executable
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
|
generate-job-summary:
|
||||||
|
description: When 'false', no Job Summary will be generated for the Job.
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
|
||||||
# EXPERIMENTAL & INTERNAL ACTION INPUTS
|
# EXPERIMENTAL & INTERNAL ACTION INPUTS
|
||||||
# The following action properties allow fine-grained tweaking of the action caching behaviour.
|
# The following action properties allow fine-grained tweaking of the action caching behaviour.
|
||||||
# These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
|
# These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
|
||||||
# Use at your own risk!
|
# Use at your own risk!
|
||||||
cache-write-only:
|
|
||||||
description: When 'true', entries will not be restored from the cache but will be saved at the end of the Job. This allows a 'clean' cache entry to be written.
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
gradle-home-cache-strict-match:
|
gradle-home-cache-strict-match:
|
||||||
description: When 'true', the action will not attempt to restore the Gradle User Home entries from other Jobs.
|
description: When 'true', the action will not attempt to restore the Gradle User Home entries from other Jobs.
|
||||||
required: false
|
required: false
|
||||||
@@ -62,6 +70,10 @@ inputs:
|
|||||||
description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users (INTERNAL).
|
description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users (INTERNAL).
|
||||||
required: false
|
required: false
|
||||||
default: ${{ toJSON(matrix) }}
|
default: ${{ toJSON(matrix) }}
|
||||||
|
gradle-home-cache-cleanup:
|
||||||
|
description: When 'true', the action will attempt to remove any stale/unused entries from the Gradle User Home prior to saving to the GitHub Actions cache.
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
build-scan-url:
|
build-scan-url:
|
||||||
|
67557
dist/main/index.js
vendored
67557
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/main/index.js.map
vendored
2
dist/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
66241
dist/post/index.js
vendored
66241
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js.map
vendored
2
dist/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
3414
package-lock.json
generated
3414
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
29
package.json
29
package.json
@@ -8,9 +8,11 @@
|
|||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format-check": "prettier --check **/*.ts",
|
||||||
"lint": "eslint src/**/*.ts",
|
"lint": "eslint src/**/*.ts",
|
||||||
"build": "ncc build src/main.ts --out dist/main --source-map --minify && ncc build src/post.ts --out dist/post --source-map --minify",
|
"compile": "ncc build src/main.ts --out dist/main --source-map && ncc build src/post.ts --out dist/post --source-map",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"all": "npm run format && npm run lint && npm run build && npm test"
|
"check": "npm run format && npm run lint",
|
||||||
|
"build": "npm run check && npm run compile",
|
||||||
|
"all": "npm run build && npm test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -24,8 +26,8 @@
|
|||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "2.0.4",
|
"@actions/cache": "3.0.4",
|
||||||
"@actions/core": "1.8.2",
|
"@actions/core": "1.9.1",
|
||||||
"@actions/exec": "1.1.1",
|
"@actions/exec": "1.1.1",
|
||||||
"@actions/github": "5.0.3",
|
"@actions/github": "5.0.3",
|
||||||
"@actions/glob": "0.3.0",
|
"@actions/glob": "0.3.0",
|
||||||
@@ -34,18 +36,19 @@
|
|||||||
"string-argv": "0.3.1"
|
"string-argv": "0.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/jest": "28.1.7",
|
||||||
"@types/node": "16.11.21",
|
"@types/node": "16.11.21",
|
||||||
"@types/unzipper": "0.10.5",
|
"@types/unzipper": "0.10.5",
|
||||||
"@typescript-eslint/parser": "5.23.0",
|
"@typescript-eslint/parser": "5.35.1",
|
||||||
"@vercel/ncc": "0.33.4",
|
"@vercel/ncc": "0.34.0",
|
||||||
"eslint": "8.15.0",
|
"eslint": "8.22.0",
|
||||||
"eslint-plugin-github": "4.3.6",
|
"eslint-plugin-github": "4.3.7",
|
||||||
"eslint-plugin-jest": "26.2.2",
|
"eslint-plugin-jest": "26.8.7",
|
||||||
"jest": "28.1.0",
|
"jest": "28.1.3",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"patch-package": "6.4.7",
|
"patch-package": "6.4.7",
|
||||||
"prettier": "2.6.2",
|
"prettier": "2.7.1",
|
||||||
"ts-jest": "28.0.2",
|
"ts-jest": "28.0.8",
|
||||||
"typescript": "4.6.4"
|
"typescript": "4.8.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,18 +26,17 @@ index 16b20f7..aea77ba 100644
|
|||||||
+ constructor(key: string, size?: number);
|
+ constructor(key: string, size?: number);
|
||||||
+}
|
+}
|
||||||
diff --git a/node_modules/@actions/cache/lib/cache.js b/node_modules/@actions/cache/lib/cache.js
|
diff --git a/node_modules/@actions/cache/lib/cache.js b/node_modules/@actions/cache/lib/cache.js
|
||||||
index 0b5a2a8..757ad88 100644
|
index 4dc5e88..92d99d5 100644
|
||||||
--- a/node_modules/@actions/cache/lib/cache.js
|
--- a/node_modules/@actions/cache/lib/cache.js
|
||||||
+++ b/node_modules/@actions/cache/lib/cache.js
|
+++ b/node_modules/@actions/cache/lib/cache.js
|
||||||
@@ -93,6 +93,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
@@ -95,26 +95,18 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
}
|
}
|
||||||
const archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||||||
core.debug(`Archive Path: ${archivePath}`);
|
core.debug(`Archive Path: ${archivePath}`);
|
||||||
+ const restoredEntry = new CacheEntry(cacheEntry.cacheKey);
|
+ const restoredEntry = new CacheEntry(cacheEntry.cacheKey);
|
||||||
try {
|
|
||||||
// Download the cache from the cache entry
|
// Download the cache from the cache entry
|
||||||
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
|
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
|
||||||
@@ -100,6 +101,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
if (core.isDebug()) {
|
||||||
yield tar_1.listTar(archivePath, compressionMethod);
|
yield tar_1.listTar(archivePath, compressionMethod);
|
||||||
}
|
}
|
||||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
@@ -45,16 +44,22 @@ index 0b5a2a8..757ad88 100644
|
|||||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||||
yield tar_1.extractTar(archivePath, compressionMethod);
|
yield tar_1.extractTar(archivePath, compressionMethod);
|
||||||
core.info('Cache restored successfully');
|
core.info('Cache restored successfully');
|
||||||
@@ -113,7 +115,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
|
||||||
core.debug(`Failed to delete archive: ${error}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- return cacheEntry.cacheKey;
|
- return cacheEntry.cacheKey;
|
||||||
|
- }
|
||||||
|
- catch (error) {
|
||||||
|
- const typedError = error;
|
||||||
|
- if (typedError.name === ValidationError.name) {
|
||||||
|
- throw error;
|
||||||
|
- }
|
||||||
|
- else {
|
||||||
|
- // Supress all non-validation cache related errors because caching should be optional
|
||||||
|
- core.warning(`Failed to restore: ${error.message}`);
|
||||||
|
- }
|
||||||
+ return restoredEntry;
|
+ return restoredEntry;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
exports.restoreCache = restoreCache;
|
finally {
|
||||||
@@ -138,6 +140,7 @@ function saveCache(paths, key, options) {
|
// Try to delete the archive to save space
|
||||||
|
@@ -153,6 +145,7 @@ function saveCache(paths, key, options) {
|
||||||
const archiveFolder = yield utils.createTempDirectory();
|
const archiveFolder = yield utils.createTempDirectory();
|
||||||
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
|
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
|
||||||
core.debug(`Archive Path: ${archivePath}`);
|
core.debug(`Archive Path: ${archivePath}`);
|
||||||
@@ -62,7 +67,7 @@ index 0b5a2a8..757ad88 100644
|
|||||||
try {
|
try {
|
||||||
yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
|
yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
|
||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
@@ -145,6 +148,7 @@ function saveCache(paths, key, options) {
|
@@ -160,6 +153,7 @@ function saveCache(paths, key, options) {
|
||||||
}
|
}
|
||||||
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
|
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
|
||||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||||
@@ -70,7 +75,26 @@ index 0b5a2a8..757ad88 100644
|
|||||||
core.debug(`File Size: ${archiveFileSize}`);
|
core.debug(`File Size: ${archiveFileSize}`);
|
||||||
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
||||||
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
||||||
@@ -176,8 +180,15 @@ function saveCache(paths, key, options) {
|
@@ -182,18 +176,6 @@ function saveCache(paths, key, options) {
|
||||||
|
core.debug(`Saving Cache (ID: ${cacheId})`);
|
||||||
|
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||||
|
}
|
||||||
|
- catch (error) {
|
||||||
|
- const typedError = error;
|
||||||
|
- if (typedError.name === ValidationError.name) {
|
||||||
|
- throw error;
|
||||||
|
- }
|
||||||
|
- else if (typedError.name === ReserveCacheError.name) {
|
||||||
|
- core.info(`Failed to save: ${typedError.message}`);
|
||||||
|
- }
|
||||||
|
- else {
|
||||||
|
- core.warning(`Failed to save: ${typedError.message}`);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
finally {
|
||||||
|
// Try to delete the archive to save space
|
||||||
|
try {
|
||||||
|
@@ -203,8 +185,15 @@ function saveCache(paths, key, options) {
|
||||||
core.debug(`Failed to delete archive: ${error}`);
|
core.debug(`Failed to delete archive: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1 +0,0 @@
|
|||||||
[FIX] Save/restore exploded Gradle dist rather than zip
|
|
||||||
|
27
src/build-results.ts
Normal file
27
src/build-results.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import * as fs from 'fs'
|
||||||
|
import * as path from 'path'
|
||||||
|
|
||||||
|
export interface BuildResult {
|
||||||
|
get rootProjectName(): string
|
||||||
|
get rootProjectDir(): string
|
||||||
|
get requestedTasks(): string
|
||||||
|
get gradleVersion(): string
|
||||||
|
get gradleHomeDir(): string
|
||||||
|
get buildFailed(): boolean
|
||||||
|
get buildScanUri(): string
|
||||||
|
get buildScanFailed(): boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadBuildResults(): BuildResult[] {
|
||||||
|
const buildResultsDir = path.resolve(process.env['RUNNER_TEMP']!, '.build-results')
|
||||||
|
if (!fs.existsSync(buildResultsDir)) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return fs.readdirSync(buildResultsDir).map(file => {
|
||||||
|
// Every file in the .build-results dir should be a BuildResults JSON
|
||||||
|
const filePath = path.join(buildResultsDir, file)
|
||||||
|
const content = fs.readFileSync(filePath, 'utf8')
|
||||||
|
return JSON.parse(content) as BuildResult
|
||||||
|
})
|
||||||
|
}
|
@@ -1,83 +1,16 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as exec from '@actions/exec'
|
import * as exec from '@actions/exec'
|
||||||
import * as github from '@actions/github'
|
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import {CacheListener} from './cache-reporting'
|
import {CacheListener} from './cache-reporting'
|
||||||
import {
|
import {saveCache, restoreCache, cacheDebug, isCacheDebuggingEnabled, tryDelete, generateCacheKey} from './cache-utils'
|
||||||
getCacheKeyPrefix,
|
|
||||||
determineJobContext,
|
|
||||||
saveCache,
|
|
||||||
restoreCache,
|
|
||||||
cacheDebug,
|
|
||||||
isCacheDebuggingEnabled,
|
|
||||||
tryDelete
|
|
||||||
} from './cache-utils'
|
|
||||||
import {ConfigurationCacheEntryExtractor, GradleHomeEntryExtractor} from './cache-extract-entries'
|
import {ConfigurationCacheEntryExtractor, GradleHomeEntryExtractor} from './cache-extract-entries'
|
||||||
|
|
||||||
const CACHE_PROTOCOL_VERSION = 'v6-'
|
|
||||||
const RESTORED_CACHE_KEY_KEY = 'restored-cache-key'
|
const RESTORED_CACHE_KEY_KEY = 'restored-cache-key'
|
||||||
|
|
||||||
export const META_FILE_DIR = '.gradle-build-action'
|
export const META_FILE_DIR = '.gradle-build-action'
|
||||||
export const PROJECT_ROOTS_FILE = 'project-roots.txt'
|
|
||||||
const INCLUDE_PATHS_PARAMETER = 'gradle-home-cache-includes'
|
const INCLUDE_PATHS_PARAMETER = 'gradle-home-cache-includes'
|
||||||
const EXCLUDE_PATHS_PARAMETER = 'gradle-home-cache-excludes'
|
const EXCLUDE_PATHS_PARAMETER = 'gradle-home-cache-excludes'
|
||||||
const STRICT_CACHE_MATCH_PARAMETER = 'gradle-home-cache-strict-match'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a key used to restore a cache entry.
|
|
||||||
* The Github Actions cache will first try for an exact match on the key.
|
|
||||||
* If that fails, it will try for a prefix match on any of the restoreKeys.
|
|
||||||
*/
|
|
||||||
class CacheKey {
|
|
||||||
key: string
|
|
||||||
restoreKeys: string[]
|
|
||||||
|
|
||||||
constructor(key: string, restoreKeys: string[]) {
|
|
||||||
this.key = key
|
|
||||||
this.restoreKeys = restoreKeys
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a cache key specific to the current job execution.
|
|
||||||
* The key is constructed from the following inputs:
|
|
||||||
* - A user-defined prefix (optional)
|
|
||||||
* - The cache protocol version
|
|
||||||
* - The name of the cache
|
|
||||||
* - The runner operating system
|
|
||||||
* - The name of the Job being executed
|
|
||||||
* - The matrix values for the Job being executed (job context)
|
|
||||||
* - The SHA of the commit being executed
|
|
||||||
*
|
|
||||||
* Caches are restored by trying to match the these key prefixes in order:
|
|
||||||
* - The full key with SHA
|
|
||||||
* - A previous key for this Job + matrix
|
|
||||||
* - Any previous key for this Job (any matrix)
|
|
||||||
* - Any previous key for this cache on the current OS
|
|
||||||
*/
|
|
||||||
function generateCacheKey(cacheName: string): CacheKey {
|
|
||||||
const cacheKeyBase = `${getCacheKeyPrefix()}${CACHE_PROTOCOL_VERSION}${cacheName}`
|
|
||||||
|
|
||||||
// At the most general level, share caches for all executions on the same OS
|
|
||||||
const runnerOs = process.env['RUNNER_OS'] || ''
|
|
||||||
const cacheKeyForOs = `${cacheKeyBase}|${runnerOs}`
|
|
||||||
|
|
||||||
// Prefer caches that run this job
|
|
||||||
const cacheKeyForJob = `${cacheKeyForOs}|${github.context.job}`
|
|
||||||
|
|
||||||
// Prefer (even more) jobs that run this job with the same context (matrix)
|
|
||||||
const cacheKeyForJobContext = `${cacheKeyForJob}[${determineJobContext()}]`
|
|
||||||
|
|
||||||
// Exact match on Git SHA
|
|
||||||
const cacheKey = `${cacheKeyForJobContext}-${github.context.sha}`
|
|
||||||
|
|
||||||
if (core.getBooleanInput(STRICT_CACHE_MATCH_PARAMETER)) {
|
|
||||||
return new CacheKey(cacheKey, [cacheKeyForJobContext])
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CacheKey(cacheKey, [cacheKeyForJobContext, cacheKeyForJob, cacheKeyForOs])
|
|
||||||
}
|
|
||||||
|
|
||||||
export class GradleStateCache {
|
export class GradleStateCache {
|
||||||
private cacheName: string
|
private cacheName: string
|
||||||
@@ -161,9 +94,18 @@ export class GradleStateCache {
|
|||||||
async save(listener: CacheListener): Promise<void> {
|
async save(listener: CacheListener): Promise<void> {
|
||||||
const cacheKey = generateCacheKey(this.cacheName).key
|
const cacheKey = generateCacheKey(this.cacheName).key
|
||||||
const restoredCacheKey = core.getState(RESTORED_CACHE_KEY_KEY)
|
const restoredCacheKey = core.getState(RESTORED_CACHE_KEY_KEY)
|
||||||
|
const gradleHomeEntryListener = listener.entry(this.cacheDescription)
|
||||||
|
|
||||||
if (restoredCacheKey && cacheKey === restoredCacheKey) {
|
if (restoredCacheKey && cacheKey === restoredCacheKey) {
|
||||||
core.info(`Cache hit occurred on the cache key ${cacheKey}, not saving cache.`)
|
core.info(`Cache hit occurred on the cache key ${cacheKey}, not saving cache.`)
|
||||||
|
|
||||||
|
for (const entryListener of listener.cacheEntries) {
|
||||||
|
if (entryListener === gradleHomeEntryListener) {
|
||||||
|
entryListener.markNotSaved('cache key not changed')
|
||||||
|
} else {
|
||||||
|
entryListener.markNotSaved(`referencing '${this.cacheDescription}' cache entry not saved`)
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,8 +118,7 @@ export class GradleStateCache {
|
|||||||
|
|
||||||
core.info(`Caching ${this.cacheDescription} with cache key: ${cacheKey}`)
|
core.info(`Caching ${this.cacheDescription} with cache key: ${cacheKey}`)
|
||||||
const cachePath = this.getCachePath()
|
const cachePath = this.getCachePath()
|
||||||
const entryListener = listener.entry(this.cacheDescription)
|
await saveCache(cachePath, cacheKey, gradleHomeEntryListener)
|
||||||
await saveCache(cachePath, cacheKey, entryListener)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -232,77 +173,18 @@ export class GradleStateCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private initializeGradleUserHome(gradleUserHome: string, initScriptsDir: string): void {
|
private initializeGradleUserHome(gradleUserHome: string, initScriptsDir: string): void {
|
||||||
const propertiesFile = path.resolve(gradleUserHome, 'gradle.properties')
|
const initScriptFilenames = ['build-result-capture.init.gradle', 'build-result-capture-service.plugin.groovy']
|
||||||
fs.appendFileSync(propertiesFile, 'org.gradle.daemon=false')
|
for (const initScriptFilename of initScriptFilenames) {
|
||||||
|
const initScriptContent = this.readInitScriptAsString(initScriptFilename)
|
||||||
const buildScanCapture = path.resolve(initScriptsDir, 'build-scan-capture.init.gradle')
|
const initScriptPath = path.resolve(initScriptsDir, initScriptFilename)
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(initScriptPath, initScriptContent)
|
||||||
buildScanCapture,
|
|
||||||
`import org.gradle.util.GradleVersion
|
|
||||||
|
|
||||||
// Only run against root build. Do not run against included builds.
|
|
||||||
def isTopLevelBuild = gradle.getParent() == null
|
|
||||||
if (isTopLevelBuild) {
|
|
||||||
def version = GradleVersion.current().baseVersion
|
|
||||||
def atLeastGradle4 = version >= GradleVersion.version("4.0")
|
|
||||||
def atLeastGradle6 = version >= GradleVersion.version("6.0")
|
|
||||||
|
|
||||||
if (atLeastGradle6) {
|
|
||||||
settingsEvaluated { settings ->
|
|
||||||
if (settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
|
|
||||||
registerCallbacks(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject.name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (atLeastGradle4) {
|
|
||||||
projectsEvaluated { gradle ->
|
|
||||||
if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) {
|
|
||||||
registerCallbacks(gradle.rootProject.extensions["buildScan"], gradle.rootProject.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def registerCallbacks(buildScanExtension, rootProjectName) {
|
|
||||||
buildScanExtension.with {
|
|
||||||
def scanFile = new File("gradle-build-scan.txt")
|
|
||||||
def buildFailed = false
|
|
||||||
|
|
||||||
buildFinished { result ->
|
|
||||||
buildFailed = (result.failure != null)
|
|
||||||
}
|
|
||||||
|
|
||||||
buildScanPublished { buildScan ->
|
private readInitScriptAsString(resource: string): string {
|
||||||
scanFile.text = buildScan.buildScanUri
|
// Resolving relative to __dirname will allow node to find the resource at runtime
|
||||||
|
const absolutePath = path.resolve(__dirname, '..', '..', 'src', 'resources', 'init-scripts', resource)
|
||||||
// Send commands directly to GitHub Actions via STDOUT.
|
return fs.readFileSync(absolutePath, 'utf8')
|
||||||
def gradleCommand = rootProjectName + " " + gradle.startParameter.taskNames.join(" ")
|
|
||||||
if (buildFailed) {
|
|
||||||
println("::warning ::Gradle build '\${gradleCommand}' FAILED - \${buildScan.buildScanUri}")
|
|
||||||
} else {
|
|
||||||
println("::notice ::Gradle build '\${gradleCommand}' - \${buildScan.buildScanUri}")
|
|
||||||
}
|
|
||||||
println("::set-output name=build-scan-url::\${buildScan.buildScanUri}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
)
|
|
||||||
|
|
||||||
const projectRootCapture = path.resolve(initScriptsDir, 'project-root-capture.init.gradle')
|
|
||||||
fs.writeFileSync(
|
|
||||||
projectRootCapture,
|
|
||||||
`
|
|
||||||
// Only run against root build. Do not run against included builds.
|
|
||||||
def isTopLevelBuild = gradle.getParent() == null
|
|
||||||
if (isTopLevelBuild) {
|
|
||||||
settingsEvaluated { settings ->
|
|
||||||
def projectRootEntry = settings.rootDir.absolutePath + "\\n"
|
|
||||||
def projectRootList = new File(settings.gradle.gradleUserHomeDir, "${PROJECT_ROOTS_FILE}")
|
|
||||||
if (!projectRootList.exists() || !projectRootList.text.contains(projectRootEntry)) {
|
|
||||||
projectRootList << projectRootEntry
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
68
src/cache-cleaner.ts
Normal file
68
src/cache-cleaner.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import * as core from '@actions/core'
|
||||||
|
import * as exec from '@actions/exec'
|
||||||
|
import * as glob from '@actions/glob'
|
||||||
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
export class CacheCleaner {
|
||||||
|
private readonly gradleUserHome: string
|
||||||
|
private readonly tmpDir: string
|
||||||
|
|
||||||
|
constructor(gradleUserHome: string, tmpDir: string) {
|
||||||
|
this.gradleUserHome = gradleUserHome
|
||||||
|
this.tmpDir = tmpDir
|
||||||
|
}
|
||||||
|
|
||||||
|
async prepare(): Promise<void> {
|
||||||
|
// Reset the file-access journal so that files appear not to have been used recently
|
||||||
|
fs.rmSync(path.resolve(this.gradleUserHome, 'caches/journal-1'), {recursive: true, force: true})
|
||||||
|
fs.mkdirSync(path.resolve(this.gradleUserHome, 'caches/journal-1'), {recursive: true})
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(this.gradleUserHome, 'caches/journal-1/file-access.properties'),
|
||||||
|
'inceptionTimestamp=0'
|
||||||
|
)
|
||||||
|
|
||||||
|
// Set the modification time of all files to the past: this timestamp is used when there is no matching entry in the journal
|
||||||
|
await this.ageAllFiles()
|
||||||
|
|
||||||
|
// Touch all 'gc' files so that cache cleanup won't run immediately.
|
||||||
|
await this.touchAllFiles('gc.properties')
|
||||||
|
}
|
||||||
|
|
||||||
|
async forceCleanup(): Promise<void> {
|
||||||
|
// Age all 'gc' files so that cache cleanup will run immediately.
|
||||||
|
await this.ageAllFiles('gc.properties')
|
||||||
|
|
||||||
|
// Run a dummy Gradle build to trigger cache cleanup
|
||||||
|
const cleanupProjectDir = path.resolve(this.tmpDir, 'dummy-cleanup-project')
|
||||||
|
fs.mkdirSync(cleanupProjectDir, {recursive: true})
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(cleanupProjectDir, 'settings.gradle'),
|
||||||
|
'rootProject.name = "dummy-cleanup-project"'
|
||||||
|
)
|
||||||
|
fs.writeFileSync(path.resolve(cleanupProjectDir, 'build.gradle'), 'task("noop") {}')
|
||||||
|
|
||||||
|
await exec.exec(`gradle -g ${this.gradleUserHome} --no-daemon --build-cache --no-scan --quiet noop`, [], {
|
||||||
|
cwd: cleanupProjectDir
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private async ageAllFiles(fileName = '*'): Promise<void> {
|
||||||
|
core.debug(`Aging all files in Gradle User Homee with name ${fileName}`)
|
||||||
|
await this.setUtimes(`${this.gradleUserHome}/**/${fileName}`, new Date(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
private async touchAllFiles(fileName = '*'): Promise<void> {
|
||||||
|
core.debug(`Touching all files in Gradle User Home with name ${fileName}`)
|
||||||
|
await this.setUtimes(`${this.gradleUserHome}/**/${fileName}`, new Date())
|
||||||
|
}
|
||||||
|
|
||||||
|
private async setUtimes(pattern: string, timestamp: Date): Promise<void> {
|
||||||
|
const globber = await glob.create(pattern, {
|
||||||
|
implicitDescendants: false
|
||||||
|
})
|
||||||
|
for await (const file of globber.globGenerator()) {
|
||||||
|
fs.utimesSync(file, timestamp, timestamp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -3,7 +3,7 @@ import fs from 'fs'
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as glob from '@actions/glob'
|
import * as glob from '@actions/glob'
|
||||||
|
|
||||||
import {META_FILE_DIR, PROJECT_ROOTS_FILE} from './cache-base'
|
import {META_FILE_DIR} from './cache-base'
|
||||||
import {CacheEntryListener, CacheListener} from './cache-reporting'
|
import {CacheEntryListener, CacheListener} from './cache-reporting'
|
||||||
import {
|
import {
|
||||||
cacheDebug,
|
cacheDebug,
|
||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
saveCache,
|
saveCache,
|
||||||
tryDelete
|
tryDelete
|
||||||
} from './cache-utils'
|
} from './cache-utils'
|
||||||
|
import {loadBuildResults} from './build-results'
|
||||||
|
|
||||||
const SKIP_RESTORE_VAR = 'GRADLE_BUILD_ACTION_SKIP_RESTORE'
|
const SKIP_RESTORE_VAR = 'GRADLE_BUILD_ACTION_SKIP_RESTORE'
|
||||||
|
|
||||||
@@ -149,8 +150,7 @@ abstract class AbstractEntryExtractor {
|
|||||||
|
|
||||||
// Find all matching files for this cache entry definition
|
// Find all matching files for this cache entry definition
|
||||||
const globber = await glob.create(pattern, {
|
const globber = await glob.create(pattern, {
|
||||||
implicitDescendants: false,
|
implicitDescendants: false
|
||||||
followSymbolicLinks: false
|
|
||||||
})
|
})
|
||||||
const matchingFiles = await globber.glob()
|
const matchingFiles = await globber.glob()
|
||||||
|
|
||||||
@@ -212,6 +212,7 @@ abstract class AbstractEntryExtractor {
|
|||||||
|
|
||||||
if (previouslyRestoredKey === cacheKey) {
|
if (previouslyRestoredKey === cacheKey) {
|
||||||
cacheDebug(`No change to previously restored ${artifactType}. Not saving.`)
|
cacheDebug(`No change to previously restored ${artifactType}. Not saving.`)
|
||||||
|
entryListener.markNotSaved('contents unchanged')
|
||||||
} else {
|
} else {
|
||||||
core.info(`Caching ${artifactType} with path '${pattern}' and cache key: ${cacheKey}`)
|
core.info(`Caching ${artifactType} with path '${pattern}' and cache key: ${cacheKey}`)
|
||||||
await saveCache([pattern], cacheKey, entryListener)
|
await saveCache([pattern], cacheKey, entryListener)
|
||||||
@@ -306,13 +307,12 @@ export class GradleHomeEntryExtractor extends AbstractEntryExtractor {
|
|||||||
private async deleteWrapperZips(): Promise<void> {
|
private async deleteWrapperZips(): Promise<void> {
|
||||||
const wrapperZips = path.resolve(this.gradleUserHome, 'wrapper/dists/*/*/*.zip')
|
const wrapperZips = path.resolve(this.gradleUserHome, 'wrapper/dists/*/*/*.zip')
|
||||||
const globber = await glob.create(wrapperZips, {
|
const globber = await glob.create(wrapperZips, {
|
||||||
implicitDescendants: false,
|
implicitDescendants: false
|
||||||
followSymbolicLinks: false
|
|
||||||
})
|
})
|
||||||
|
|
||||||
for (const p of await globber.glob()) {
|
for (const wrapperZip of await globber.glob()) {
|
||||||
cacheDebug(`Deleting wrapper zip: ${p}`)
|
cacheDebug(`Deleting wrapper zip: ${wrapperZip}`)
|
||||||
tryDelete(p)
|
await tryDelete(wrapperZip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,13 +386,8 @@ export class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
|
|||||||
* set of project roots, to allow saving of configuration-cache entries for each.
|
* set of project roots, to allow saving of configuration-cache entries for each.
|
||||||
*/
|
*/
|
||||||
private getProjectRoots(): string[] {
|
private getProjectRoots(): string[] {
|
||||||
const projectList = path.resolve(this.gradleUserHome, PROJECT_ROOTS_FILE)
|
const buildResults = loadBuildResults()
|
||||||
if (!fs.existsSync(projectList)) {
|
const projectRootDirs = buildResults.map(x => x.rootProjectDir)
|
||||||
core.info(`Missing project list file ${projectList}`)
|
return [...new Set(projectRootDirs)] // Remove duplicates
|
||||||
return []
|
|
||||||
}
|
|
||||||
const projectRoots = fs.readFileSync(projectList, 'utf-8')
|
|
||||||
core.info(`Found project roots '${projectRoots}' in ${projectList}`)
|
|
||||||
return projectRoots.trim().split('\n')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import * as cache from '@actions/cache'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects information on what entries were saved and restored during the action.
|
* Collects information on what entries were saved and restored during the action.
|
||||||
@@ -6,11 +7,22 @@ import * as core from '@actions/core'
|
|||||||
*/
|
*/
|
||||||
export class CacheListener {
|
export class CacheListener {
|
||||||
cacheEntries: CacheEntryListener[] = []
|
cacheEntries: CacheEntryListener[] = []
|
||||||
|
cacheReadOnly = false
|
||||||
|
cacheWriteOnly = false
|
||||||
|
cacheDisabled = false
|
||||||
|
|
||||||
get fullyRestored(): boolean {
|
get fullyRestored(): boolean {
|
||||||
return this.cacheEntries.every(x => !x.wasRequestedButNotRestored())
|
return this.cacheEntries.every(x => !x.wasRequestedButNotRestored())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get cacheStatus(): string {
|
||||||
|
if (!cache.isFeatureAvailable()) return 'not available'
|
||||||
|
if (this.cacheDisabled) return 'disabled'
|
||||||
|
if (this.cacheWriteOnly) return 'write-only'
|
||||||
|
if (this.cacheReadOnly) return 'read-only'
|
||||||
|
return 'enabled'
|
||||||
|
}
|
||||||
|
|
||||||
entry(name: string): CacheEntryListener {
|
entry(name: string): CacheEntryListener {
|
||||||
for (const entry of this.cacheEntries) {
|
for (const entry of this.cacheEntries) {
|
||||||
if (entry.entryName === name) {
|
if (entry.entryName === name) {
|
||||||
@@ -50,9 +62,11 @@ export class CacheEntryListener {
|
|||||||
requestedRestoreKeys: string[] | undefined
|
requestedRestoreKeys: string[] | undefined
|
||||||
restoredKey: string | undefined
|
restoredKey: string | undefined
|
||||||
restoredSize: number | undefined
|
restoredSize: number | undefined
|
||||||
|
notRestored: string | undefined
|
||||||
|
|
||||||
savedKey: string | undefined
|
savedKey: string | undefined
|
||||||
savedSize: number | undefined
|
savedSize: number | undefined
|
||||||
|
notSaved: string | undefined
|
||||||
|
|
||||||
constructor(entryName: string) {
|
constructor(entryName: string) {
|
||||||
this.entryName = entryName
|
this.entryName = entryName
|
||||||
@@ -74,6 +88,11 @@ export class CacheEntryListener {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
markNotRestored(message: string): CacheEntryListener {
|
||||||
|
this.notRestored = message
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
markSaved(key: string, size: number | undefined): CacheEntryListener {
|
markSaved(key: string, size: number | undefined): CacheEntryListener {
|
||||||
this.savedKey = key
|
this.savedKey = key
|
||||||
this.savedSize = size
|
this.savedSize = size
|
||||||
@@ -85,54 +104,125 @@ export class CacheEntryListener {
|
|||||||
this.savedSize = 0
|
this.savedSize = 0
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
markNotSaved(message: string): CacheEntryListener {
|
||||||
|
this.notSaved = message
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function writeCachingReport(listener: CacheListener): void {
|
||||||
|
const entries = listener.cacheEntries
|
||||||
|
|
||||||
|
core.summary.addRaw(
|
||||||
|
`\n<details><summary><h4>Caching for gradle-build-action was ${listener.cacheStatus} - expand for details</h4></summary>\n`
|
||||||
|
)
|
||||||
|
|
||||||
|
core.summary.addTable([
|
||||||
|
[
|
||||||
|
{data: '', header: true},
|
||||||
|
{data: 'Count', header: true},
|
||||||
|
{data: 'Total Size (Mb)', header: true}
|
||||||
|
],
|
||||||
|
['Entries Restored', `${getCount(entries, e => e.restoredSize)}`, `${getSize(entries, e => e.restoredSize)}`],
|
||||||
|
['Entries Saved', `${getCount(entries, e => e.savedSize)}`, `${getSize(entries, e => e.savedSize)}`]
|
||||||
|
])
|
||||||
|
|
||||||
|
core.summary.addHeading('Cache Entry Details', 5)
|
||||||
|
|
||||||
|
const entryDetails = renderEntryDetails(listener)
|
||||||
|
core.summary.addRaw(`<pre>
|
||||||
|
${entryDetails}
|
||||||
|
</pre>
|
||||||
|
</details>
|
||||||
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logCachingReport(listener: CacheListener): void {
|
export function logCachingReport(listener: CacheListener): void {
|
||||||
if (listener.cacheEntries.length === 0) {
|
const entries = listener.cacheEntries
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
core.info(`---------- Caching Summary -------------
|
core.startGroup(`Caching for gradle-build-action was ${listener.cacheStatus} - expand for details`)
|
||||||
Restored Entries Count: ${getCount(listener.cacheEntries, e => e.restoredSize)}
|
|
||||||
Size: ${getSum(listener.cacheEntries, e => e.restoredSize)}
|
|
||||||
Saved Entries Count: ${getCount(listener.cacheEntries, e => e.savedSize)}
|
|
||||||
Size: ${getSum(listener.cacheEntries, e => e.savedSize)}`)
|
|
||||||
|
|
||||||
core.startGroup('Cache Entry details')
|
core.info(
|
||||||
for (const entry of listener.cacheEntries) {
|
`Entries Restored: ${getCount(entries, e => e.restoredSize)} (${getSize(entries, e => e.restoredSize)} Mb)`
|
||||||
core.info(`Entry: ${entry.entryName}
|
)
|
||||||
|
core.info(`Entries Saved : ${getCount(entries, e => e.savedSize)} (${getSize(entries, e => e.savedSize)} Mb)`)
|
||||||
|
|
||||||
|
core.info(`Cache Entry Details`)
|
||||||
|
core.info(renderEntryDetails(listener))
|
||||||
|
|
||||||
|
core.endGroup()
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderEntryDetails(listener: CacheListener): string {
|
||||||
|
return listener.cacheEntries
|
||||||
|
.map(
|
||||||
|
entry => `Entry: ${entry.entryName}
|
||||||
Requested Key : ${entry.requestedKey ?? ''}
|
Requested Key : ${entry.requestedKey ?? ''}
|
||||||
Restored Key : ${entry.restoredKey ?? ''}
|
Restored Key : ${entry.restoredKey ?? ''}
|
||||||
Size: ${formatSize(entry.restoredSize)}
|
Size: ${formatSize(entry.restoredSize)}
|
||||||
|
${getRestoredMessage(entry, listener.cacheWriteOnly)}
|
||||||
Saved Key : ${entry.savedKey ?? ''}
|
Saved Key : ${entry.savedKey ?? ''}
|
||||||
Size: ${formatSize(entry.savedSize)}`)
|
Size: ${formatSize(entry.savedSize)}
|
||||||
|
${getSavedMessage(entry, listener.cacheReadOnly)}
|
||||||
|
`
|
||||||
|
)
|
||||||
|
.join('---\n')
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRestoredMessage(entry: CacheEntryListener, cacheWriteOnly: boolean): string {
|
||||||
|
if (entry.notRestored) {
|
||||||
|
return `(Entry not restored: ${entry.notRestored})`
|
||||||
}
|
}
|
||||||
core.endGroup()
|
if (cacheWriteOnly) {
|
||||||
|
return '(Entry not restored: cache is write-only)'
|
||||||
|
}
|
||||||
|
if (entry.requestedKey === undefined) {
|
||||||
|
return '(Entry not restored: not requested)'
|
||||||
|
}
|
||||||
|
if (entry.restoredKey === undefined) {
|
||||||
|
return '(Entry not restored: no match found)'
|
||||||
|
}
|
||||||
|
if (entry.restoredKey === entry.requestedKey) {
|
||||||
|
return '(Entry restored: exact match found)'
|
||||||
|
}
|
||||||
|
return '(Entry restored: partial match found)'
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSavedMessage(entry: CacheEntryListener, cacheReadOnly: boolean): string {
|
||||||
|
if (entry.notSaved) {
|
||||||
|
return `(Entry not saved: ${entry.notSaved})`
|
||||||
|
}
|
||||||
|
if (entry.savedKey === undefined) {
|
||||||
|
if (cacheReadOnly) {
|
||||||
|
return '(Entry not saved: cache is read-only)'
|
||||||
|
}
|
||||||
|
return '(Entry not saved: reason unknown)'
|
||||||
|
}
|
||||||
|
if (entry.savedSize === 0) {
|
||||||
|
return '(Entry not saved: entry with key already exists)'
|
||||||
|
}
|
||||||
|
return '(Entry saved)'
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCount(
|
function getCount(
|
||||||
cacheEntries: CacheEntryListener[],
|
cacheEntries: CacheEntryListener[],
|
||||||
predicate: (value: CacheEntryListener) => number | undefined
|
predicate: (value: CacheEntryListener) => number | undefined
|
||||||
): number {
|
): number {
|
||||||
return cacheEntries.filter(e => predicate(e) !== undefined).length
|
return cacheEntries.filter(e => predicate(e)).length
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSum(
|
function getSize(
|
||||||
cacheEntries: CacheEntryListener[],
|
cacheEntries: CacheEntryListener[],
|
||||||
predicate: (value: CacheEntryListener) => number | undefined
|
predicate: (value: CacheEntryListener) => number | undefined
|
||||||
): string {
|
): number {
|
||||||
if (cacheEntries.length === 0) {
|
const bytes = cacheEntries.map(e => predicate(e) ?? 0).reduce((p, v) => p + v, 0)
|
||||||
return '0'
|
return Math.round(bytes / (1024 * 1024))
|
||||||
}
|
|
||||||
return formatSize(cacheEntries.map(e => predicate(e) ?? 0).reduce((p, v) => p + v, 0))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatSize(bytes: number | undefined): string {
|
function formatSize(bytes: number | undefined): string {
|
||||||
if (bytes === undefined) {
|
if (bytes === undefined || bytes === 0) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
if (bytes === 0) {
|
|
||||||
return '0 (Entry already exists)'
|
|
||||||
}
|
|
||||||
return `${Math.round(bytes / (1024 * 1024))} MB (${bytes} B)`
|
return `${Math.round(bytes / (1024 * 1024))} MB (${bytes} B)`
|
||||||
}
|
}
|
||||||
|
@@ -1,24 +1,42 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as cache from '@actions/cache'
|
import * as cache from '@actions/cache'
|
||||||
|
import * as github from '@actions/github'
|
||||||
|
import * as exec from '@actions/exec'
|
||||||
|
|
||||||
import * as crypto from 'crypto'
|
import * as crypto from 'crypto'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
|
||||||
import {CacheEntryListener} from './cache-reporting'
|
import {CacheEntryListener} from './cache-reporting'
|
||||||
|
|
||||||
|
const CACHE_PROTOCOL_VERSION = 'v6-'
|
||||||
|
|
||||||
const JOB_CONTEXT_PARAMETER = 'workflow-job-context'
|
const JOB_CONTEXT_PARAMETER = 'workflow-job-context'
|
||||||
const CACHE_DISABLED_PARAMETER = 'cache-disabled'
|
const CACHE_DISABLED_PARAMETER = 'cache-disabled'
|
||||||
const CACHE_READONLY_PARAMETER = 'cache-read-only'
|
const CACHE_READONLY_PARAMETER = 'cache-read-only'
|
||||||
const CACHE_WRITEONLY_PARAMETER = 'cache-write-only'
|
const CACHE_WRITEONLY_PARAMETER = 'cache-write-only'
|
||||||
|
const STRICT_CACHE_MATCH_PARAMETER = 'gradle-home-cache-strict-match'
|
||||||
|
const CACHE_CLEANUP_ENABLED_PARAMETER = 'gradle-home-cache-cleanup'
|
||||||
const CACHE_DEBUG_VAR = 'GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED'
|
const CACHE_DEBUG_VAR = 'GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED'
|
||||||
const CACHE_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX'
|
|
||||||
|
const CACHE_KEY_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX'
|
||||||
|
const CACHE_KEY_OS_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_ENVIRONMENT'
|
||||||
|
const CACHE_KEY_JOB_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB'
|
||||||
|
const CACHE_KEY_JOB_INSTANCE_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB_INSTANCE'
|
||||||
|
const CACHE_KEY_JOB_EXECUTION_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB_EXECUTION'
|
||||||
|
|
||||||
|
const SEGMENT_DOWNLOAD_TIMEOUT_VAR = 'SEGMENT_DOWNLOAD_TIMEOUT_MINS'
|
||||||
|
const SEGMENT_DOWNLOAD_TIMEOUT_DEFAULT = 10 * 60 * 1000 // 10 minutes
|
||||||
|
|
||||||
export function isCacheDisabled(): boolean {
|
export function isCacheDisabled(): boolean {
|
||||||
|
if (!cache.isFeatureAvailable()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
return core.getBooleanInput(CACHE_DISABLED_PARAMETER)
|
return core.getBooleanInput(CACHE_DISABLED_PARAMETER)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCacheReadOnly(): boolean {
|
export function isCacheReadOnly(): boolean {
|
||||||
return core.getBooleanInput(CACHE_READONLY_PARAMETER)
|
return !isCacheWriteOnly() && core.getBooleanInput(CACHE_READONLY_PARAMETER)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCacheWriteOnly(): boolean {
|
export function isCacheWriteOnly(): boolean {
|
||||||
@@ -29,18 +47,95 @@ export function isCacheDebuggingEnabled(): boolean {
|
|||||||
return process.env[CACHE_DEBUG_VAR] ? true : false
|
return process.env[CACHE_DEBUG_VAR] ? true : false
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCacheKeyPrefix(): string {
|
export function isCacheCleanupEnabled(): boolean {
|
||||||
// Prefix can be used to force change all cache keys (defaults to cache protocol version)
|
return core.getBooleanInput(CACHE_CLEANUP_ENABLED_PARAMETER)
|
||||||
return process.env[CACHE_PREFIX_VAR] || ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function determineJobContext(): string {
|
/**
|
||||||
|
* Represents a key used to restore a cache entry.
|
||||||
|
* The Github Actions cache will first try for an exact match on the key.
|
||||||
|
* If that fails, it will try for a prefix match on any of the restoreKeys.
|
||||||
|
*/
|
||||||
|
export class CacheKey {
|
||||||
|
key: string
|
||||||
|
restoreKeys: string[]
|
||||||
|
|
||||||
|
constructor(key: string, restoreKeys: string[]) {
|
||||||
|
this.key = key
|
||||||
|
this.restoreKeys = restoreKeys
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a cache key specific to the current job execution.
|
||||||
|
* The key is constructed from the following inputs (with some user overrides):
|
||||||
|
* - The cache protocol version
|
||||||
|
* - The name of the cache
|
||||||
|
* - The runner operating system
|
||||||
|
* - The name of the Job being executed
|
||||||
|
* - The matrix values for the Job being executed (job context)
|
||||||
|
* - The SHA of the commit being executed
|
||||||
|
*
|
||||||
|
* Caches are restored by trying to match the these key prefixes in order:
|
||||||
|
* - The full key with SHA
|
||||||
|
* - A previous key for this Job + matrix
|
||||||
|
* - Any previous key for this Job (any matrix)
|
||||||
|
* - Any previous key for this cache on the current OS
|
||||||
|
*/
|
||||||
|
export function generateCacheKey(cacheName: string): CacheKey {
|
||||||
|
const cacheKeyBase = `${getCacheKeyPrefix()}${CACHE_PROTOCOL_VERSION}${cacheName}`
|
||||||
|
|
||||||
|
// At the most general level, share caches for all executions on the same OS
|
||||||
|
const cacheKeyForEnvironment = `${cacheKeyBase}|${getCacheKeyEnvironment()}`
|
||||||
|
|
||||||
|
// Prefer caches that run this job
|
||||||
|
const cacheKeyForJob = `${cacheKeyForEnvironment}|${getCacheKeyJob()}`
|
||||||
|
|
||||||
|
// Prefer (even more) jobs that run this job with the same context (matrix)
|
||||||
|
const cacheKeyForJobContext = `${cacheKeyForJob}[${getCacheKeyJobInstance()}]`
|
||||||
|
|
||||||
|
// Exact match on Git SHA
|
||||||
|
const cacheKey = `${cacheKeyForJobContext}-${getCacheKeyJobExecution()}`
|
||||||
|
|
||||||
|
if (core.getBooleanInput(STRICT_CACHE_MATCH_PARAMETER)) {
|
||||||
|
return new CacheKey(cacheKey, [cacheKeyForJobContext])
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CacheKey(cacheKey, [cacheKeyForJobContext, cacheKeyForJob, cacheKeyForEnvironment])
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCacheKeyPrefix(): string {
|
||||||
|
// Prefix can be used to force change all cache keys (defaults to cache protocol version)
|
||||||
|
return process.env[CACHE_KEY_PREFIX_VAR] || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCacheKeyEnvironment(): string {
|
||||||
|
const runnerOs = process.env['RUNNER_OS'] || ''
|
||||||
|
return process.env[CACHE_KEY_OS_VAR] || runnerOs
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCacheKeyJob(): string {
|
||||||
|
// Prefix can be used to force change all cache keys (defaults to cache protocol version)
|
||||||
|
return process.env[CACHE_KEY_JOB_VAR] || github.context.job
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCacheKeyJobInstance(): string {
|
||||||
|
const override = process.env[CACHE_KEY_JOB_INSTANCE_VAR]
|
||||||
|
if (override) {
|
||||||
|
return override
|
||||||
|
}
|
||||||
|
|
||||||
// By default, we hash the full `matrix` data for the run, to uniquely identify this job invocation
|
// By default, we hash the full `matrix` data for the run, to uniquely identify this job invocation
|
||||||
// The only way we can obtain the `matrix` data is via the `workflow-job-context` parameter in action.yml.
|
// The only way we can obtain the `matrix` data is via the `workflow-job-context` parameter in action.yml.
|
||||||
const workflowJobContext = core.getInput(JOB_CONTEXT_PARAMETER)
|
const workflowJobContext = core.getInput(JOB_CONTEXT_PARAMETER)
|
||||||
return hashStrings([workflowJobContext])
|
return hashStrings([workflowJobContext])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCacheKeyJobExecution(): string {
|
||||||
|
// Used to associate a cache key with a particular execution (default is bound to the git commit sha)
|
||||||
|
return process.env[CACHE_KEY_JOB_EXECUTION_VAR] || github.context.sha
|
||||||
|
}
|
||||||
|
|
||||||
export function hashFileNames(fileNames: string[]): string {
|
export function hashFileNames(fileNames: string[]): string {
|
||||||
return hashStrings(fileNames.map(x => x.replace(new RegExp(`\\${path.sep}`, 'g'), '/')))
|
return hashStrings(fileNames.map(x => x.replace(new RegExp(`\\${path.sep}`, 'g'), '/')))
|
||||||
}
|
}
|
||||||
@@ -61,12 +156,17 @@ export async function restoreCache(
|
|||||||
): Promise<cache.CacheEntry | undefined> {
|
): Promise<cache.CacheEntry | undefined> {
|
||||||
listener.markRequested(cacheKey, cacheRestoreKeys)
|
listener.markRequested(cacheKey, cacheRestoreKeys)
|
||||||
try {
|
try {
|
||||||
const restoredEntry = await cache.restoreCache(cachePath, cacheKey, cacheRestoreKeys)
|
// Only override the read timeout if the SEGMENT_DOWNLOAD_TIMEOUT_MINS env var has NOT been set
|
||||||
|
const cacheRestoreOptions = process.env[SEGMENT_DOWNLOAD_TIMEOUT_VAR]
|
||||||
|
? {}
|
||||||
|
: {segmentTimeoutInMs: SEGMENT_DOWNLOAD_TIMEOUT_DEFAULT}
|
||||||
|
const restoredEntry = await cache.restoreCache(cachePath, cacheKey, cacheRestoreKeys, cacheRestoreOptions)
|
||||||
if (restoredEntry !== undefined) {
|
if (restoredEntry !== undefined) {
|
||||||
listener.markRestored(restoredEntry.key, restoredEntry.size)
|
listener.markRestored(restoredEntry.key, restoredEntry.size)
|
||||||
}
|
}
|
||||||
return restoredEntry
|
return restoredEntry
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
listener.markNotRestored((error as Error).message)
|
||||||
handleCacheFailure(error, `Failed to restore ${cacheKey}`)
|
handleCacheFailure(error, `Failed to restore ${cacheKey}`)
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
@@ -79,8 +179,10 @@ export async function saveCache(cachePath: string[], cacheKey: string, listener:
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof cache.ReserveCacheError) {
|
if (error instanceof cache.ReserveCacheError) {
|
||||||
listener.markAlreadyExists(cacheKey)
|
listener.markAlreadyExists(cacheKey)
|
||||||
|
} else {
|
||||||
|
listener.markNotSaved((error as Error).message)
|
||||||
}
|
}
|
||||||
handleCacheFailure(error, `Failed to save cache entry ${cacheKey}`)
|
handleCacheFailure(error, `Failed to save cache entry with path '${cachePath}' and key: ${cacheKey}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,9 +215,13 @@ export function handleCacheFailure(error: unknown, message: string): void {
|
|||||||
* Attempt to delete a file or directory, waiting to allow locks to be released
|
* Attempt to delete a file or directory, waiting to allow locks to be released
|
||||||
*/
|
*/
|
||||||
export async function tryDelete(file: string): Promise<void> {
|
export async function tryDelete(file: string): Promise<void> {
|
||||||
const stat = fs.lstatSync(file)
|
const maxAttempts = 5
|
||||||
for (let count = 0; count < 3; count++) {
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
||||||
|
if (!fs.existsSync(file)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
|
const stat = fs.lstatSync(file)
|
||||||
if (stat.isDirectory()) {
|
if (stat.isDirectory()) {
|
||||||
fs.rmdirSync(file, {recursive: true})
|
fs.rmdirSync(file, {recursive: true})
|
||||||
} else {
|
} else {
|
||||||
@@ -123,10 +229,13 @@ export async function tryDelete(file: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (count === 2) {
|
if (attempt === maxAttempts) {
|
||||||
|
core.warning(`Failed to delete ${file}, which will impact caching.
|
||||||
|
It is likely locked by another process. Output of 'jps -ml':
|
||||||
|
${await getJavaProcesses()}`)
|
||||||
throw error
|
throw error
|
||||||
} else {
|
} else {
|
||||||
core.warning(String(error))
|
cacheDebug(`Attempt to delete ${file} failed. Will try again.`)
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,3 +245,8 @@ export async function tryDelete(file: string): Promise<void> {
|
|||||||
async function delay(ms: number): Promise<void> {
|
async function delay(ms: number): Promise<void> {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms))
|
return new Promise(resolve => setTimeout(resolve, ms))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getJavaProcesses(): Promise<string> {
|
||||||
|
const jpsOutput = await exec.getExecOutput('jps', ['-lm'])
|
||||||
|
return jpsOutput.stdout
|
||||||
|
}
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {isCacheDisabled, isCacheReadOnly, isCacheWriteOnly} from './cache-utils'
|
import {isCacheCleanupEnabled, isCacheDisabled, isCacheReadOnly, isCacheWriteOnly} from './cache-utils'
|
||||||
import {logCachingReport, CacheListener} from './cache-reporting'
|
import {CacheListener} from './cache-reporting'
|
||||||
|
import {DaemonController} from './daemon-controller'
|
||||||
import {GradleStateCache} from './cache-base'
|
import {GradleStateCache} from './cache-base'
|
||||||
|
import {CacheCleaner} from './cache-cleaner'
|
||||||
|
|
||||||
const CACHE_RESTORED_VAR = 'GRADLE_BUILD_ACTION_CACHE_RESTORED'
|
const CACHE_RESTORED_VAR = 'GRADLE_BUILD_ACTION_CACHE_RESTORED'
|
||||||
const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
|
|
||||||
const CACHE_LISTENER = 'CACHE_LISTENER'
|
|
||||||
|
|
||||||
export async function restore(gradleUserHome: string): Promise<void> {
|
export async function restore(gradleUserHome: string, cacheListener: CacheListener): Promise<void> {
|
||||||
// Bypass restore cache on all but first action step in workflow.
|
// Bypass restore cache on all but first action step in workflow.
|
||||||
if (process.env[CACHE_RESTORED_VAR]) {
|
if (process.env[CACHE_RESTORED_VAR]) {
|
||||||
core.info('Cache only restored on first action step.')
|
core.info('Cache only restored on first action step.')
|
||||||
@@ -21,6 +21,7 @@ export async function restore(gradleUserHome: string): Promise<void> {
|
|||||||
core.info('Cache is disabled: will not restore state from previous builds.')
|
core.info('Cache is disabled: will not restore state from previous builds.')
|
||||||
// Initialize the Gradle User Home even when caching is disabled.
|
// Initialize the Gradle User Home even when caching is disabled.
|
||||||
gradleStateCache.init()
|
gradleStateCache.init()
|
||||||
|
cacheListener.cacheDisabled = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,53 +35,54 @@ export async function restore(gradleUserHome: string): Promise<void> {
|
|||||||
gradleStateCache.init()
|
gradleStateCache.init()
|
||||||
// Mark the state as restored so that post-action will perform save.
|
// Mark the state as restored so that post-action will perform save.
|
||||||
core.saveState(CACHE_RESTORED_VAR, true)
|
core.saveState(CACHE_RESTORED_VAR, true)
|
||||||
// Save the Gradle User Home for the post-action step.
|
|
||||||
core.saveState(GRADLE_USER_HOME, gradleUserHome)
|
|
||||||
|
|
||||||
if (isCacheWriteOnly()) {
|
if (isCacheWriteOnly()) {
|
||||||
core.info('Cache is write-only: will not restore from cache.')
|
core.info('Cache is write-only: will not restore from cache.')
|
||||||
|
cacheListener.cacheWriteOnly = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await core.group('Restore Gradle state from cache', async () => {
|
await core.group('Restore Gradle state from cache', async () => {
|
||||||
const cacheListener = new CacheListener()
|
|
||||||
await gradleStateCache.restore(cacheListener)
|
await gradleStateCache.restore(cacheListener)
|
||||||
|
|
||||||
core.saveState(CACHE_LISTENER, cacheListener.stringify())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function save(): Promise<void> {
|
|
||||||
if (!shouldSaveCaches()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const cacheListener: CacheListener = CacheListener.rehydrate(core.getState(CACHE_LISTENER))
|
|
||||||
|
|
||||||
if (isCacheReadOnly()) {
|
|
||||||
core.info('Cache is read-only: will not save state for use in subsequent builds.')
|
|
||||||
logCachingReport(cacheListener)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await core.group('Caching Gradle state', async () => {
|
|
||||||
const gradleUserHome = core.getState(GRADLE_USER_HOME)
|
|
||||||
return new GradleStateCache(gradleUserHome).save(cacheListener)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
logCachingReport(cacheListener)
|
if (isCacheCleanupEnabled() && !isCacheReadOnly()) {
|
||||||
|
core.info('Preparing cache for cleanup.')
|
||||||
|
const cacheCleaner = new CacheCleaner(gradleUserHome, process.env['RUNNER_TEMP']!)
|
||||||
|
await cacheCleaner.prepare()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldSaveCaches(): boolean {
|
export async function save(
|
||||||
|
gradleUserHome: string,
|
||||||
|
cacheListener: CacheListener,
|
||||||
|
daemonController: DaemonController
|
||||||
|
): Promise<void> {
|
||||||
if (isCacheDisabled()) {
|
if (isCacheDisabled()) {
|
||||||
core.info('Cache is disabled: will not save state for later builds.')
|
core.info('Cache is disabled: will not save state for later builds.')
|
||||||
return false
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!core.getState(CACHE_RESTORED_VAR)) {
|
if (!core.getState(CACHE_RESTORED_VAR)) {
|
||||||
core.info('Cache will not be saved: not restored in main action step.')
|
core.info('Cache will not be saved: not restored in main action step.')
|
||||||
return false
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
if (isCacheReadOnly()) {
|
||||||
|
core.info('Cache is read-only: will not save state for use in subsequent builds.')
|
||||||
|
cacheListener.cacheReadOnly = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await daemonController.stopAllDaemons()
|
||||||
|
|
||||||
|
if (isCacheCleanupEnabled()) {
|
||||||
|
core.info('Forcing cache cleanup.')
|
||||||
|
const cacheCleaner = new CacheCleaner(gradleUserHome, process.env['RUNNER_TEMP']!)
|
||||||
|
await cacheCleaner.forceCleanup()
|
||||||
|
}
|
||||||
|
|
||||||
|
await core.group('Caching Gradle state', async () => {
|
||||||
|
return new GradleStateCache(gradleUserHome).save(cacheListener)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
36
src/daemon-controller.ts
Normal file
36
src/daemon-controller.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import * as core from '@actions/core'
|
||||||
|
import * as exec from '@actions/exec'
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import * as path from 'path'
|
||||||
|
import {BuildResult} from './build-results'
|
||||||
|
|
||||||
|
export class DaemonController {
|
||||||
|
private readonly gradleHomes
|
||||||
|
|
||||||
|
constructor(buildResults: BuildResult[]) {
|
||||||
|
const allHomes = buildResults.map(buildResult => buildResult.gradleHomeDir)
|
||||||
|
this.gradleHomes = Array.from(new Set(allHomes))
|
||||||
|
}
|
||||||
|
|
||||||
|
async stopAllDaemons(): Promise<void> {
|
||||||
|
core.info('Stopping all Gradle daemons before saving Gradle User Home state')
|
||||||
|
|
||||||
|
const executions: Promise<number>[] = []
|
||||||
|
const args = ['--stop']
|
||||||
|
|
||||||
|
for (const gradleHome of this.gradleHomes) {
|
||||||
|
const executable = path.resolve(gradleHome, 'bin', 'gradle')
|
||||||
|
if (!fs.existsSync(executable)) {
|
||||||
|
core.warning(`Gradle executable not found at ${executable}. Could not stop Gradle daemons.`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
core.info(`Stopping Gradle daemons for ${gradleHome}`)
|
||||||
|
executions.push(
|
||||||
|
exec.exec(executable, args, {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
await Promise.all(executions)
|
||||||
|
}
|
||||||
|
}
|
@@ -1,17 +1,9 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as exec from '@actions/exec'
|
import * as exec from '@actions/exec'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
|
||||||
import * as gradlew from './gradlew'
|
import * as gradlew from './gradlew'
|
||||||
|
|
||||||
export async function executeGradleBuild(executable: string | undefined, root: string, args: string[]): Promise<void> {
|
export async function executeGradleBuild(executable: string | undefined, root: string, args: string[]): Promise<void> {
|
||||||
let buildScanUrl: string | undefined
|
|
||||||
|
|
||||||
const buildScanFile = path.resolve(root, 'gradle-build-scan.txt')
|
|
||||||
if (fs.existsSync(buildScanFile)) {
|
|
||||||
fs.unlinkSync(buildScanFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use the provided executable, or look for a Gradle wrapper script to run
|
// Use the provided executable, or look for a Gradle wrapper script to run
|
||||||
const toExecute = executable ?? gradlew.locateGradleWrapperScript(root)
|
const toExecute = executable ?? gradlew.locateGradleWrapperScript(root)
|
||||||
verifyIsExecutableScript(toExecute)
|
verifyIsExecutableScript(toExecute)
|
||||||
@@ -20,16 +12,8 @@ export async function executeGradleBuild(executable: string | undefined, root: s
|
|||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
})
|
})
|
||||||
|
|
||||||
if (fs.existsSync(buildScanFile)) {
|
|
||||||
buildScanUrl = fs.readFileSync(buildScanFile, 'utf-8')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status !== 0) {
|
if (status !== 0) {
|
||||||
if (buildScanUrl) {
|
core.setFailed(`Gradle build failed: see console output for details`)
|
||||||
core.setFailed(`Gradle build failed: ${buildScanUrl}`)
|
|
||||||
} else {
|
|
||||||
core.setFailed(`Gradle build failed: process exited with status ${status}`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
94
src/job-summary.ts
Normal file
94
src/job-summary.ts
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
import * as core from '@actions/core'
|
||||||
|
import {BuildResult} from './build-results'
|
||||||
|
import {writeCachingReport, CacheListener, logCachingReport} from './cache-reporting'
|
||||||
|
|
||||||
|
export async function writeJobSummary(buildResults: BuildResult[], cacheListener: CacheListener): Promise<void> {
|
||||||
|
core.info('Writing job summary')
|
||||||
|
|
||||||
|
if (buildResults.length === 0) {
|
||||||
|
core.debug('No Gradle build results found. Summary table will not be generated.')
|
||||||
|
} else {
|
||||||
|
writeSummaryTable(buildResults)
|
||||||
|
}
|
||||||
|
|
||||||
|
writeCachingReport(cacheListener)
|
||||||
|
|
||||||
|
await core.summary.write()
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function logJobSummary(buildResults: BuildResult[], cacheListener: CacheListener): Promise<void> {
|
||||||
|
if (buildResults.length === 0) {
|
||||||
|
core.debug('No Gradle build results found. Summary table will not be logged.')
|
||||||
|
} else {
|
||||||
|
logSummaryTable(buildResults)
|
||||||
|
}
|
||||||
|
|
||||||
|
logCachingReport(cacheListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeSummaryTable(results: BuildResult[]): void {
|
||||||
|
core.summary.addHeading('Gradle Builds', 3)
|
||||||
|
|
||||||
|
core.summary.addRaw(`
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Root Project</th>
|
||||||
|
<th>Requested Tasks</th>
|
||||||
|
<th>Gradle Version</th>
|
||||||
|
<th>Build Outcome</th>
|
||||||
|
<th>Build Scan™</th>
|
||||||
|
</tr>${results.map(result => renderBuildResultRow(result)).join('')}
|
||||||
|
</table>
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderBuildResultRow(result: BuildResult): string {
|
||||||
|
return `
|
||||||
|
<tr>
|
||||||
|
<td>${result.rootProjectName}</td>
|
||||||
|
<td>${result.requestedTasks}</td>
|
||||||
|
<td align='center'>${result.gradleVersion}</td>
|
||||||
|
<td align='center'>${renderOutcome(result)}</td>
|
||||||
|
<td>${renderBuildScan(result)}</td>
|
||||||
|
</tr>`
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderOutcome(result: BuildResult): string {
|
||||||
|
return result.buildFailed ? ':x:' : ':white_check_mark:'
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderBuildScan(result: BuildResult): string {
|
||||||
|
if (result.buildScanFailed) {
|
||||||
|
return renderBuildScanBadge(
|
||||||
|
'PUBLISH_FAILED',
|
||||||
|
'orange',
|
||||||
|
'https://docs.gradle.com/enterprise/gradle-plugin/#troubleshooting'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (result.buildScanUri) {
|
||||||
|
return renderBuildScanBadge('PUBLISHED', '06A0CE', result.buildScanUri)
|
||||||
|
}
|
||||||
|
return renderBuildScanBadge('NOT_PUBLISHED', 'lightgrey', 'https://scans.gradle.com')
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderBuildScanBadge(outcomeText: string, outcomeColor: string, targetUrl: string): string {
|
||||||
|
const badgeUrl = `https://img.shields.io/badge/Build%20Scan%E2%84%A2-${outcomeText}-${outcomeColor}?logo=Gradle`
|
||||||
|
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`
|
||||||
|
return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`
|
||||||
|
}
|
||||||
|
|
||||||
|
function logSummaryTable(results: BuildResult[]): void {
|
||||||
|
core.info('============================')
|
||||||
|
core.info('Gradle Builds')
|
||||||
|
core.info('----------------------------')
|
||||||
|
core.info('Root Project | Requested Tasks | Gradle Version | Build Outcome | Build Scan™')
|
||||||
|
core.info('----------------------------')
|
||||||
|
for (const result of results) {
|
||||||
|
core.info(
|
||||||
|
`${result.rootProjectName} | ${result.requestedTasks} | ${result.gradleVersion} | ${
|
||||||
|
result.buildFailed ? 'FAILED' : 'SUCCESS'
|
||||||
|
} | ${result.buildScanFailed ? 'Publish failed' : result.buildScanUri}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
core.info('============================')
|
||||||
|
}
|
15
src/main.ts
15
src/main.ts
@@ -1,9 +1,8 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as os from 'os'
|
|
||||||
import {parseArgsStringToArgv} from 'string-argv'
|
import {parseArgsStringToArgv} from 'string-argv'
|
||||||
|
|
||||||
import * as caches from './caches'
|
import * as setupGradle from './setup-gradle'
|
||||||
import * as execution from './execution'
|
import * as execution from './execution'
|
||||||
import * as provision from './provision'
|
import * as provision from './provision'
|
||||||
|
|
||||||
@@ -14,9 +13,8 @@ export async function run(): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
const workspaceDirectory = process.env[`GITHUB_WORKSPACE`] || ''
|
const workspaceDirectory = process.env[`GITHUB_WORKSPACE`] || ''
|
||||||
const buildRootDirectory = resolveBuildRootDirectory(workspaceDirectory)
|
const buildRootDirectory = resolveBuildRootDirectory(workspaceDirectory)
|
||||||
const gradleUserHome = determineGradleUserHome(buildRootDirectory)
|
|
||||||
|
|
||||||
await caches.restore(gradleUserHome)
|
await setupGradle.setup(buildRootDirectory)
|
||||||
|
|
||||||
const executable = await provisionGradle(workspaceDirectory)
|
const executable = await provisionGradle(workspaceDirectory)
|
||||||
// executable will be undefined if using Gradle wrapper
|
// executable will be undefined if using Gradle wrapper
|
||||||
@@ -60,15 +58,6 @@ function resolveBuildRootDirectory(baseDirectory: string): string {
|
|||||||
return resolvedBuildRootDirectory
|
return resolvedBuildRootDirectory
|
||||||
}
|
}
|
||||||
|
|
||||||
function determineGradleUserHome(rootDir: string): string {
|
|
||||||
const customGradleUserHome = process.env['GRADLE_USER_HOME']
|
|
||||||
if (customGradleUserHome) {
|
|
||||||
return path.resolve(rootDir, customGradleUserHome)
|
|
||||||
}
|
|
||||||
|
|
||||||
return path.resolve(os.homedir(), '.gradle')
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseCommandLineArguments(): string[] {
|
function parseCommandLineArguments(): string[] {
|
||||||
const input = core.getInput('arguments')
|
const input = core.getInput('arguments')
|
||||||
return parseArgsStringToArgv(input)
|
return parseArgsStringToArgv(input)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as caches from './caches'
|
import * as setupGradle from './setup-gradle'
|
||||||
|
|
||||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||||
@@ -11,14 +11,14 @@ process.on('uncaughtException', e => handleFailure(e))
|
|||||||
*/
|
*/
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await caches.save()
|
await setupGradle.complete()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleFailure(error)
|
handleFailure(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFailure(error: unknown): void {
|
function handleFailure(error: unknown): void {
|
||||||
core.warning(`Unhandled error saving cache - job will continue: ${error}`)
|
core.warning(`Unhandled error in Gradle post-action - job will continue: ${error}`)
|
||||||
if (error instanceof Error && error.stack) {
|
if (error instanceof Error && error.stack) {
|
||||||
core.info(error.stack)
|
core.info(error.stack)
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,59 @@
|
|||||||
|
import org.gradle.tooling.events.*
|
||||||
|
import org.gradle.tooling.events.task.*
|
||||||
|
import org.gradle.util.GradleVersion
|
||||||
|
|
||||||
|
// Can't use settingsEvaluated since this script is applied inside a settingsEvaluated handler
|
||||||
|
// But projectsEvaluated is good enough, since the build service won't catch configuration failures anyway
|
||||||
|
projectsEvaluated {
|
||||||
|
def projectTracker = gradle.sharedServices.registerIfAbsent("gradle-build-action-buildResultsRecorder", BuildResultsRecorder, { spec ->
|
||||||
|
spec.getParameters().getRootProjectName().set(gradle.rootProject.name)
|
||||||
|
spec.getParameters().getRootProjectDir().set(gradle.rootProject.rootDir.absolutePath)
|
||||||
|
spec.getParameters().getRequestedTasks().set(gradle.startParameter.taskNames.join(" "))
|
||||||
|
spec.getParameters().getGradleHomeDir().set(gradle.gradleHomeDir.absolutePath)
|
||||||
|
spec.getParameters().getInvocationId().set(gradle.ext.invocationId)
|
||||||
|
})
|
||||||
|
|
||||||
|
gradle.services.get(BuildEventsListenerRegistry).onTaskCompletion(projectTracker)
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class BuildResultsRecorder implements BuildService<BuildResultsRecorder.Params>, OperationCompletionListener, AutoCloseable {
|
||||||
|
private boolean buildFailed = false
|
||||||
|
interface Params extends BuildServiceParameters {
|
||||||
|
Property<String> getRootProjectName()
|
||||||
|
Property<String> getRootProjectDir()
|
||||||
|
Property<String> getRequestedTasks()
|
||||||
|
Property<String> getGradleHomeDir()
|
||||||
|
Property<String> getInvocationId()
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFinish(FinishEvent finishEvent) {
|
||||||
|
if (finishEvent instanceof TaskFinishEvent && finishEvent.result instanceof TaskFailureResult) {
|
||||||
|
buildFailed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
def buildResults = [
|
||||||
|
rootProjectName: getParameters().getRootProjectName().get(),
|
||||||
|
rootProjectDir: getParameters().getRootProjectDir().get(),
|
||||||
|
requestedTasks: getParameters().getRequestedTasks().get(),
|
||||||
|
gradleVersion: GradleVersion.current().version,
|
||||||
|
gradleHomeDir: getParameters().getGradleHomeDir().get(),
|
||||||
|
buildFailed: buildFailed,
|
||||||
|
buildScanUri: null,
|
||||||
|
buildScanFailed: false
|
||||||
|
]
|
||||||
|
|
||||||
|
def runnerTempDir = System.getenv("RUNNER_TEMP")
|
||||||
|
def githubActionStep = System.getenv("GITHUB_ACTION")
|
||||||
|
if (!runnerTempDir || !githubActionStep) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
def buildResultsDir = new File(runnerTempDir, ".build-results")
|
||||||
|
buildResultsDir.mkdirs()
|
||||||
|
def buildResultsFile = new File(buildResultsDir, githubActionStep + getParameters().getInvocationId().get() + ".json")
|
||||||
|
buildResultsFile << groovy.json.JsonOutput.toJson(buildResults)
|
||||||
|
}
|
||||||
|
}
|
129
src/resources/init-scripts/build-result-capture.init.gradle
Normal file
129
src/resources/init-scripts/build-result-capture.init.gradle
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* Capture information for each executed Gradle build to display in the job summary.
|
||||||
|
*/
|
||||||
|
import org.gradle.util.GradleVersion
|
||||||
|
|
||||||
|
// Only run against root build. Do not run against included builds.
|
||||||
|
def isTopLevelBuild = gradle.getParent() == null
|
||||||
|
if (isTopLevelBuild) {
|
||||||
|
def version = GradleVersion.current().baseVersion
|
||||||
|
|
||||||
|
def atLeastGradle3 = version >= GradleVersion.version("3.0")
|
||||||
|
def atLeastGradle6 = version >= GradleVersion.version("6.0")
|
||||||
|
|
||||||
|
def invocationId = "-${System.currentTimeMillis()}"
|
||||||
|
|
||||||
|
if (atLeastGradle6) {
|
||||||
|
def useBuildService = version >= GradleVersion.version("6.6")
|
||||||
|
settingsEvaluated { settings ->
|
||||||
|
// The `buildScanPublished` hook is the only way to capture the build scan URI.
|
||||||
|
if (settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
|
||||||
|
captureUsingBuildScanPublished(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject, invocationId)
|
||||||
|
}
|
||||||
|
// We also need to add hooks in case the plugin is applied but no build scan is published
|
||||||
|
if (useBuildService) {
|
||||||
|
captureUsingBuildService(settings, invocationId)
|
||||||
|
} else {
|
||||||
|
captureUsingBuildFinished(gradle, invocationId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (atLeastGradle3) {
|
||||||
|
projectsEvaluated { gradle ->
|
||||||
|
if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) {
|
||||||
|
captureUsingBuildScanPublished(gradle.rootProject.extensions["buildScan"], gradle.rootProject, invocationId)
|
||||||
|
}
|
||||||
|
// Always attempt to capture in buildFinished in case the plugin is applied but no build scan is published
|
||||||
|
// The `buildScanPublished` results will NOT be overwritten by this call
|
||||||
|
captureUsingBuildFinished(gradle, invocationId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def captureUsingBuildScanPublished(buildScanExtension, rootProject, invocationId) {
|
||||||
|
buildScanExtension.with {
|
||||||
|
def buildResults = new BuildResults(invocationId, gradle, rootProject)
|
||||||
|
|
||||||
|
buildFinished { result ->
|
||||||
|
buildResults.setBuildResult(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
buildScanPublished { buildScan ->
|
||||||
|
buildResults.setBuildScanUri(buildScan.buildScanUri.toASCIIString())
|
||||||
|
buildResults.writeToResultsFile(true)
|
||||||
|
|
||||||
|
println("::set-output name=build-scan-url::${buildScan.buildScanUri}")
|
||||||
|
}
|
||||||
|
|
||||||
|
onError { error ->
|
||||||
|
buildResults.setBuildScanFailed()
|
||||||
|
buildResults.writeToResultsFile(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def captureUsingBuildFinished(gradle, invocationId) {
|
||||||
|
gradle.buildFinished { result ->
|
||||||
|
def buildResults = new BuildResults(invocationId, gradle, gradle.rootProject)
|
||||||
|
buildResults.setBuildResult(result)
|
||||||
|
|
||||||
|
buildResults.writeToResultsFile(false)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def captureUsingBuildService(settings, invocationId) {
|
||||||
|
gradle.ext.invocationId = invocationId
|
||||||
|
apply from: 'build-result-capture-service.plugin.groovy'
|
||||||
|
}
|
||||||
|
|
||||||
|
class BuildResults {
|
||||||
|
def invocationId
|
||||||
|
def buildResults
|
||||||
|
|
||||||
|
BuildResults(String invocationId, def gradle, def rootProject) {
|
||||||
|
this.invocationId = invocationId
|
||||||
|
buildResults = [
|
||||||
|
rootProjectName: rootProject.name,
|
||||||
|
rootProjectDir: rootProject.projectDir.absolutePath,
|
||||||
|
requestedTasks: gradle.startParameter.taskNames.join(" "),
|
||||||
|
gradleVersion: GradleVersion.current().version,
|
||||||
|
gradleHomeDir: gradle.gradleHomeDir.absolutePath,
|
||||||
|
buildFailed: false,
|
||||||
|
buildScanUri: null,
|
||||||
|
buildScanFailed: false
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
def setBuildResult(def result) {
|
||||||
|
buildResults['buildFailed'] = result.failure != null
|
||||||
|
}
|
||||||
|
|
||||||
|
def setBuildScanUri(def buildScanUrl) {
|
||||||
|
buildResults['buildScanUri'] = buildScanUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
def setBuildScanFailed() {
|
||||||
|
buildResults['buildScanFailed'] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
def writeToResultsFile(boolean overwrite) {
|
||||||
|
def runnerTempDir = System.getenv("RUNNER_TEMP")
|
||||||
|
def githubActionStep = System.getenv("GITHUB_ACTION")
|
||||||
|
if (!runnerTempDir || !githubActionStep) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
def buildResultsDir = new File(runnerTempDir, ".build-results")
|
||||||
|
buildResultsDir.mkdirs()
|
||||||
|
def buildResultsFile = new File(buildResultsDir, githubActionStep + invocationId + ".json")
|
||||||
|
|
||||||
|
// Overwrite any contents written by buildFinished or build service, since this result is a superset.
|
||||||
|
if (buildResultsFile.exists()) {
|
||||||
|
if (overwrite) {
|
||||||
|
buildResultsFile.text = groovy.json.JsonOutput.toJson(buildResults)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
buildResultsFile << groovy.json.JsonOutput.toJson(buildResults)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
95
src/setup-gradle.ts
Normal file
95
src/setup-gradle.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import * as core from '@actions/core'
|
||||||
|
import * as exec from '@actions/exec'
|
||||||
|
import {SUMMARY_ENV_VAR} from '@actions/core/lib/summary'
|
||||||
|
import * as path from 'path'
|
||||||
|
import * as os from 'os'
|
||||||
|
import * as caches from './caches'
|
||||||
|
|
||||||
|
import {logJobSummary, writeJobSummary} from './job-summary'
|
||||||
|
import {loadBuildResults} from './build-results'
|
||||||
|
import {CacheListener} from './cache-reporting'
|
||||||
|
import {DaemonController} from './daemon-controller'
|
||||||
|
|
||||||
|
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED'
|
||||||
|
const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
|
||||||
|
const CACHE_LISTENER = 'CACHE_LISTENER'
|
||||||
|
const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary'
|
||||||
|
|
||||||
|
function shouldGenerateJobSummary(): boolean {
|
||||||
|
// Check if Job Summary is supported on this platform
|
||||||
|
if (!process.env[SUMMARY_ENV_VAR]) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return core.getBooleanInput(JOB_SUMMARY_ENABLED_PARAMETER)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function setup(buildRootDirectory: string): Promise<void> {
|
||||||
|
const gradleUserHome = await determineGradleUserHome(buildRootDirectory)
|
||||||
|
|
||||||
|
// Bypass setup on all but first action step in workflow.
|
||||||
|
if (process.env[GRADLE_SETUP_VAR]) {
|
||||||
|
core.info('Gradle setup only performed on first gradle-build-action step in workflow.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Record setup complete: visible to all subsequent actions and prevents duplicate setup
|
||||||
|
core.exportVariable(GRADLE_SETUP_VAR, true)
|
||||||
|
// Record setup complete: visible in post-action, to control action completion
|
||||||
|
core.saveState(GRADLE_SETUP_VAR, true)
|
||||||
|
|
||||||
|
// Save the Gradle User Home for use in the post-action step.
|
||||||
|
core.saveState(GRADLE_USER_HOME, gradleUserHome)
|
||||||
|
|
||||||
|
const cacheListener = new CacheListener()
|
||||||
|
await caches.restore(gradleUserHome, cacheListener)
|
||||||
|
|
||||||
|
core.saveState(CACHE_LISTENER, cacheListener.stringify())
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function complete(): Promise<void> {
|
||||||
|
if (!core.getState(GRADLE_SETUP_VAR)) {
|
||||||
|
core.info('Gradle setup post-action only performed for first gradle-build-action step in workflow.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
core.info('In final post-action step, saving state and writing summary')
|
||||||
|
|
||||||
|
const buildResults = loadBuildResults()
|
||||||
|
|
||||||
|
const gradleUserHome = core.getState(GRADLE_USER_HOME)
|
||||||
|
const cacheListener: CacheListener = CacheListener.rehydrate(core.getState(CACHE_LISTENER))
|
||||||
|
const daemonController = new DaemonController(buildResults)
|
||||||
|
|
||||||
|
await caches.save(gradleUserHome, cacheListener, daemonController)
|
||||||
|
|
||||||
|
if (shouldGenerateJobSummary()) {
|
||||||
|
await writeJobSummary(buildResults, cacheListener)
|
||||||
|
} else {
|
||||||
|
logJobSummary(buildResults, cacheListener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function determineGradleUserHome(rootDir: string): Promise<string> {
|
||||||
|
const customGradleUserHome = process.env['GRADLE_USER_HOME']
|
||||||
|
if (customGradleUserHome) {
|
||||||
|
return path.resolve(rootDir, customGradleUserHome)
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.resolve(await determineUserHome(), '.gradle')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Different values can be returned by os.homedir() in Javascript and System.getProperty('user.home') in Java.
|
||||||
|
* In order to determine the correct Gradle User Home, we ask Java for the user home instead of using os.homedir().
|
||||||
|
*/
|
||||||
|
async function determineUserHome(): Promise<string> {
|
||||||
|
const output = await exec.getExecOutput('java', ['-XshowSettings:properties', '-version'], {silent: true})
|
||||||
|
const regex = /user\.home = (\S*)/i
|
||||||
|
const found = output.stderr.match(regex)
|
||||||
|
if (found == null || found.length <= 1) {
|
||||||
|
core.info('Could not determine user.home from java -version output. Using os.homedir().')
|
||||||
|
return os.homedir()
|
||||||
|
}
|
||||||
|
const userHome = found[1]
|
||||||
|
core.debug(`Determined user.home from java -version output: '${userHome}'`)
|
||||||
|
return userHome
|
||||||
|
}
|
2
test/init-scripts/.gitignore
vendored
Normal file
2
test/init-scripts/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
build
|
||||||
|
.gradle
|
29
test/init-scripts/build.gradle
Normal file
29
test/init-scripts/build.gradle
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
plugins {
|
||||||
|
id 'groovy'
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation gradleTestKit()
|
||||||
|
testImplementation 'org.spockframework:spock-core:2.1-groovy-3.0'
|
||||||
|
testImplementation('org.spockframework:spock-junit4:2.1-groovy-3.0')
|
||||||
|
|
||||||
|
testImplementation ('io.ratpack:ratpack-groovy-test:1.9.0') {
|
||||||
|
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
|
||||||
|
}
|
||||||
|
testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-smile:2.13.3'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
234
test/init-scripts/gradlew
vendored
Executable file
234
test/init-scripts/gradlew
vendored
Executable file
@@ -0,0 +1,234 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -54,7 +54,7 @@ goto fail
|
|||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
@@ -64,21 +64,6 @@ echo location of your Java installation.
|
|||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
@@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
14
test/init-scripts/settings.gradle
Normal file
14
test/init-scripts/settings.gradle
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
plugins {
|
||||||
|
id "com.gradle.enterprise" version "3.11.1"
|
||||||
|
id "com.gradle.common-custom-user-data-gradle-plugin" version "1.8"
|
||||||
|
}
|
||||||
|
|
||||||
|
gradleEnterprise {
|
||||||
|
buildScan {
|
||||||
|
termsOfServiceUrl = "https://gradle.com/terms-of-service"
|
||||||
|
termsOfServiceAgree = "yes"
|
||||||
|
publishAlways()
|
||||||
|
uploadInBackground = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootProject.name = 'test-init-scripts'
|
@@ -0,0 +1,250 @@
|
|||||||
|
package com.gradle.gradlebuildaction
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonFactory
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
|
import com.fasterxml.jackson.dataformat.smile.SmileFactory
|
||||||
|
import org.gradle.testkit.runner.BuildResult
|
||||||
|
import org.gradle.testkit.runner.GradleRunner
|
||||||
|
import org.gradle.testkit.runner.internal.DefaultGradleRunner
|
||||||
|
import org.gradle.util.GradleVersion
|
||||||
|
import ratpack.groovy.test.embed.GroovyEmbeddedApp
|
||||||
|
import spock.lang.AutoCleanup
|
||||||
|
import spock.lang.Specification
|
||||||
|
import spock.lang.TempDir
|
||||||
|
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.util.zip.GZIPOutputStream
|
||||||
|
|
||||||
|
class BaseInitScriptTest extends Specification {
|
||||||
|
|
||||||
|
static final TestGradleVersion GRADLE_3_5 = new TestGradleVersion(GradleVersion.version('3.5.1'), 7, 9)
|
||||||
|
static final TestGradleVersion GRADLE_4_0 = new TestGradleVersion(GradleVersion.version('4.0.2'), 7, 9)
|
||||||
|
static final TestGradleVersion GRADLE_4_10 = new TestGradleVersion(GradleVersion.version('4.10.3'), 7, 10)
|
||||||
|
static final TestGradleVersion GRADLE_5_0 = new TestGradleVersion(GradleVersion.version('5.0'), 8, 11)
|
||||||
|
static final TestGradleVersion GRADLE_5_6 = new TestGradleVersion(GradleVersion.version('5.6.4'), 8, 12)
|
||||||
|
static final TestGradleVersion GRADLE_6_0 = new TestGradleVersion(GradleVersion.version('6.0.1'), 8, 13)
|
||||||
|
static final TestGradleVersion GRADLE_6_7 = new TestGradleVersion(GradleVersion.version('6.7'), 8, 15)
|
||||||
|
static final TestGradleVersion GRADLE_7_0 = new TestGradleVersion(GradleVersion.version('7.0.2'), 8, 16)
|
||||||
|
static final TestGradleVersion GRADLE_7_4 = new TestGradleVersion(GradleVersion.version('7.4.2'), 8, 17)
|
||||||
|
|
||||||
|
static final List<TestGradleVersion> ALL_VERSIONS = [
|
||||||
|
GRADLE_3_5, // First version where TestKit supports environment variables
|
||||||
|
GRADLE_4_0,
|
||||||
|
GRADLE_4_10,
|
||||||
|
GRADLE_5_0,
|
||||||
|
GRADLE_5_6,
|
||||||
|
GRADLE_6_0,
|
||||||
|
GRADLE_6_7,
|
||||||
|
GRADLE_7_0,
|
||||||
|
GRADLE_7_4,
|
||||||
|
]
|
||||||
|
|
||||||
|
static final List<TestGradleVersion> CONFIGURATION_CACHE_VERSIONS =
|
||||||
|
[GRADLE_7_0, GRADLE_7_4]
|
||||||
|
|
||||||
|
static final String PUBLIC_BUILD_SCAN_ID = 'i2wepy2gr7ovw'
|
||||||
|
static final String DEFAULT_SCAN_UPLOAD_TOKEN = 'scan-upload-token'
|
||||||
|
static final String ROOT_PROJECT_NAME = 'test-init-script'
|
||||||
|
boolean failScanUpload = false
|
||||||
|
|
||||||
|
File settingsFile
|
||||||
|
File buildFile
|
||||||
|
|
||||||
|
@TempDir
|
||||||
|
File testProjectDir
|
||||||
|
|
||||||
|
@AutoCleanup
|
||||||
|
def mockScansServer = GroovyEmbeddedApp.of {
|
||||||
|
def jsonWriter = new ObjectMapper(new JsonFactory()).writer()
|
||||||
|
def smileWriter = new ObjectMapper(new SmileFactory()).writer()
|
||||||
|
|
||||||
|
handlers {
|
||||||
|
post('in/:gradleVersion/:pluginVersion') {
|
||||||
|
if (failScanUpload) {
|
||||||
|
context.response.status(401).send()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
def scanUrlString = "${mockScansServer.address}s/$PUBLIC_BUILD_SCAN_ID"
|
||||||
|
def body = [
|
||||||
|
id : PUBLIC_BUILD_SCAN_ID,
|
||||||
|
scanUrl: scanUrlString.toString(),
|
||||||
|
]
|
||||||
|
def out = new ByteArrayOutputStream()
|
||||||
|
new GZIPOutputStream(out).withStream { smileWriter.writeValue(it, body) }
|
||||||
|
context.response
|
||||||
|
.contentType('application/vnd.gradle.scan-ack')
|
||||||
|
.send(out.toByteArray())
|
||||||
|
}
|
||||||
|
prefix('scans/publish') {
|
||||||
|
post('gradle/:pluginVersion/token') {
|
||||||
|
if (failScanUpload) {
|
||||||
|
context.response.status(401).send()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
def pluginVersion = context.pathTokens.pluginVersion
|
||||||
|
def scanUrlString = "${mockScansServer.address}s/$PUBLIC_BUILD_SCAN_ID"
|
||||||
|
def body = [
|
||||||
|
id : PUBLIC_BUILD_SCAN_ID,
|
||||||
|
scanUrl : scanUrlString.toString(),
|
||||||
|
scanUploadUrl : "${mockScansServer.address.toString()}scans/publish/gradle/$pluginVersion/upload".toString(),
|
||||||
|
scanUploadToken: DEFAULT_SCAN_UPLOAD_TOKEN
|
||||||
|
]
|
||||||
|
context.response
|
||||||
|
.contentType('application/vnd.gradle.scan-ack+json')
|
||||||
|
.send(jsonWriter.writeValueAsBytes(body))
|
||||||
|
}
|
||||||
|
post('gradle/:pluginVersion/upload') {
|
||||||
|
if (failScanUpload) {
|
||||||
|
context.response.status(401).send()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
context.request.getBody(1024 * 1024 * 10).then {
|
||||||
|
context.response
|
||||||
|
.contentType('application/vnd.gradle.scan-upload-ack+json')
|
||||||
|
.send()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notFound()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def setup() {
|
||||||
|
settingsFile = new File(testProjectDir, 'settings.gradle')
|
||||||
|
buildFile = new File(testProjectDir, 'build.gradle')
|
||||||
|
|
||||||
|
File srcInitScriptsDir = new File("../../src/resources/init-scripts")
|
||||||
|
File targetInitScriptsDir = new File(testProjectDir, "initScripts")
|
||||||
|
targetInitScriptsDir.mkdirs()
|
||||||
|
|
||||||
|
for (File srcInitScript : srcInitScriptsDir.listFiles()) {
|
||||||
|
File targetInitScript = new File(targetInitScriptsDir, srcInitScript.name)
|
||||||
|
Files.copy(srcInitScript.toPath(), targetInitScript.toPath())
|
||||||
|
}
|
||||||
|
settingsFile << "rootProject.name = '${ROOT_PROJECT_NAME}'\n"
|
||||||
|
buildFile << ''
|
||||||
|
}
|
||||||
|
|
||||||
|
def declareGePluginApplication(GradleVersion gradleVersion) {
|
||||||
|
settingsFile.text = maybeAddPluginsToSettings(gradleVersion) + settingsFile.text
|
||||||
|
buildFile.text = maybeAddPluginsToRootProject(gradleVersion) + buildFile.text
|
||||||
|
}
|
||||||
|
|
||||||
|
String maybeAddPluginsToSettings(GradleVersion gradleVersion) {
|
||||||
|
if (gradleVersion < GradleVersion.version('5.0')) {
|
||||||
|
'' // applied in build.gradle
|
||||||
|
} else if (gradleVersion < GradleVersion.version('6.0')) {
|
||||||
|
'' // applied in build.gradle
|
||||||
|
} else {
|
||||||
|
"""
|
||||||
|
plugins {
|
||||||
|
id 'com.gradle.enterprise' version '3.4.1'
|
||||||
|
}
|
||||||
|
gradleEnterprise {
|
||||||
|
server = '$mockScansServer.address'
|
||||||
|
buildScan {
|
||||||
|
publishAlways()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String maybeAddPluginsToRootProject(GradleVersion gradleVersion) {
|
||||||
|
if (gradleVersion < GradleVersion.version('5.0')) {
|
||||||
|
"""
|
||||||
|
plugins {
|
||||||
|
id 'com.gradle.build-scan' version '1.16'
|
||||||
|
}
|
||||||
|
buildScan {
|
||||||
|
server = '$mockScansServer.address'
|
||||||
|
publishAlways()
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
} else if (gradleVersion < GradleVersion.version('6.0')) {
|
||||||
|
"""
|
||||||
|
plugins {
|
||||||
|
id 'com.gradle.build-scan' version '3.4.1'
|
||||||
|
}
|
||||||
|
gradleEnterprise {
|
||||||
|
server = '$mockScansServer.address'
|
||||||
|
buildScan {
|
||||||
|
publishAlways()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
} else {
|
||||||
|
'' // applied in settings.gradle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def addFailingTaskToBuild() {
|
||||||
|
buildFile << '''
|
||||||
|
task expectFailure {
|
||||||
|
doLast {
|
||||||
|
throw new RuntimeException("Expected to fail")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildResult run(List<String> args, String initScript, GradleVersion gradleVersion = GradleVersion.current(), List<String> jvmArgs = [], Map<String, String> envVars = [:]) {
|
||||||
|
createRunner(initScript, args, gradleVersion, jvmArgs, envVars).build()
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildResult runAndFail(List<String> args, String initScript, GradleVersion gradleVersion = GradleVersion.current(), List<String> jvmArgs = [], Map<String, String> envVars = [:]) {
|
||||||
|
createRunner(initScript, args, gradleVersion, jvmArgs, envVars).buildAndFail()
|
||||||
|
}
|
||||||
|
|
||||||
|
GradleRunner createRunner(String initScript, List<String> args, GradleVersion gradleVersion = GradleVersion.current(), List<String> jvmArgs = [], Map<String, String> envVars = [:]) {
|
||||||
|
File initScriptsDir = new File(testProjectDir, "initScripts")
|
||||||
|
args << '-I' << new File(initScriptsDir, initScript).absolutePath
|
||||||
|
|
||||||
|
envVars.putIfAbsent('RUNNER_TEMP', testProjectDir.absolutePath)
|
||||||
|
envVars.putIfAbsent('GITHUB_ACTION', 'github-step-id')
|
||||||
|
|
||||||
|
def runner = ((DefaultGradleRunner) GradleRunner.create())
|
||||||
|
.withJvmArguments(jvmArgs)
|
||||||
|
.withGradleVersion(gradleVersion.version)
|
||||||
|
.withProjectDir(testProjectDir)
|
||||||
|
.withArguments(args)
|
||||||
|
.withEnvironment(envVars)
|
||||||
|
.forwardOutput()
|
||||||
|
|
||||||
|
runner
|
||||||
|
}
|
||||||
|
|
||||||
|
static final class TestGradleVersion {
|
||||||
|
|
||||||
|
final GradleVersion gradleVersion
|
||||||
|
private final Integer jdkMin
|
||||||
|
private final Integer jdkMax
|
||||||
|
|
||||||
|
TestGradleVersion(GradleVersion gradleVersion, Integer jdkMin, Integer jdkMax) {
|
||||||
|
this.gradleVersion = gradleVersion
|
||||||
|
this.jdkMin = jdkMin
|
||||||
|
this.jdkMax = jdkMax
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isCompatibleWithCurrentJvm() {
|
||||||
|
def jvmVersion = getJvmVersion()
|
||||||
|
jdkMin <= jvmVersion && jvmVersion <= jdkMax
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getJvmVersion() {
|
||||||
|
String version = System.getProperty('java.version')
|
||||||
|
if (version.startsWith('1.')) {
|
||||||
|
Integer.parseInt(version.substring(2, 3))
|
||||||
|
} else {
|
||||||
|
Integer.parseInt(version.substring(0, version.indexOf('.')))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String toString() {
|
||||||
|
return "Gradle " + gradleVersion.version
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,172 @@
|
|||||||
|
package com.gradle.gradlebuildaction
|
||||||
|
|
||||||
|
import groovy.json.JsonSlurper
|
||||||
|
|
||||||
|
import static org.junit.Assume.assumeTrue
|
||||||
|
|
||||||
|
class TestBuildResultRecorder extends BaseInitScriptTest {
|
||||||
|
def initScript = 'build-result-capture.init.gradle'
|
||||||
|
|
||||||
|
def "produces build results file for build with #testGradleVersion"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
when:
|
||||||
|
run(['help'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
then:
|
||||||
|
assertResults('help', testGradleVersion, false, false)
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << ALL_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
|
def "produces build results file for failing build with #testGradleVersion"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
when:
|
||||||
|
addFailingTaskToBuild()
|
||||||
|
runAndFail(['expectFailure'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
then:
|
||||||
|
assertResults('expectFailure', testGradleVersion, true, false)
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << ALL_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
|
def "produces build results file for build with --configuration-cache on #testGradleVersion"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
when:
|
||||||
|
run(['help', '--configuration-cache'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
then:
|
||||||
|
assertResults('help', testGradleVersion, false, false)
|
||||||
|
assert buildResultFile.delete()
|
||||||
|
|
||||||
|
when:
|
||||||
|
run(['help', '--configuration-cache'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
then:
|
||||||
|
assertResults('help', testGradleVersion, false, false)
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << CONFIGURATION_CACHE_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
|
def "produces build results file for #testGradleVersion with build scan published"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
when:
|
||||||
|
declareGePluginApplication(testGradleVersion.gradleVersion)
|
||||||
|
run(['help'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
then:
|
||||||
|
assertResults('help', testGradleVersion, false, true)
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << ALL_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
|
def "produces build results file for #testGradleVersion with ge-plugin and no build scan published"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
when:
|
||||||
|
declareGePluginApplication(testGradleVersion.gradleVersion)
|
||||||
|
run(['help', '--no-scan'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
then:
|
||||||
|
assertResults('help', testGradleVersion, false, false)
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << ALL_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
|
def "produces build results file for failing build on #testGradleVersion with build scan published"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
when:
|
||||||
|
declareGePluginApplication(testGradleVersion.gradleVersion)
|
||||||
|
addFailingTaskToBuild()
|
||||||
|
runAndFail(['expectFailure'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
then:
|
||||||
|
assertResults('expectFailure', testGradleVersion, true, true)
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << ALL_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
|
def "produces build results file for build with --configuration-cache on #testGradleVersion with build scan published"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
when:
|
||||||
|
declareGePluginApplication(testGradleVersion.gradleVersion)
|
||||||
|
run(['help', '--configuration-cache'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
then:
|
||||||
|
assertResults('help', testGradleVersion, false, true)
|
||||||
|
assert buildResultFile.delete()
|
||||||
|
|
||||||
|
when:
|
||||||
|
run(['help', '--configuration-cache'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
then:
|
||||||
|
assertResults('help', testGradleVersion, false, true)
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << CONFIGURATION_CACHE_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
|
def "produces build results file for failing build on #testGradleVersion when build scan publish fails"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
when:
|
||||||
|
declareGePluginApplication(testGradleVersion.gradleVersion)
|
||||||
|
addFailingTaskToBuild()
|
||||||
|
failScanUpload = true
|
||||||
|
runAndFail(['expectFailure'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
then:
|
||||||
|
assertResults('expectFailure', testGradleVersion, true, false, true)
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << ALL_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
|
def "produces no build results file when GitHub env vars not set with #testGradleVersion"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
when:
|
||||||
|
run(['help'], initScript, testGradleVersion.gradleVersion, [], [RUNNER_TEMP: '', GITHUB_ACTION: ''])
|
||||||
|
|
||||||
|
then:
|
||||||
|
def buildResultsDir = new File(testProjectDir, '.build-results')
|
||||||
|
assert !buildResultsDir.exists()
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << ALL_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertResults(String task, TestGradleVersion testGradleVersion, boolean hasFailure, boolean hasBuildScan, boolean scanUploadFailed = false) {
|
||||||
|
def results = new JsonSlurper().parse(buildResultFile)
|
||||||
|
assert results['rootProjectName'] == ROOT_PROJECT_NAME
|
||||||
|
assert results['rootProjectDir'] == testProjectDir.canonicalPath
|
||||||
|
assert results['requestedTasks'] == task
|
||||||
|
assert results['gradleVersion'] == testGradleVersion.gradleVersion.version
|
||||||
|
assert results['gradleHomeDir'] != null
|
||||||
|
assert results['buildFailed'] == hasFailure
|
||||||
|
assert results['buildScanUri'] == (hasBuildScan ? "${mockScansServer.address}s/${PUBLIC_BUILD_SCAN_ID}" : null)
|
||||||
|
assert results['buildScanFailed'] == scanUploadFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
private File getBuildResultFile() {
|
||||||
|
def buildResultsDir = new File(testProjectDir, '.build-results')
|
||||||
|
assert buildResultsDir.directory
|
||||||
|
assert buildResultsDir.listFiles().size() == 1
|
||||||
|
def resultsFile = buildResultsDir.listFiles()[0]
|
||||||
|
assert resultsFile.name.startsWith('github-step-id')
|
||||||
|
assert resultsFile.text.count('rootProjectName') == 1
|
||||||
|
return resultsFile
|
||||||
|
}
|
||||||
|
}
|
87
test/jest/cache-cleanup.test.ts
Normal file
87
test/jest/cache-cleanup.test.ts
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import * as exec from '@actions/exec'
|
||||||
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
import {CacheCleaner} from '../../src/cache-cleaner'
|
||||||
|
|
||||||
|
jest.setTimeout(120000)
|
||||||
|
|
||||||
|
test('will cleanup unused dependency jars and build-cache entries', async () => {
|
||||||
|
const projectRoot = prepareTestProject()
|
||||||
|
const gradleUserHome = path.resolve(projectRoot, 'HOME')
|
||||||
|
const tmpDir = path.resolve(projectRoot, 'tmp')
|
||||||
|
const cacheCleaner = new CacheCleaner(gradleUserHome, tmpDir)
|
||||||
|
|
||||||
|
await runGradleBuild(projectRoot, 'build', '3.1')
|
||||||
|
|
||||||
|
await cacheCleaner.prepare()
|
||||||
|
|
||||||
|
await runGradleBuild(projectRoot, 'build', '3.1.1')
|
||||||
|
|
||||||
|
const commonsMath31 = path.resolve(gradleUserHome, "caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1")
|
||||||
|
const commonsMath311 = path.resolve(gradleUserHome, "caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1.1")
|
||||||
|
const buildCacheDir = path.resolve(gradleUserHome, "caches/build-cache-1")
|
||||||
|
|
||||||
|
expect(fs.existsSync(commonsMath31)).toBe(true)
|
||||||
|
expect(fs.existsSync(commonsMath311)).toBe(true)
|
||||||
|
expect(fs.readdirSync(buildCacheDir).length).toBe(4)
|
||||||
|
|
||||||
|
await cacheCleaner.forceCleanup()
|
||||||
|
|
||||||
|
expect(fs.existsSync(commonsMath31)).toBe(false)
|
||||||
|
expect(fs.existsSync(commonsMath311)).toBe(true)
|
||||||
|
expect(fs.readdirSync(buildCacheDir).length).toBe(3)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('will cleanup unused gradle versions', async () => {
|
||||||
|
const projectRoot = prepareTestProject()
|
||||||
|
const gradleUserHome = path.resolve(projectRoot, 'HOME')
|
||||||
|
const tmpDir = path.resolve(projectRoot, 'tmp')
|
||||||
|
const cacheCleaner = new CacheCleaner(gradleUserHome, tmpDir)
|
||||||
|
|
||||||
|
// Initialize HOME with 2 different Gradle versions
|
||||||
|
await runGradleWrapperBuild(projectRoot, 'build')
|
||||||
|
await runGradleBuild(projectRoot, 'build')
|
||||||
|
|
||||||
|
await cacheCleaner.prepare()
|
||||||
|
|
||||||
|
// Run with only one of these versions
|
||||||
|
await runGradleBuild(projectRoot, 'build')
|
||||||
|
|
||||||
|
const gradle733 = path.resolve(gradleUserHome, "caches/7.3.3")
|
||||||
|
const wrapper733 = path.resolve(gradleUserHome, "wrapper/dists/gradle-7.3.3-bin")
|
||||||
|
const gradleCurrent = path.resolve(gradleUserHome, "caches/7.5.1")
|
||||||
|
|
||||||
|
expect(fs.existsSync(gradle733)).toBe(true)
|
||||||
|
expect(fs.existsSync(wrapper733)).toBe(true)
|
||||||
|
expect(fs.existsSync(gradleCurrent)).toBe(true)
|
||||||
|
|
||||||
|
await cacheCleaner.forceCleanup()
|
||||||
|
|
||||||
|
expect(fs.existsSync(gradle733)).toBe(false)
|
||||||
|
expect(fs.existsSync(wrapper733)).toBe(false)
|
||||||
|
expect(fs.existsSync(gradleCurrent)).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
async function runGradleBuild(projectRoot: string, args: string, version: string = '3.1'): Promise<void> {
|
||||||
|
const status31 = await exec.exec(`gradle -g HOME --no-daemon --build-cache -Dcommons_math3_version="${version}" ${args}`, [], {
|
||||||
|
cwd: projectRoot
|
||||||
|
})
|
||||||
|
console.log(`Gradle User Home initialized with commons_math3_version=${version} ${args}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runGradleWrapperBuild(projectRoot: string, args: string, version: string = '3.1'): Promise<void> {
|
||||||
|
const status31 = await exec.exec(`./gradlew -g HOME --no-daemon --build-cache -Dcommons_math3_version="${version}" ${args}`, [], {
|
||||||
|
cwd: projectRoot
|
||||||
|
})
|
||||||
|
console.log(`Gradle User Home initialized with commons_math3_version="${version}" ${args}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepareTestProject(): string {
|
||||||
|
const projectRoot = 'test/jest/resources/cache-cleanup'
|
||||||
|
fs.rmSync(path.resolve(projectRoot, 'HOME'), { recursive: true, force: true })
|
||||||
|
fs.rmSync(path.resolve(projectRoot, 'tmp'), { recursive: true, force: true })
|
||||||
|
fs.rmSync(path.resolve(projectRoot, 'build'), { recursive: true, force: true })
|
||||||
|
fs.rmSync(path.resolve(projectRoot, '.gradle'), { recursive: true, force: true })
|
||||||
|
return projectRoot
|
||||||
|
}
|
||||||
|
|
@@ -1,4 +1,4 @@
|
|||||||
import {CacheEntryListener, CacheListener} from '../src/cache-reporting'
|
import {CacheEntryListener, CacheListener} from '../../src/cache-reporting'
|
||||||
|
|
||||||
describe('caching report', () => {
|
describe('caching report', () => {
|
||||||
describe('reports not fully restored', () => {
|
describe('reports not fully restored', () => {
|
@@ -1,4 +1,4 @@
|
|||||||
import * as cacheUtils from '../src/cache-utils'
|
import * as cacheUtils from '../../src/cache-utils'
|
||||||
|
|
||||||
describe('cacheUtils-utils', () => {
|
describe('cacheUtils-utils', () => {
|
||||||
describe('can hash', () => {
|
describe('can hash', () => {
|
@@ -3,3 +3,6 @@
|
|||||||
|
|
||||||
# Ignore Gradle build output directory
|
# Ignore Gradle build output directory
|
||||||
build
|
build
|
||||||
|
|
||||||
|
HOME
|
||||||
|
tmp
|
11
test/jest/resources/cache-cleanup/build.gradle
Normal file
11
test/jest/resources/cache-cleanup/build.gradle
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
plugins {
|
||||||
|
id 'java-library'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api "org.apache.commons:commons-math3:${System.properties['commons_math3_version']}"
|
||||||
|
}
|
BIN
test/jest/resources/cache-cleanup/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
test/jest/resources/cache-cleanup/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user