mirror of
https://github.com/gradle/actions.git
synced 2025-08-18 23:01:27 +08:00
Merge pull request #40 from gradle/dd/v3.1
Improvements in preparation for v3.1
This commit is contained in:
commit
5e512f6e1d
@ -10,7 +10,7 @@ dependencies {
|
||||
api("org.apache.commons:commons-math3:3.6.1")
|
||||
implementation("com.google.guava:guava:33.0.0-jre")
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
|
@ -73,6 +73,7 @@ runs:
|
||||
arguments: |
|
||||
-Dorg.gradle.configureondemand=false
|
||||
-Dorg.gradle.dependency.verification=off
|
||||
-Dorg.gradle.unsafe.isolated-projects=false
|
||||
:ForceDependencyResolutionPlugin_resolveAllDependencies
|
||||
${{ inputs.additional-arguments }}
|
||||
- name: Download and submit dependency graph
|
||||
|
24
dist/setup-gradle/main/index.js
vendored
24
dist/setup-gradle/main/index.js
vendored
@ -139144,6 +139144,9 @@ class GradleStateCache {
|
||||
fs_1.default.mkdirSync(actionCacheDir, { recursive: true });
|
||||
this.copyInitScripts();
|
||||
this.registerToolchains();
|
||||
if (core.isDebug()) {
|
||||
this.configureInfoLogLevel();
|
||||
}
|
||||
}
|
||||
copyInitScripts() {
|
||||
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
|
||||
@ -139182,9 +139185,22 @@ class GradleStateCache {
|
||||
const absolutePath = path_1.default.resolve(__dirname, '..', '..', '..', 'sources', 'src', 'resources', ...paths);
|
||||
return fs_1.default.readFileSync(absolutePath, 'utf8');
|
||||
}
|
||||
configureInfoLogLevel() {
|
||||
const infoProperties = `org.gradle.logging.level=info\norg.gradle.logging.stacktrace=all\n`;
|
||||
const propertiesFile = path_1.default.resolve(this.gradleUserHome, 'gradle.properties');
|
||||
if (fs_1.default.existsSync(propertiesFile)) {
|
||||
core.info(`Merged --info and --stacktrace into existing ${propertiesFile} file`);
|
||||
const existingProperties = fs_1.default.readFileSync(propertiesFile, 'utf-8');
|
||||
fs_1.default.writeFileSync(propertiesFile, `${infoProperties}\n${existingProperties}`);
|
||||
}
|
||||
else {
|
||||
core.info(`Created a new ${propertiesFile} with --info and --stacktrace`);
|
||||
fs_1.default.writeFileSync(propertiesFile, infoProperties);
|
||||
}
|
||||
}
|
||||
debugReportGradleUserHomeSize(label) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!(0, cache_utils_1.isCacheDebuggingEnabled)()) {
|
||||
if (!(0, cache_utils_1.isCacheDebuggingEnabled)() && !core.isDebug()) {
|
||||
return;
|
||||
}
|
||||
if (!fs_1.default.existsSync(this.gradleUserHome)) {
|
||||
@ -141041,7 +141057,9 @@ function addPRComment(jobSummary) {
|
||||
const pull_request_number = context.payload.pull_request.number;
|
||||
core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`);
|
||||
const prComment = `<h3>Job Summary for Gradle</h3>
|
||||
<h5>${github.context.workflow} :: <em>${github.context.job}</em></h5>
|
||||
<a href="${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}" target="_blank">
|
||||
<h5>${context.workflow} :: <em>${context.job}</em></h5>
|
||||
</a>
|
||||
|
||||
${jobSummary}`;
|
||||
const github_token = params.getGithubToken();
|
||||
@ -141110,7 +141128,7 @@ function renderBuildScan(result) {
|
||||
function renderBuildScanBadge(outcomeText, outcomeColor, targetUrl) {
|
||||
const badgeUrl = `https://img.shields.io/badge/Build%20Scan%C2%AE-${outcomeText}-${outcomeColor}?logo=Gradle`;
|
||||
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`;
|
||||
return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`;
|
||||
return `<a href="${targetUrl}" rel="nofollow" target="_blank">${badgeHtml}</a>`;
|
||||
}
|
||||
function shouldGenerateJobSummary(buildResults) {
|
||||
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
|
||||
|
2
dist/setup-gradle/main/index.js.map
vendored
2
dist/setup-gradle/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
24
dist/setup-gradle/post/index.js
vendored
24
dist/setup-gradle/post/index.js
vendored
@ -136597,6 +136597,9 @@ class GradleStateCache {
|
||||
fs_1.default.mkdirSync(actionCacheDir, { recursive: true });
|
||||
this.copyInitScripts();
|
||||
this.registerToolchains();
|
||||
if (core.isDebug()) {
|
||||
this.configureInfoLogLevel();
|
||||
}
|
||||
}
|
||||
copyInitScripts() {
|
||||
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
|
||||
@ -136635,9 +136638,22 @@ class GradleStateCache {
|
||||
const absolutePath = path_1.default.resolve(__dirname, '..', '..', '..', 'sources', 'src', 'resources', ...paths);
|
||||
return fs_1.default.readFileSync(absolutePath, 'utf8');
|
||||
}
|
||||
configureInfoLogLevel() {
|
||||
const infoProperties = `org.gradle.logging.level=info\norg.gradle.logging.stacktrace=all\n`;
|
||||
const propertiesFile = path_1.default.resolve(this.gradleUserHome, 'gradle.properties');
|
||||
if (fs_1.default.existsSync(propertiesFile)) {
|
||||
core.info(`Merged --info and --stacktrace into existing ${propertiesFile} file`);
|
||||
const existingProperties = fs_1.default.readFileSync(propertiesFile, 'utf-8');
|
||||
fs_1.default.writeFileSync(propertiesFile, `${infoProperties}\n${existingProperties}`);
|
||||
}
|
||||
else {
|
||||
core.info(`Created a new ${propertiesFile} with --info and --stacktrace`);
|
||||
fs_1.default.writeFileSync(propertiesFile, infoProperties);
|
||||
}
|
||||
}
|
||||
debugReportGradleUserHomeSize(label) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!(0, cache_utils_1.isCacheDebuggingEnabled)()) {
|
||||
if (!(0, cache_utils_1.isCacheDebuggingEnabled)() && !core.isDebug()) {
|
||||
return;
|
||||
}
|
||||
if (!fs_1.default.existsSync(this.gradleUserHome)) {
|
||||
@ -138360,7 +138376,9 @@ function addPRComment(jobSummary) {
|
||||
const pull_request_number = context.payload.pull_request.number;
|
||||
core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`);
|
||||
const prComment = `<h3>Job Summary for Gradle</h3>
|
||||
<h5>${github.context.workflow} :: <em>${github.context.job}</em></h5>
|
||||
<a href="${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}" target="_blank">
|
||||
<h5>${context.workflow} :: <em>${context.job}</em></h5>
|
||||
</a>
|
||||
|
||||
${jobSummary}`;
|
||||
const github_token = params.getGithubToken();
|
||||
@ -138429,7 +138447,7 @@ function renderBuildScan(result) {
|
||||
function renderBuildScanBadge(outcomeText, outcomeColor, targetUrl) {
|
||||
const badgeUrl = `https://img.shields.io/badge/Build%20Scan%C2%AE-${outcomeText}-${outcomeColor}?logo=Gradle`;
|
||||
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`;
|
||||
return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`;
|
||||
return `<a href="${targetUrl}" rel="nofollow" target="_blank">${badgeHtml}</a>`;
|
||||
}
|
||||
function shouldGenerateJobSummary(buildResults) {
|
||||
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
|
||||
|
2
dist/setup-gradle/post/index.js.map
vendored
2
dist/setup-gradle/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
@ -193,6 +193,16 @@ Specifically:
|
||||
|
||||
Using either of these mechanisms may interfere with the caching provided by this action. If you choose to use a different mechanism to save and restore the Gradle User Home, you should disable the caching provided by this action, as described above.
|
||||
|
||||
### GitHub Action Debug support
|
||||
To debug a failed job, GitHub provides a [debug mode](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging).
|
||||
If this debug mode is active, this action adds `--info` and `--stacktrace` by writing these [Gradle properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties) into the `${GRADLE_USER_HOME}/gradle.properties` file at the top.
|
||||
|
||||
To opt-out of this behaviour you can override these properties manually and put them into your `gradle.properties` file:
|
||||
```properties
|
||||
# default lifecycle
|
||||
org.gradle.logging.level=lifecycle
|
||||
org.gradle.logging.stacktrace=internal
|
||||
```
|
||||
### Cache debugging and analysis
|
||||
|
||||
A report of all cache entries restored and saved is printed to the Job Summary when saving the cache entries.
|
||||
@ -205,7 +215,7 @@ env:
|
||||
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||
```
|
||||
|
||||
Note that this setting will also prevent certain cache operations from running in parallel, further assisting with debugging.
|
||||
Note that when the workflow is run in debug mode (above), cache debugging is automatically enabled.
|
||||
|
||||
## How Gradle User Home caching works
|
||||
|
||||
@ -688,4 +698,3 @@ jobs:
|
||||
- name: Run a Gradle build - a build scan will be published automatically
|
||||
run: ./gradlew build
|
||||
```
|
||||
|
||||
|
@ -192,6 +192,10 @@ export class GradleStateCache {
|
||||
|
||||
// Copy the default toolchain definitions to `~/.m2/toolchains.xml`
|
||||
this.registerToolchains()
|
||||
|
||||
if (core.isDebug()) {
|
||||
this.configureInfoLogLevel()
|
||||
}
|
||||
}
|
||||
|
||||
private copyInitScripts(): void {
|
||||
@ -241,11 +245,30 @@ export class GradleStateCache {
|
||||
}
|
||||
|
||||
/**
|
||||
* When cache debugging is enabled, this method will give a detailed report
|
||||
* of the Gradle User Home contents.
|
||||
* When the GitHub environment ACTIONS_RUNNER_DEBUG is true, run Gradle with --info and --stacktrace.
|
||||
* see https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging
|
||||
*
|
||||
* @VisibleForTesting
|
||||
*/
|
||||
configureInfoLogLevel(): void {
|
||||
const infoProperties = `org.gradle.logging.level=info\norg.gradle.logging.stacktrace=all\n`
|
||||
const propertiesFile = path.resolve(this.gradleUserHome, 'gradle.properties')
|
||||
if (fs.existsSync(propertiesFile)) {
|
||||
core.info(`Merged --info and --stacktrace into existing ${propertiesFile} file`)
|
||||
const existingProperties = fs.readFileSync(propertiesFile, 'utf-8')
|
||||
fs.writeFileSync(propertiesFile, `${infoProperties}\n${existingProperties}`)
|
||||
} else {
|
||||
core.info(`Created a new ${propertiesFile} with --info and --stacktrace`)
|
||||
fs.writeFileSync(propertiesFile, infoProperties)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When cache debugging is enabled (or ACTIONS_STEP_DEBUG is on),
|
||||
* this method will give a detailed report of the Gradle User Home contents.
|
||||
*/
|
||||
private async debugReportGradleUserHomeSize(label: string): Promise<void> {
|
||||
if (!isCacheDebuggingEnabled()) {
|
||||
if (!isCacheDebuggingEnabled() && !core.isDebug()) {
|
||||
return
|
||||
}
|
||||
if (!fs.existsSync(this.gradleUserHome)) {
|
||||
|
@ -41,7 +41,9 @@ async function addPRComment(jobSummary: string): Promise<void> {
|
||||
core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`)
|
||||
|
||||
const prComment = `<h3>Job Summary for Gradle</h3>
|
||||
<h5>${github.context.workflow} :: <em>${github.context.job}</em></h5>
|
||||
<a href="${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}" target="_blank">
|
||||
<h5>${context.workflow} :: <em>${context.job}</em></h5>
|
||||
</a>
|
||||
|
||||
${jobSummary}`
|
||||
|
||||
@ -123,7 +125,7 @@ function renderBuildScan(result: BuildResult): string {
|
||||
function renderBuildScanBadge(outcomeText: string, outcomeColor: string, targetUrl: string): string {
|
||||
const badgeUrl = `https://img.shields.io/badge/Build%20Scan%C2%AE-${outcomeText}-${outcomeColor}?logo=Gradle`
|
||||
const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`
|
||||
return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`
|
||||
return `<a href="${targetUrl}" rel="nofollow" target="_blank">${badgeHtml}</a>`
|
||||
}
|
||||
|
||||
function shouldGenerateJobSummary(buildResults: BuildResult[]): boolean {
|
||||
|
30
sources/test/jest/cache-debug.test.ts
Normal file
30
sources/test/jest/cache-debug.test.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import {GradleStateCache} from "../../src/cache-base"
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
|
||||
describe("--info and --stacktrace", () => {
|
||||
describe("will be created", () => {
|
||||
it("when gradle.properties does not exists", async () => {
|
||||
const emptyGradleHome = 'test/jest/resources/gradle-home/empty'
|
||||
fs.rmSync(path.resolve(emptyGradleHome, "gradle.properties"), {force: true})
|
||||
|
||||
const stateCache = new GradleStateCache("ignored", emptyGradleHome)
|
||||
stateCache.configureInfoLogLevel()
|
||||
|
||||
expect(fs.readFileSync(path.resolve(emptyGradleHome, "gradle.properties"), 'utf-8'))
|
||||
.toBe("org.gradle.logging.level=info\norg.gradle.logging.stacktrace=all\n")
|
||||
})
|
||||
})
|
||||
describe("will be added", () => {
|
||||
it("and gradle.properties does exists", async () => {
|
||||
const existingGradleHome = 'test/jest/resources/gradle-home/existing'
|
||||
fs.writeFileSync(path.resolve(existingGradleHome, "gradle.properties"), "org.gradle.logging.level=debug\n")
|
||||
|
||||
const stateCache = new GradleStateCache("ignored", existingGradleHome)
|
||||
stateCache.configureInfoLogLevel()
|
||||
|
||||
expect(fs.readFileSync(path.resolve(existingGradleHome, "gradle.properties"), 'utf-8'))
|
||||
.toBe("org.gradle.logging.level=info\norg.gradle.logging.stacktrace=all\n\norg.gradle.logging.level=debug\n")
|
||||
})
|
||||
})
|
||||
})
|
1
sources/test/jest/resources/gradle-home/empty/.gitignore
vendored
Normal file
1
sources/test/jest/resources/gradle-home/empty/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
gradle.properties
|
@ -0,0 +1 @@
|
||||
org.gradle.logging.level=debug
|
Loading…
x
Reference in New Issue
Block a user