mirror of
https://github.com/gradle/actions.git
synced 2026-03-25 13:36:20 +08:00
Mute license warning when terms are accepted (#911)
With licensing changes in v6, a license warning was added to the logs and job summary. Now, accepting the Build Scan Terms of Use or providing a Develocity Access Key will mute this warning.
This commit is contained in:
35
.github/workflows/demo-job-summary.yml
vendored
35
.github/workflows/demo-job-summary.yml
vendored
@@ -131,3 +131,38 @@ jobs:
|
|||||||
- name: Build kotlin-dsl project
|
- name: Build kotlin-dsl project
|
||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
run: ./gradlew assemble
|
run: ./gradlew assemble
|
||||||
|
|
||||||
|
terms-of-use-accepted:
|
||||||
|
needs: build-distribution
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
- name: Initialize integ-test
|
||||||
|
uses: ./.github/actions/init-integ-test
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./setup-gradle
|
||||||
|
with:
|
||||||
|
build-scan-terms-of-use-url: https://gradle.com/help/legal-terms-of-use
|
||||||
|
build-scan-terms-of-use-agree: yes
|
||||||
|
- name: Build kotlin-dsl project
|
||||||
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
run: ./gradlew assemble
|
||||||
|
|
||||||
|
develocity-access-key-set:
|
||||||
|
needs: build-distribution
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
- name: Initialize integ-test
|
||||||
|
uses: ./.github/actions/init-integ-test
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./setup-gradle
|
||||||
|
with:
|
||||||
|
develocity-access-key: ${{ secrets.DV_SOLUTIONS_ACCESS_KEY }}
|
||||||
|
- name: Build kotlin-dsl project
|
||||||
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
run: ./gradlew assemble
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ This repository contains a set of GitHub Actions that are useful for building Gr
|
|||||||
> Use of the `gradle-actions-caching` component is subject to a separate license, available at https://gradle.com/legal/terms-of-use/.
|
> Use of the `gradle-actions-caching` component is subject to a separate license, available at https://gradle.com/legal/terms-of-use/.
|
||||||
> If you do not agree to these license terms, do not use the `gradle-actions-caching` component.
|
> If you do not agree to these license terms, do not use the `gradle-actions-caching` component.
|
||||||
|
|
||||||
|
This license notice will be displayed in workflow logs and each job summary. To suppress this message,
|
||||||
|
either [accept the terms of use](docs/setup-gradle.md#publishing-to-scansgradlecom) in your workflow, or [provide a Develocity access key](docs/setup-gradle.md#managing-develocity-access-keys).
|
||||||
|
|
||||||
## The `setup-gradle` action
|
## The `setup-gradle` action
|
||||||
|
|
||||||
The `setup-gradle` action can be used to configure Gradle for optimal execution on any platform supported by GitHub Actions.
|
The `setup-gradle` action can be used to configure Gradle for optimal execution on any platform supported by GitHub Actions.
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ If you're confused by the behaviour you're seeing or have specific questions, pl
|
|||||||
> Use of the `gradle-actions-caching` component is subject to a separate license, available at https://gradle.com/legal/terms-of-use/.
|
> Use of the `gradle-actions-caching` component is subject to a separate license, available at https://gradle.com/legal/terms-of-use/.
|
||||||
> If you do not agree to these license terms, do not use the `gradle-actions-caching` component.
|
> If you do not agree to these license terms, do not use the `gradle-actions-caching` component.
|
||||||
|
|
||||||
|
This license notice will be displayed in workflow logs and each job summary. To suppress this message,
|
||||||
|
either [accept the terms of use](setup-gradle.md#publishing-to-scansgradlecom) in your workflow, or [provide a Develocity access key](setup-gradle.md#managing-develocity-access-keys).
|
||||||
|
|
||||||
## General usage
|
## General usage
|
||||||
|
|
||||||
The following workflow will generate a dependency graph for a Gradle project and submit it immediately to the repository via the
|
The following workflow will generate a dependency graph for a Gradle project and submit it immediately to the repository via the
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ This GitHub Action can be used to configure Gradle for optimal execution on any
|
|||||||
> Use of the `gradle-actions-caching` component is subject to a separate license, available at https://gradle.com/legal/terms-of-use/.
|
> Use of the `gradle-actions-caching` component is subject to a separate license, available at https://gradle.com/legal/terms-of-use/.
|
||||||
> If you do not agree to these license terms, do not use the `gradle-actions-caching` component.
|
> If you do not agree to these license terms, do not use the `gradle-actions-caching` component.
|
||||||
|
|
||||||
|
This license notice will be displayed in workflow logs and each job summary. To suppress this message,
|
||||||
|
either [accept the terms of use](#publishing-to-scansgradlecom) in your workflow, or [provide a Develocity access key](#managing-develocity-access-keys).
|
||||||
|
|
||||||
## Why use the `setup-gradle` action?
|
## Why use the `setup-gradle` action?
|
||||||
|
|
||||||
It is possible to directly invoke Gradle in your workflow, and the `actions/setup-java@v5` action provides a simple way to cache Gradle dependencies.
|
It is possible to directly invoke Gradle in your workflow, and the `actions/setup-java@v5` action provides a simple way to cache Gradle dependencies.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import * as dependencyGraph from '../../dependency-graph'
|
|||||||
|
|
||||||
import {parseArgsStringToArgv} from 'string-argv'
|
import {parseArgsStringToArgv} from 'string-argv'
|
||||||
import {
|
import {
|
||||||
BuildScanConfig,
|
DevelocityConfig,
|
||||||
CacheConfig,
|
CacheConfig,
|
||||||
DependencyGraphConfig,
|
DependencyGraphConfig,
|
||||||
DependencyGraphOption,
|
DependencyGraphOption,
|
||||||
@@ -25,7 +25,7 @@ export async function run(): Promise<void> {
|
|||||||
setActionId('gradle/actions/dependency-submission')
|
setActionId('gradle/actions/dependency-submission')
|
||||||
|
|
||||||
// Configure Gradle environment (Gradle User Home)
|
// Configure Gradle environment (Gradle User Home)
|
||||||
await setupGradle.setup(new CacheConfig(), new BuildScanConfig(), new WrapperValidationConfig())
|
await setupGradle.setup(new CacheConfig(), new DevelocityConfig(), new WrapperValidationConfig())
|
||||||
|
|
||||||
// Capture the enabled state of dependency-graph
|
// Capture the enabled state of dependency-graph
|
||||||
const originallyEnabled = process.env['GITHUB_DEPENDENCY_GRAPH_ENABLED']
|
const originallyEnabled = process.env['GITHUB_DEPENDENCY_GRAPH_ENABLED']
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as setupGradle from '../../setup-gradle'
|
|||||||
import * as provisioner from '../../execution/provision'
|
import * as provisioner from '../../execution/provision'
|
||||||
import * as dependencyGraph from '../../dependency-graph'
|
import * as dependencyGraph from '../../dependency-graph'
|
||||||
import {
|
import {
|
||||||
BuildScanConfig,
|
DevelocityConfig,
|
||||||
CacheConfig,
|
CacheConfig,
|
||||||
DependencyGraphConfig,
|
DependencyGraphConfig,
|
||||||
GradleExecutionConfig,
|
GradleExecutionConfig,
|
||||||
@@ -28,7 +28,7 @@ export async function run(): Promise<void> {
|
|||||||
setActionId('gradle/actions/setup-gradle')
|
setActionId('gradle/actions/setup-gradle')
|
||||||
|
|
||||||
// Configure Gradle environment (Gradle User Home)
|
// Configure Gradle environment (Gradle User Home)
|
||||||
await setupGradle.setup(new CacheConfig(), new BuildScanConfig(), new WrapperValidationConfig())
|
await setupGradle.setup(new CacheConfig(), new DevelocityConfig(), new WrapperValidationConfig())
|
||||||
|
|
||||||
// Configure the dependency graph submission
|
// Configure the dependency graph submission
|
||||||
await dependencyGraph.setup(new DependencyGraphConfig())
|
await dependencyGraph.setup(new DependencyGraphConfig())
|
||||||
|
|||||||
@@ -68,8 +68,14 @@ export async function getCacheService(cacheConfig: CacheConfig): Promise<CacheSe
|
|||||||
if (cacheConfig.isCacheDisabled()) {
|
if (cacheConfig.isCacheDisabled()) {
|
||||||
return new NoOpCacheService()
|
return new NoOpCacheService()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cacheService = await loadVendoredCacheService()
|
||||||
|
if (cacheConfig.isCacheLicenseAccepted()) {
|
||||||
|
return cacheService
|
||||||
|
}
|
||||||
|
|
||||||
await logCacheLicenseWarning()
|
await logCacheLicenseWarning()
|
||||||
return new LicenseWarningCacheService(await loadVendoredCacheService())
|
return new LicenseWarningCacheService(cacheService)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadVendoredCacheService(): Promise<CacheService> {
|
export async function loadVendoredCacheService(): Promise<CacheService> {
|
||||||
@@ -90,5 +96,5 @@ function findVendoredLibraryPath(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function logCacheLicenseWarning(): Promise<void> {
|
export async function logCacheLicenseWarning(): Promise<void> {
|
||||||
console.warn(CACHE_LICENSE_WARNING)
|
console.info(CACHE_LICENSE_WARNING)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,6 +166,11 @@ export class CacheConfig {
|
|||||||
getCacheExcludes(): string[] {
|
getCacheExcludes(): string[] {
|
||||||
return core.getMultilineInput('gradle-home-cache-excludes')
|
return core.getMultilineInput('gradle-home-cache-excludes')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isCacheLicenseAccepted(): boolean {
|
||||||
|
const dvConfig = new DevelocityConfig()
|
||||||
|
return dvConfig.getDevelocityAccessKey() !== '' || dvConfig.hasTermsOfUseAgreement()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum CacheCleanupOption {
|
export enum CacheCleanupOption {
|
||||||
@@ -229,7 +234,7 @@ export enum JobSummaryOption {
|
|||||||
OnFailure = 'on-failure'
|
OnFailure = 'on-failure'
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BuildScanConfig {
|
export class DevelocityConfig {
|
||||||
static DevelocityAccessKeyEnvVar = 'DEVELOCITY_ACCESS_KEY'
|
static DevelocityAccessKeyEnvVar = 'DEVELOCITY_ACCESS_KEY'
|
||||||
static GradleEnterpriseAccessKeyEnvVar = 'GRADLE_ENTERPRISE_ACCESS_KEY'
|
static GradleEnterpriseAccessKeyEnvVar = 'GRADLE_ENTERPRISE_ACCESS_KEY'
|
||||||
|
|
||||||
@@ -237,19 +242,19 @@ export class BuildScanConfig {
|
|||||||
return getBooleanInput('build-scan-publish') && this.verifyTermsOfUseAgreement()
|
return getBooleanInput('build-scan-publish') && this.verifyTermsOfUseAgreement()
|
||||||
}
|
}
|
||||||
|
|
||||||
getBuildScanTermsOfUseUrl(): string {
|
getTermsOfUseUrl(): string {
|
||||||
return core.getInput('build-scan-terms-of-use-url')
|
return core.getInput('build-scan-terms-of-use-url')
|
||||||
}
|
}
|
||||||
|
|
||||||
getBuildScanTermsOfUseAgree(): string {
|
getTermsOfUseAgree(): string {
|
||||||
return core.getInput('build-scan-terms-of-use-agree')
|
return core.getInput('build-scan-terms-of-use-agree')
|
||||||
}
|
}
|
||||||
|
|
||||||
getDevelocityAccessKey(): string {
|
getDevelocityAccessKey(): string {
|
||||||
return (
|
return (
|
||||||
core.getInput('develocity-access-key') ||
|
core.getInput('develocity-access-key') ||
|
||||||
process.env[BuildScanConfig.DevelocityAccessKeyEnvVar] ||
|
process.env[DevelocityConfig.DevelocityAccessKeyEnvVar] ||
|
||||||
process.env[BuildScanConfig.GradleEnterpriseAccessKeyEnvVar] ||
|
process.env[DevelocityConfig.GradleEnterpriseAccessKeyEnvVar] ||
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -290,12 +295,17 @@ export class BuildScanConfig {
|
|||||||
return new PluginRepositoryConfig()
|
return new PluginRepositoryConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasTermsOfUseAgreement(): boolean {
|
||||||
|
const develocityAccessKeySet = this.getDevelocityAccessKey() !== ''
|
||||||
|
const termsUrlSet =
|
||||||
|
this.getTermsOfUseUrl() === 'https://gradle.com/terms-of-service' ||
|
||||||
|
this.getTermsOfUseUrl() === 'https://gradle.com/help/legal-terms-of-use'
|
||||||
|
const termsAgreed = this.getTermsOfUseAgree() === 'yes'
|
||||||
|
return develocityAccessKeySet || (termsUrlSet && termsAgreed)
|
||||||
|
}
|
||||||
|
|
||||||
private verifyTermsOfUseAgreement(): boolean {
|
private verifyTermsOfUseAgreement(): boolean {
|
||||||
if (
|
if (!this.hasTermsOfUseAgreement()) {
|
||||||
(this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/terms-of-service' &&
|
|
||||||
this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/help/legal-terms-of-use') ||
|
|
||||||
this.getBuildScanTermsOfUseAgree() !== 'yes'
|
|
||||||
) {
|
|
||||||
core.warning(
|
core.warning(
|
||||||
`Terms of use at 'https://gradle.com/help/legal-terms-of-use' must be agreed in order to publish build scans.`
|
`Terms of use at 'https://gradle.com/help/legal-terms-of-use' must be agreed in order to publish build scans.`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {BuildScanConfig} from '../configuration'
|
import {DevelocityConfig} from '../configuration'
|
||||||
import {setupToken} from './short-lived-token'
|
import {setupToken} from './short-lived-token'
|
||||||
|
|
||||||
export async function setup(config: BuildScanConfig): Promise<void> {
|
export async function setup(config: DevelocityConfig): Promise<void> {
|
||||||
maybeExportVariable('DEVELOCITY_INJECTION_INIT_SCRIPT_NAME', 'gradle-actions.inject-develocity.init.gradle')
|
maybeExportVariable('DEVELOCITY_INJECTION_INIT_SCRIPT_NAME', 'gradle-actions.inject-develocity.init.gradle')
|
||||||
maybeExportVariable('DEVELOCITY_INJECTION_CUSTOM_VALUE', 'gradle-actions')
|
maybeExportVariable('DEVELOCITY_INJECTION_CUSTOM_VALUE', 'gradle-actions')
|
||||||
|
|
||||||
@@ -36,8 +36,8 @@ export async function setup(config: BuildScanConfig): Promise<void> {
|
|||||||
maybeExportVariable('DEVELOCITY_INJECTION_ENABLED', 'true')
|
maybeExportVariable('DEVELOCITY_INJECTION_ENABLED', 'true')
|
||||||
maybeExportVariable('DEVELOCITY_INJECTION_DEVELOCITY_PLUGIN_VERSION', '4.3.2')
|
maybeExportVariable('DEVELOCITY_INJECTION_DEVELOCITY_PLUGIN_VERSION', '4.3.2')
|
||||||
maybeExportVariable('DEVELOCITY_INJECTION_CCUD_PLUGIN_VERSION', '2.1')
|
maybeExportVariable('DEVELOCITY_INJECTION_CCUD_PLUGIN_VERSION', '2.1')
|
||||||
maybeExportVariable('DEVELOCITY_INJECTION_TERMS_OF_USE_URL', config.getBuildScanTermsOfUseUrl())
|
maybeExportVariable('DEVELOCITY_INJECTION_TERMS_OF_USE_URL', config.getTermsOfUseUrl())
|
||||||
maybeExportVariable('DEVELOCITY_INJECTION_TERMS_OF_USE_AGREE', config.getBuildScanTermsOfUseAgree())
|
maybeExportVariable('DEVELOCITY_INJECTION_TERMS_OF_USE_AGREE', config.getTermsOfUseAgree())
|
||||||
}
|
}
|
||||||
|
|
||||||
return setupToken(
|
return setupToken(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as httpm from '@actions/http-client'
|
import * as httpm from '@actions/http-client'
|
||||||
import {BuildScanConfig} from '../configuration'
|
import {DevelocityConfig} from '../configuration'
|
||||||
import {recordDeprecation} from '../deprecation-collector'
|
import {recordDeprecation} from '../deprecation-collector'
|
||||||
|
|
||||||
export async function setupToken(
|
export async function setupToken(
|
||||||
@@ -28,7 +28,7 @@ export async function setupToken(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function exportAccessKeyEnvVars(value: string): void {
|
function exportAccessKeyEnvVars(value: string): void {
|
||||||
;[BuildScanConfig.DevelocityAccessKeyEnvVar, BuildScanConfig.GradleEnterpriseAccessKeyEnvVar].forEach(key =>
|
;[DevelocityConfig.DevelocityAccessKeyEnvVar, DevelocityConfig.GradleEnterpriseAccessKeyEnvVar].forEach(key =>
|
||||||
core.exportVariable(key, value)
|
core.exportVariable(key, value)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -36,12 +36,14 @@ function exportAccessKeyEnvVars(value: string): void {
|
|||||||
function handleMissingAccessToken(): void {
|
function handleMissingAccessToken(): void {
|
||||||
core.warning(`Failed to fetch short-lived token for Develocity`)
|
core.warning(`Failed to fetch short-lived token for Develocity`)
|
||||||
|
|
||||||
if (process.env[BuildScanConfig.GradleEnterpriseAccessKeyEnvVar]) {
|
if (process.env[DevelocityConfig.GradleEnterpriseAccessKeyEnvVar]) {
|
||||||
// We do not clear the GRADLE_ENTERPRISE_ACCESS_KEY env var in v3, to let the users upgrade to DV 2024.1
|
// We do not clear the GRADLE_ENTERPRISE_ACCESS_KEY env var in v3, to let the users upgrade to DV 2024.1
|
||||||
recordDeprecation(`The ${BuildScanConfig.GradleEnterpriseAccessKeyEnvVar} env var is deprecated`)
|
recordDeprecation(`The ${DevelocityConfig.GradleEnterpriseAccessKeyEnvVar} env var is deprecated`)
|
||||||
}
|
}
|
||||||
if (process.env[BuildScanConfig.DevelocityAccessKeyEnvVar]) {
|
if (process.env[DevelocityConfig.DevelocityAccessKeyEnvVar]) {
|
||||||
core.warning(`The ${BuildScanConfig.DevelocityAccessKeyEnvVar} env var should be mapped to a short-lived token`)
|
core.warning(
|
||||||
|
`The ${DevelocityConfig.DevelocityAccessKeyEnvVar} env var should be mapped to a short-lived token`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {loadBuildResults, markBuildResultsProcessed} from './build-results'
|
|||||||
import {getCacheService} from './cache-service-loader'
|
import {getCacheService} from './cache-service-loader'
|
||||||
import {CacheOptions} from './cache-service'
|
import {CacheOptions} from './cache-service'
|
||||||
import {
|
import {
|
||||||
BuildScanConfig,
|
DevelocityConfig,
|
||||||
CacheConfig,
|
CacheConfig,
|
||||||
SummaryConfig,
|
SummaryConfig,
|
||||||
WrapperValidationConfig,
|
WrapperValidationConfig,
|
||||||
@@ -24,7 +24,7 @@ const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
|
|||||||
|
|
||||||
export async function setup(
|
export async function setup(
|
||||||
cacheConfig: CacheConfig,
|
cacheConfig: CacheConfig,
|
||||||
buildScanConfig: BuildScanConfig,
|
develocityConfig: DevelocityConfig,
|
||||||
wrapperValidationConfig: WrapperValidationConfig
|
wrapperValidationConfig: WrapperValidationConfig
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const userHome = await determineUserHome()
|
const userHome = await determineUserHome()
|
||||||
@@ -49,7 +49,7 @@ export async function setup(
|
|||||||
|
|
||||||
await wrapperValidator.validateWrappers(wrapperValidationConfig, getWorkspaceDirectory(), gradleUserHome)
|
await wrapperValidator.validateWrappers(wrapperValidationConfig, getWorkspaceDirectory(), gradleUserHome)
|
||||||
|
|
||||||
await buildScan.setup(buildScanConfig)
|
await buildScan.setup(develocityConfig)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user