Skip to content

Conversation

ribafish
Copy link
Member

@ribafish ribafish commented Jul 8, 2025

Added a Publish to Maven Local and Test with Locally Published Plugin job to Verify Build workflow. This will publish the latest changes to Maven Local, modify settings.gradle.kts to use the locally published plugin and run a regular build, effectively giving us a build, built with the latest changes of CCUD Gradle plugin.

I implemented it by modifying the CCUD version applied to the build to be dynamic (2+). I added this to the build-verification.yml workflow. If you feel this makes more sense to live separately, let me know.

Once this is merged, I will add a similar thing to CCUD Maven and sbt.

@ribafish ribafish requested a review from a team July 8, 2025 15:00
@ribafish ribafish changed the title Added selftest with pTML Add testing latest changes using Maven Local Jul 8, 2025
Copy link
Member

@jprinet jprinet left a comment

Choose a reason for hiding this comment

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

This certainly works 👍
I am just curious if you considered using a sample project using CCUD as an included build to avoid all the tedious publication process

Copy link
Member

@erichaagdev erichaagdev left a comment

Choose a reason for hiding this comment

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

Are you going to do the same for Maven too?

FTR, we do something similar to this for the convention samples:

https://github.com/gradle/develocity-build-config-samples/blob/main/.github/workflows/convention-develocity-gradle-plugin-verification.yml

@ribafish
Copy link
Member Author

ribafish commented Jul 9, 2025

This certainly works 👍 I am just curious if you considered using a sample project using CCUD as an included build to avoid all the tedious publication process

I have, but it kinda seemed nice to apply it to itself :D On a second thought, it might make more sense to have a sample project, esp as I'll do the same for CCUD Maven and sbt if/when this is merged, we just need to agree on what to do.

@ribafish
Copy link
Member Author

ribafish commented Jul 9, 2025

Actually, I created a sample project and was ready to open a different PR...but I'm not sure I'd include a sample project, in which we define mavenLocal and add ccud with a dynamic version... so, while this current way is more convoluted and hacky, it's still just a test. To me, the sample project should be the way it's supposed to be used. I'm happy to add a sample project, but I still think it shouldn't have mavenLocal and dynamic versions in it.

@ribafish ribafish requested review from erichaagdev and jprinet July 9, 2025 08:51
@jprinet
Copy link
Member

jprinet commented Jul 9, 2025

Actually, I created a sample project and was ready to open a different PR...but I'm not sure I'd include a sample project, in which we define mavenLocal and add ccud with a dynamic version... so, while this current way is more convoluted and hacky, it's still just a test. To me, the sample project should be the way it's supposed to be used. I'm happy to add a sample project, but I still think it shouldn't have mavenLocal and dynamic versions in it.

That's why I would recommend building the sample project with CCUD plugin as an included build, you would get it applied without the need to publish to Maven local, nor specifying the version

@ribafish
Copy link
Member Author

ribafish commented Jul 9, 2025

Actually, I created a sample project and was ready to open a different PR...but I'm not sure I'd include a sample project, in which we define mavenLocal and add ccud with a dynamic version... so, while this current way is more convoluted and hacky, it's still just a test. To me, the sample project should be the way it's supposed to be used. I'm happy to add a sample project, but I still think it shouldn't have mavenLocal and dynamic versions in it.

That's why I would recommend building the sample project with CCUD plugin as an included build, you would get it applied without the need to publish to Maven local, nor specifying the version

Hm, yes, that's also a possibility...but I still wouldn't call that a sample project 😄 more like integration test project..

@erichaagdev
Copy link
Member

I don't think we should confuse sample projects and projects used for testing. I also don't think we should use included builds as it's not how the plugin is consumed by users.

What about writing out a minimal build file to a temporary directory and running the test there? Something like this is all you need:

pluginManagement {
  repositories {
    mavenLocal()
    gradlePluginPortal()
  }
}

plugins {
  id("com.gradle.develocity") version "4.0.2"
  id("com.gradle.common-custom-user-data-gradle-plugin") version "..."
}

develocity {
  server = "https://ge.solutions-team.gradle.com"

Then run gradle help.

@ribafish ribafish force-pushed the gk/ghaSelfTest branch 3 times, most recently from d077948 to 6f5f5f2 Compare July 10, 2025 11:31
@ribafish
Copy link
Member Author

I don't think we should confuse sample projects and projects used for testing. I also don't think we should use included builds as it's not how the plugin is consumed by users.

What about writing out a minimal build file to a temporary directory and running the test there? Something like this is all you need:

Then run gradle help.

Good idea, probably the least convoluted and clearest among the discussed. I've implemented it, this is the run with it.

Copy link
Member

@erichaagdev erichaagdev left a comment

Choose a reason for hiding this comment

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

Approved, but left a few suggestions.

DISABLE_REQUIRED_SIGNING: true
- name: Create a test project
run: |
mkdir test-project
Copy link
Member

Choose a reason for hiding this comment

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

I suggest using runner.temp to avoid dirtying the working directory.

develocity-access-key: ${{ secrets.DV_SOLUTIONS_ACCESS_KEY }}
- name: Publish to maven local
id: publish-to-maven-local
run: ./gradlew clean publishToMavenLocal -Dgradle.cache.remote.push=false
Copy link
Member

Choose a reason for hiding this comment

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

Did you consider adding the publish to the previous job, then storing/restoring the artifact? That way we test the exact artifact that was build/tested and wouldn't require invoking Gradle here.

Comment on lines 50 to 53
repositories {
mavenLocal()
gradlePluginPortal()
}
Copy link
Member

Choose a reason for hiding this comment

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

Since this test job should fail if CCUD ends up resolved from the portal instead of maven local as we expect, we could declare that CCUD should be found exclusively in maven local

Comment on lines +32 to +85
name: Test with Locally Published Plugin
runs-on: ubuntu-latest
needs: verification
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.DV_SOLUTIONS_ACCESS_KEY }}
- name: Download plugin to maven local
uses: actions/download-artifact@v4
with:
name: common-custom-user-data-gradle-plugin
path: ~/.m2/repository/com/gradle
- name: Create a test project
run: |
echo """
pluginManagement {
repositories {
gradlePluginPortal()
exclusiveContent {
forRepository {
mavenLocal()
}
filter {
includeModule(\"com.gradle\", \"common-custom-user-data-gradle-plugin\")
includeModule(\"com.gradle.common-custom-user-data-gradle-plugin\", \"com.gradle.common-custom-user-data-gradle-plugin.gradle.plugin\")
}
}
}
}
plugins {
id(\"com.gradle.develocity\") version \"4+\"
id(\"com.gradle.common-custom-user-data-gradle-plugin\") version \"2+\"
}
develocity {
server = \"https://ge.solutions-team.gradle.com\"
}
rootProject.name = \"ccud-gradle-integration-test\"
""" > ${{ runner.temp }}/settings.gradle.kts
- name: Run a build with the locally published plugin
id: build-with-local-plugin
run: gradle help
working-directory: ${{ runner.temp }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

To resolve this issue, we should add an explicit permissions block at the root of the workflow and/or for specific jobs. Since the jobs in this workflow mainly interact with artifacts, Gradle, and Maven, the required permissions are minimal. For instance:

  1. Add contents: read to allow the workflow to read repository contents if necessary.
  2. Add other permissions only if required for the workflow to function correctly.

The permissions block can be added at the top level of the workflow file to apply to all jobs by default or specified individually for each job. In this case, we will add a permissions block at the root level to ensure all jobs share the same minimal permissions.


Suggested changeset 1
.github/workflows/build-verification.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build-verification.yml b/.github/workflows/build-verification.yml
--- a/.github/workflows/build-verification.yml
+++ b/.github/workflows/build-verification.yml
@@ -2,6 +2,9 @@
 
 on: [ push, pull_request, workflow_dispatch ]
 
+permissions:
+  contents: read
+
 jobs:
   verification:
     name: Verification
EOF
@@ -2,6 +2,9 @@

on: [ push, pull_request, workflow_dispatch ]

permissions:
contents: read

jobs:
verification:
name: Verification
Copilot is powered by AI and may make mistakes. Always verify output.
@ribafish ribafish merged commit a7f1903 into main Jul 14, 2025
9 checks passed
@ribafish ribafish deleted the gk/ghaSelfTest branch July 14, 2025 09:57
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.

4 participants