Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTOR-8344 Enable build cache for settings plugins #4745

Merged
merged 3 commits into from
Mar 21, 2025

Conversation

osipxd
Copy link
Member

@osipxd osipxd commented Mar 21, 2025

Subsystem
Infrastructure

Motivation
KTOR-8344 Enable shared build cache for build-settings-logic

Solution
Enabled build cache for build-settings-logic.
This should reduce configuration times on CI by ~20 seconds (2 + 13 + 4) for all builds.

image

Also:

  • removed redundant build scan customizations as they're already done in common-custom-user-data-gradle-plugin.
  • enabled obfuscation for usernames and hostnames

@osipxd osipxd self-assigned this Mar 21, 2025
Copy link

coderabbitai bot commented Mar 21, 2025

Walkthrough

The pull request integrates and configures the Develocity plugin in the Gradle build settings. It adds a new plugin dependency with a specified version, sets a hardcoded server URL in the Develocity configuration, and introduces an isCIRun variable to control build caching behavior. Additionally, the changes remove files containing enrichment functions, command execution logic, and constant definitions. A commented property in the gradle configuration is also removed, and the plugin declaration in the root settings file has been updated.

Changes

File(s) Change Summary
build-settings-logic/settings.gradle.kts
build-settings-logic/src/main/kotlin/ktorbuild.develocity.settings.gradle.kts
Added Develocity plugin dependency (com.gradle.develocity version "3.17.6") and configuration block with a hardcoded server URL ("https://ge.jetbrains.com"). Introduced an isCIRun variable and modified build cache settings.
build-settings-logic/src/main/kotlin/customization.kt
build-settings-logic/src/main/kotlin/execute.kt
build-settings-logic/src/main/kotlin/params.kt
Removed files containing build scan metadata enrichment functions (enrichTeamCityData, enrichGitData), a command execution extension (execute), and constants/variables (e.g., DEVELOCITY_SERVER, GITHUB_REPO, TEAMCITY_URL, and isCIRun).
gradle.properties Removed commented-out lines related to Develocity build scan configuration and added new comments for customization guidance.
settings.gradle.kts Updated the plugin declaration from id("conventions-develocity") to id("ktorbuild.develocity").
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sorry, something went wrong.

@osipxd osipxd requested a review from Mr3zee March 21, 2025 10:23
@osipxd osipxd changed the title Enable build cache for settings plugins KTOR-8344 Enable build cache for settings plugins Mar 21, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e31697 and ff3ad8d.

📒 Files selected for processing (7)
  • build-settings-logic/settings.gradle.kts (2 hunks)
  • build-settings-logic/src/main/kotlin/customization.kt (0 hunks)
  • build-settings-logic/src/main/kotlin/execute.kt (0 hunks)
  • build-settings-logic/src/main/kotlin/ktorbuild.develocity.settings.gradle.kts (3 hunks)
  • build-settings-logic/src/main/kotlin/params.kt (0 hunks)
  • gradle.properties (0 hunks)
  • settings.gradle.kts (1 hunks)
💤 Files with no reviewable changes (4)
  • gradle.properties
  • build-settings-logic/src/main/kotlin/execute.kt
  • build-settings-logic/src/main/kotlin/params.kt
  • build-settings-logic/src/main/kotlin/customization.kt
🔇 Additional comments (8)
settings.gradle.kts (1)

10-12: Plugin ID Update: Replacing Deprecated Plugin
The plugin declaration on line 12 has been updated from the old conventions-develocity to ktorbuild.develocity. This change appears intentional for aligning with the new build cache strategy. Please double-check that all downstream configurations now reference the new plugin ID.

build-settings-logic/settings.gradle.kts (3)

5-7: New Develocity Plugin Dependency Added
A new plugin dependency (com.gradle.develocity version 3.17.6) has been introduced. This is aligned with the PR objective to use the develocity plugin for build caching. Everything looks good—just confirm that the version is validated against your CI requirements.


19-24: Consistent Develocity Configuration
The develocity block sets the server URL explicitly to "https://ge.jetbrains.com", with an inline comment noting that this should be in sync with the configuration in ktorbuild.develocity.settings.gradle.kts. This consistency is key; please ensure that any future changes in one of these files are mirrored in the other.


25-37: Build Cache Configuration Based on CI Environment
The introduction of the isCIRun variable—by checking for TEAMCITY_VERSION—and the conditional build cache settings are well implemented. Disabling the local cache on CI (lines 27-31) and enabling remote caching (lines 33-36) aligns with the goal of optimizing build times.

build-settings-logic/src/main/kotlin/ktorbuild.develocity.settings.gradle.kts (4)

2-3: Copyright Update
The copyright year has been updated from 2024 to 2025 on line 2. This is a standard update reflecting the current year.


12-13: CI Environment Variable Setup
The new variable isCIRun is introduced to determine if the build is running in a CI environment. Its usage here is consistent with the configuration in build-settings-logic/settings.gradle.kts.


18-20: Develocity Server Configuration Alignment
The develocity block now sets the server URL explicitly to "https://ge.jetbrains.com" (lines 18–19), maintaining consistency with the root settings file. This clarity helps prevent misconfigurations across environments.


45-56: Consistent Remote Build Cache Configuration
The build cache configuration in lines 45–56 mirrors the pattern established in the parent settings file. Disabling the local cache when running in a CI environment and setting remote cache properties accordingly is consistent and should provide the desired performance benefits.

import com.gradle.develocity.agent.gradle.DevelocityConfiguration
import org.gradle.api.initialization.Settings

fun Settings.enrichTeamCityData() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove all this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as they're already done in common-custom-user-data-gradle-plugin.

So now we have these values duplicated in build scans:
image

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
build-settings-logic/src/main/kotlin/ktorbuild.develocity.settings.gradle.kts (1)

14-20: Server Configuration and Initialization
In this segment, the develocity block sets up necessary parameters such as startParameter and scanJournal and defines a hardcoded server URL ("https://ge.jetbrains.com"). While this meets the current requirements, consider externalizing the server URL in the future if environmental flexibility is needed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff3ad8d and ddab0f5.

📒 Files selected for processing (2)
  • build-settings-logic/src/main/kotlin/ktorbuild.develocity.settings.gradle.kts (1 hunks)
  • gradle.properties (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • gradle.properties
🔇 Additional comments (8)
build-settings-logic/src/main/kotlin/ktorbuild.develocity.settings.gradle.kts (8)

7-10: Plugins Declaration: Well-Defined and Targeted
The plugins declared (com.gradle.develocity and com.gradle.common-custom-user-data-gradle-plugin) are appropriate for enabling the shared build cache and build scan functionalities as per the PR objectives.


12-12: CI Run Detection is Correctly Implemented
The variable isCIRun correctly detects the presence of the TEAMCITY_VERSION environment variable, enabling CI-specific logic throughout the configuration.


21-23: Build Scan Upload Behavior Based on CI Environment
Setting uploadInBackground to !isCIRun ensures that in CI environments, the build scan upload is handled synchronously. This aligns well with the intended CI behavior where immediate feedback is often preferable.


24-43: Obfuscation Logic for User Information
The obfuscation block uses a clear when clause to conditionally mask user details based on whether the build is running in CI or if overridden properties are provided. The logic is readable and correctly leverages Kotlin's null-safe functions.


45-48: File Fingerprint Capture Enabled
Enabling file fingerprint capture through fileFingerprints = true is a sound decision to enhance the integrity and traceability of the build scans.


49-51: Build Scan Publication Logging
Appending detailed scan information (including a timestamp, scan URI, and the start parameters) to a log file is an effective way to audit the build process. This will be beneficial for debugging and historical reference.


53-57: Conditional Publishing Control for Build Scans
The configuration for skipBuildScans uses the Gradle property "ktor.develocity.skipBuildScans" and converts it via .toBoolean(). Given Kotlin's null-safe extension for String?.toBoolean(), this approach is safe and concise. The subsequent publishing.onlyIf { !skipBuildScans } correctly applies this condition.


61-72: Build Cache Configuration for CI Optimization
The buildCache block is well structured: it disables local caching in CI by checking isCIRun and enables remote caching with push permissions accordingly. This directly supports the PR objective of reducing CI configuration times.

@osipxd osipxd requested a review from bjhham March 21, 2025 13:25
@osipxd osipxd enabled auto-merge (squash) March 21, 2025 13:27
@osipxd osipxd merged commit 8a8b186 into main Mar 21, 2025
16 of 18 checks passed
@osipxd osipxd deleted the osipxd/build-cache-for-settings-plugin branch March 21, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants