Unverified Commit 1b6cac1f authored by Daz DeBoer's avatar Daz DeBoer Committed by GitHub
Browse files

Make it easy to publish to scans.gradle.com (#1045)

parents 75b3db10 90d7c1a0
Loading
Loading
Loading
Loading
+40 −3
Changes for .github/workflows/integ-test-inject-develocity.yml: 40 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -19,14 +19,15 @@ env:
  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:
  inject-develocity:
    env:
      DEVELOCITY_INJECTION_ENABLED: true
      DEVELOCITY_URL: https://ge.solutions-team.gradle.com
      DEVELOCITY_PLUGIN_VERSION: 3.16.1
      DEVELOCITY_CCUD_PLUGIN_VERSION: 1.12.1
      GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} # This env var has not (yet) been renamed/aliased in GE plugin 3.16.1

jobs:
  inject-develocity:
    strategy:
      matrix:
        gradle: [current, 7.6.2, 6.9.4, 5.6.4]
@@ -58,3 +59,39 @@ jobs:
      with:
        script: |
          core.setFailed('No Build Scan detected')   

  build-scan-publish:
    strategy:
      matrix:
        gradle: [current, 7.6.2, 6.9.4, 5.6.4]
    runs-on: ubuntu-latest
    steps:
    - name: Checkout sources
      uses: actions/checkout@v4
    - name: Download distribution if required
      uses: ./.github/actions/download-dist
    - name: Setup Java
      uses: actions/setup-java@v4
      with:
        distribution: temurin
        java-version: 8
    - name: Setup Gradle
      id: setup-gradle
      uses: ./
      with:
        cache-read-only: false # For testing, allow writing cache entries on non-default branches
        gradle-version: ${{ matrix.gradle }}
        build-scan-publish: true
        build-scan-terms-of-service-url: "https://gradle.com/terms-of-service"
        build-scan-terms-of-service-agree: "yes"
    - name: Run Gradle build
      id: gradle
      working-directory: .github/workflow-samples/no-ge
      run: gradle help
    - name: Check Build Scan url
      if: ${{ !steps.gradle.outputs.build-scan-url }}
      uses: actions/github-script@v7
      with:
        script: |
          core.setFailed('No Build Scan detected')   
+21 −5
Changes for README.md: 21 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -861,10 +861,26 @@ The `init-script` supports a number of additional configuration parameters that
## Publishing to scans.gradle.com

Develocity injection is designed to enable publishing of build scans to a Develocity instance,
and is not suitable for publishing to the public Build Scans instance (https://scans.gradle.com).
but is also useful for publishing to the public Build Scans instance (https://scans.gradle.com).

In order to publish Build Scans to scans.gradle.com, you need to:
- Apply the Develocity plugin to your build configuration ([see docs](https://docs.gradle.com/enterprise/get-started/#applying_the_plugin))
- Programmatically accept the Terms of Service for scans.gradle.com ([see docs](https://docs.gradle.com/enterprise/gradle-plugin/#connecting_to_scans_gradle_com))
- Execute the build with `--scan` or configure your build with `publishAlways()` ([see docs](https://docs.gradle.com/enterprise/get-started/#always_publishing_a_build_scan))
To publish to https://scans.gradle.com, you must specify in your workflow that you accept the [Gradle Terms of Service](https://gradle.com/terms-of-service).

```yaml
name: Run build and publish Build Scan

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Setup Gradle to publish build scans
      uses: gradle/gradle-build-action@v2
      with:
        build-scan-publish: true
        build-scan-terms-of-service-url: "https://gradle.com/terms-of-service"
        build-scan-terms-of-service-agree: "yes"

    - name: Run a Gradle build - a build scan will be published automatically
      run: ./gradlew build
```
+15
Changes for action.yml: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -82,6 +82,21 @@ inputs:
    description: Specifies the number of days to retain any artifacts generated by the action. If not set, the default retention settings for the repository will apply.
    required: false

  build-scan-publish:
    description: |
      Set to 'true' to automatically publish build results as a Build Scan on scans.gradle.com.
      For publication to succeed without user input, you must also provide values for `build-scan-terms-of-service-url` and 'build-scan-terms-of-service-agree'.
    required: false
    default: false

  build-scan-terms-of-service-url:
    description: The URL to the Build Scan® terms of service. This input must be set to 'https://gradle.com/terms-of-service'.
    required: false
  
  build-scan-terms-of-service-agree:
    description: Indicate that you agree to the Build Scan® terms of service. This input value must be "yes".
    required: false

  # DEPRECATED ACTION INPUTS
  arguments:
    description: Gradle command line arguments (supports multi-line input)
+74 −1
Changes for dist/main/index.js: 74 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -138544,6 +138544,65 @@ function loadBuildResults() {
exports.loadBuildResults = loadBuildResults;
/***/ }),
/***/ 85772:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.setup = void 0;
const core = __importStar(__nccwpck_require__(42186));
const input_params_1 = __nccwpck_require__(23885);
function setup() {
    if ((0, input_params_1.getBuildScanPublishEnabled)() && verifyTermsOfServiceAgreement()) {
        maybeExportVariable('DEVELOCITY_INJECTION_ENABLED', 'true');
        maybeExportVariable('DEVELOCITY_PLUGIN_VERSION', '3.16.1');
        maybeExportVariable('DEVELOCITY_CCUD_PLUGIN_VERSION', '1.12.1');
        maybeExportVariable('BUILD_SCAN_TERMS_OF_SERVICE_URL', (0, input_params_1.getBuildScanTermsOfServiceUrl)());
        maybeExportVariable('BUILD_SCAN_TERMS_OF_SERVICE_AGREE', (0, input_params_1.getBuildScanTermsOfServiceAgree)());
    }
}
exports.setup = setup;
function verifyTermsOfServiceAgreement() {
    if ((0, input_params_1.getBuildScanTermsOfServiceUrl)() !== 'https://gradle.com/terms-of-service' ||
        (0, input_params_1.getBuildScanTermsOfServiceAgree)() !== 'yes') {
        core.warning(`Terms of service must be agreed in order to publish build scans.`);
        return false;
    }
    return true;
}
function maybeExportVariable(variableName, value) {
    if (!process.env[variableName]) {
        core.exportVariable(variableName, value);
    }
}
/***/ }),
/***/ 47591:
@@ -140374,7 +140433,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
    return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.JobSummaryOption = exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphContinueOnFailure = exports.getDependencyGraphOption = exports.getPRCommentOption = exports.getJobSummaryOption = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.getCacheEncryptionKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
exports.JobSummaryOption = exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphContinueOnFailure = exports.getDependencyGraphOption = exports.getBuildScanTermsOfServiceAgree = exports.getBuildScanTermsOfServiceUrl = exports.getBuildScanPublishEnabled = exports.getPRCommentOption = exports.getJobSummaryOption = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.getCacheEncryptionKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(42186));
const string_argv_1 = __nccwpck_require__(19663);
function isCacheDisabled() {
@@ -140450,6 +140509,18 @@ function getPRCommentOption() {
    return parseJobSummaryOption('add-job-summary-as-pr-comment');
}
exports.getPRCommentOption = getPRCommentOption;
function getBuildScanPublishEnabled() {
    return getBooleanInput('build-scan-publish');
}
exports.getBuildScanPublishEnabled = getBuildScanPublishEnabled;
function getBuildScanTermsOfServiceUrl() {
    return core.getInput('build-scan-terms-of-service-url');
}
exports.getBuildScanTermsOfServiceUrl = getBuildScanTermsOfServiceUrl;
function getBuildScanTermsOfServiceAgree() {
    return core.getInput('build-scan-terms-of-service-agree');
}
exports.getBuildScanTermsOfServiceAgree = getBuildScanTermsOfServiceAgree;
function parseJobSummaryOption(paramName) {
    const val = core.getInput(paramName);
    switch (val.toLowerCase().trim()) {
@@ -141100,6 +141171,7 @@ const layout = __importStar(__nccwpck_require__(28182));
const params = __importStar(__nccwpck_require__(23885));
const dependencyGraph = __importStar(__nccwpck_require__(80));
const jobSummary = __importStar(__nccwpck_require__(87345));
const buildScan = __importStar(__nccwpck_require__(85772));
const build_results_1 = __nccwpck_require__(82107);
const cache_reporting_1 = __nccwpck_require__(66674);
const daemon_controller_1 = __nccwpck_require__(85146);
@@ -141123,6 +141195,7 @@ function setup() {
        yield caches.restore(userHome, gradleUserHome, cacheListener);
        core.saveState(CACHE_LISTENER, cacheListener.stringify());
        yield dependencyGraph.setup(params.getDependencyGraphOption());
        buildScan.setup();
    });
}
exports.setup = setup;
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

Loading