mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-25 14:16:18 +08:00
Do not generate dependency graph in cache-cleanup
- Allow environment variables to be overridden by system properties in dependency-graph initscript - Set `GITHUB_DEPENDENCY_GRAPH_ENABLED=false` when executing Gradle for cache cleanup
This commit is contained in:
parent
6fcc109efa
commit
d1b726d8c1
3
dist/main/index.js
vendored
3
dist/main/index.js
vendored
@ -69620,7 +69620,8 @@ class CacheCleaner {
|
|||||||
fs_1.default.mkdirSync(cleanupProjectDir, { recursive: true });
|
fs_1.default.mkdirSync(cleanupProjectDir, { recursive: true });
|
||||||
fs_1.default.writeFileSync(path_1.default.resolve(cleanupProjectDir, 'settings.gradle'), 'rootProject.name = "dummy-cleanup-project"');
|
fs_1.default.writeFileSync(path_1.default.resolve(cleanupProjectDir, 'settings.gradle'), 'rootProject.name = "dummy-cleanup-project"');
|
||||||
fs_1.default.writeFileSync(path_1.default.resolve(cleanupProjectDir, 'build.gradle'), 'task("noop") {}');
|
fs_1.default.writeFileSync(path_1.default.resolve(cleanupProjectDir, 'build.gradle'), 'task("noop") {}');
|
||||||
yield exec.exec(`gradle -g ${this.gradleUserHome} --no-daemon --build-cache --no-scan --quiet noop`, [], {
|
const gradleCommand = `gradle -g ${this.gradleUserHome} --no-daemon --build-cache --no-scan --quiet -DGITHUB_DEPENDENCY_GRAPH_ENABLED=false noop`;
|
||||||
|
yield exec.exec(gradleCommand, [], {
|
||||||
cwd: cleanupProjectDir
|
cwd: cleanupProjectDir
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
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
3
dist/post/index.js
vendored
3
dist/post/index.js
vendored
@ -69620,7 +69620,8 @@ class CacheCleaner {
|
|||||||
fs_1.default.mkdirSync(cleanupProjectDir, { recursive: true });
|
fs_1.default.mkdirSync(cleanupProjectDir, { recursive: true });
|
||||||
fs_1.default.writeFileSync(path_1.default.resolve(cleanupProjectDir, 'settings.gradle'), 'rootProject.name = "dummy-cleanup-project"');
|
fs_1.default.writeFileSync(path_1.default.resolve(cleanupProjectDir, 'settings.gradle'), 'rootProject.name = "dummy-cleanup-project"');
|
||||||
fs_1.default.writeFileSync(path_1.default.resolve(cleanupProjectDir, 'build.gradle'), 'task("noop") {}');
|
fs_1.default.writeFileSync(path_1.default.resolve(cleanupProjectDir, 'build.gradle'), 'task("noop") {}');
|
||||||
yield exec.exec(`gradle -g ${this.gradleUserHome} --no-daemon --build-cache --no-scan --quiet noop`, [], {
|
const gradleCommand = `gradle -g ${this.gradleUserHome} --no-daemon --build-cache --no-scan --quiet -DGITHUB_DEPENDENCY_GRAPH_ENABLED=false noop`;
|
||||||
|
yield exec.exec(gradleCommand, [], {
|
||||||
cwd: cleanupProjectDir
|
cwd: cleanupProjectDir
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
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
@ -42,7 +42,8 @@ export class CacheCleaner {
|
|||||||
)
|
)
|
||||||
fs.writeFileSync(path.resolve(cleanupProjectDir, 'build.gradle'), 'task("noop") {}')
|
fs.writeFileSync(path.resolve(cleanupProjectDir, 'build.gradle'), 'task("noop") {}')
|
||||||
|
|
||||||
await exec.exec(`gradle -g ${this.gradleUserHome} --no-daemon --build-cache --no-scan --quiet noop`, [], {
|
const gradleCommand = `gradle -g ${this.gradleUserHome} --no-daemon --build-cache --no-scan --quiet -DGITHUB_DEPENDENCY_GRAPH_ENABLED=false noop`
|
||||||
|
await exec.exec(gradleCommand, [], {
|
||||||
cwd: cleanupProjectDir
|
cwd: cleanupProjectDir
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
|
|
||||||
// Only run when dependency graph is explicitly enabled
|
// Only run when dependency graph is explicitly enabled
|
||||||
if (System.env.GITHUB_DEPENDENCY_GRAPH_ENABLED != "true") {
|
if (getVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED') != "true") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ if (GradleVersion.current().baseVersion < GradleVersion.version("5.0")) {
|
|||||||
// This is only required for top-level builds
|
// This is only required for top-level builds
|
||||||
def isTopLevelBuild = gradle.getParent() == null
|
def isTopLevelBuild = gradle.getParent() == null
|
||||||
if (isTopLevelBuild) {
|
if (isTopLevelBuild) {
|
||||||
def reportFile = getUniqueReportFile(System.env.GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR)
|
def reportFile = getUniqueReportFile(getVariable('GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR'))
|
||||||
|
|
||||||
if (reportFile == null) {
|
if (reportFile == null) {
|
||||||
println "::warning::No dependency snapshot generated for step. Could not determine unique job correlator - specify GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR var for this step."
|
println "::warning::No dependency snapshot generated for step. Could not determine unique job correlator - specify GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR var for this step."
|
||||||
@ -40,7 +40,7 @@ apply from: 'gradle-build-action.github-dependency-graph-gradle-plugin-apply.gro
|
|||||||
* - When found, this value is set as a System property override.
|
* - When found, this value is set as a System property override.
|
||||||
*/
|
*/
|
||||||
File getUniqueReportFile(String jobCorrelator) {
|
File getUniqueReportFile(String jobCorrelator) {
|
||||||
def reportDir = System.env.DEPENDENCY_GRAPH_REPORT_DIR
|
def reportDir = getVariable('DEPENDENCY_GRAPH_REPORT_DIR')
|
||||||
def reportFile = new File(reportDir, jobCorrelator + ".json")
|
def reportFile = new File(reportDir, jobCorrelator + ".json")
|
||||||
if (!reportFile.exists()) return reportFile
|
if (!reportFile.exists()) return reportFile
|
||||||
|
|
||||||
@ -57,3 +57,10 @@ File getUniqueReportFile(String jobCorrelator) {
|
|||||||
// Could not determine unique job correlator
|
// Could not determine unique job correlator
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the environment variable value, or equivalent system property (if set)
|
||||||
|
*/
|
||||||
|
String getVariable(String name) {
|
||||||
|
return System.properties[name] ?: System.getenv(name)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user