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

CURATOR-669. Integrate with ge.apache.org Gradle Enterprise server #459

Merged
merged 3 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Configure Gradle Enterprise integration
run: |
if [[ -n "${{ secrets.GE_ACCESS_TOKEN }}" ]]; then
echo "Configuring Gradle Enterprise for build"
cp .mvn/ge-extensions.xml .mvn/extensions.xml
echo "GRADLE_ENTERPRISE_ACCESS_KEY=${{ secrets.GE_ACCESS_TOKEN }}" >> $GITHUB_ENV
echo "GRADLE_ENTERPRISE_ACCESS_KEY has been configured"
else
echo "GRADLE_ENTERPRISE_ACCESS_KEY is not configured."
fi

- name: Cache Local Maven Repository
uses: actions/cache@v3
with:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ atlassian-ide-plugin.xml

# NetBeans specific files/directories
.nbattrs

# Gradle Enterprise
test-reports/
.mvn/.gradle-enterprise/
.mvn/extensions.xml
34 changes: 34 additions & 0 deletions .mvn/ge-extensions.xml
tisonkun marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>com.gradle</groupId>
<artifactId>gradle-enterprise-maven-extension</artifactId>
<version>1.16.3</version>
tisonkun marked this conversation as resolved.
Show resolved Hide resolved
</extension>
<extension>
<groupId>com.gradle</groupId>
<artifactId>common-custom-user-data-maven-extension</artifactId>
<version>1.11.1</version>
</extension>
</extensions>
46 changes: 46 additions & 0 deletions .mvn/gradle-enterprise-custom-user-data.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// Add Maven command line arguments
def mavenCommand = ''

if (System.env.MAVEN_CMD_LINE_ARGS) {
mavenCommand = "mvn ${System.env.MAVEN_CMD_LINE_ARGS}".toString()
buildScan.value('Maven command line', mavenCommand)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would be very careful capturing the entire Maven command line. You could imagine scenarios where a user passes in a secret as a system property, or possibly even typos that include secrets. Gradle Enterprise doesn't capture certain environment details for this reason.

Perhaps it would make more sense to capture specific details you may be interested in? For example, we already add a custom value for the skipTests setting. We also have samples to capture profiles as tags. This may actually make it easier to queries that combine the different values, rather than trying to construct queries that are considering the command line as a whole. It may also be more accurate, as capturing the value of configured properties would not only capture values passed in at the command line.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave it as is for now. If you have better config suggestions, feel free to patch the script based on this branch or after this patch gets merged.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. I'm trying to redact mvn command.

@tisonkun - should just be a matter of removing this if (System.env.MAVEN_CMD_LINE_ARGS) { ... } block

}

if (System.env.GITHUB_ACTIONS) {
if (session.goals.size() == 1 && session.goals[0] == 'initialize') {
// omit publishing build scan when the only goal is "initialize"
buildScan.publishOnDemand()
} else {
def jobName = System.env.GITHUB_JOB
buildScan.value('GitHub Actions Job name', jobName)
buildScan.value('GitHub Actions Event name', System.env.GITHUB_EVENT_NAME)
buildScan.value('GitHub Ref name', System.env.GITHUB_REF_NAME)
buildScan.value('GitHub Actor', System.env.GITHUB_ACTOR)
buildScan.link('GitHub Repository', "https://github.com/" + System.env.GITHUB_REPOSITORY)
buildScan.link('GitHub Commit', "https://github.com/" + System.env.GITHUB_REPOSITORY + "/commits/" + System.env.GITHUB_SHA)
buildScan.buildScanPublished { publishedBuildScan ->
new File(System.env.GITHUB_STEP_SUMMARY).withWriterAppend { out ->
out.println("\n[Gradle build scan for '${mavenCommand}' in ${jobName}](${publishedBuildScan.buildScanUri})\n")
}
}
}
}
49 changes: 49 additions & 0 deletions .mvn/gradle-enterprise.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<gradleEnterprise
xmlns="https://www.gradle.com/gradle-enterprise-maven" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.gradle.com/gradle-enterprise-maven https://www.gradle.com/schema/gradle-enterprise-maven.xsd">
<server>
<url>https://ge.apache.org</url>
<allowUntrusted>false</allowUntrusted>
</server>
<buildScan>
<capture>
<goalInputFiles>true</goalInputFiles>
<buildLogging>true</buildLogging>
<testLogging>true</testLogging>
</capture>
<backgroundBuildScanUpload>#{isFalse(env['GITHUB_ACTIONS'])}</backgroundBuildScanUpload>
<publish>ALWAYS</publish>
tisonkun marked this conversation as resolved.
Show resolved Hide resolved
<obfuscation>
<ipAddresses>#{{'0.0.0.0'}}</ipAddresses>
</obfuscation>
</buildScan>
<buildCache>
<local>
<enabled>#{isFalse(env['GITHUB_ACTIONS'])}</enabled>
</local>
<remote>
<enabled>false</enabled>
</remote>
</buildCache>
</gradleEnterprise>