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

build: Add Gradle task to assemble module build harness #5137

Merged
merged 3 commits into from
Sep 10, 2023

Conversation

skaldarnar
Copy link
Member

@skaldarnar skaldarnar commented Sep 4, 2023

Contains

Trying to make some Jenkins magic 🪄 more explicit in producing a build artifact for the module build harness that we could publish somewhere and use it in module builds again.

Context

Info is taken from

https://github.com/MovingBlocks/ModuleJteConfig/blob/b8599916257184f1258da5ff209e9fb55c26863f/Jenkinsfile#L62-L63

and

Terasology/Jenkinsfile

Lines 55 to 65 in 43a7e05

archiveArtifacts '''
gradlew,
gradle/wrapper/*,
templates/build.gradle,
templates/module.logback-test.xml,
config/**,
facades/PC/build/distributions/Terasology.zip,
engine/build/resources/main/org/terasology/engine/version/versionInfo.properties,
natives/**,
build-logic/src/**,
build-logic/*.kts

How to Test

Module Build

For local testing, run the following in the engine repo, which should produce build/distributions/build-harness.zip.

./gradlew assembleBuildHarness

In a stand-alone checkout of a module (any module should work) extract the build-harness.zip file and try to run the Gradle build. For instance:

# in stand-alone module checkout
unzip ../Terasology/build/distributions/build-harness.zip 

# set project name and include plugin, see https://github.com/MovingBlocks/ModuleJteConfig/blob/b8599916257184f1258da5ff209e9fb55c26863f/Jenkinsfile#L62-L63
echo "rootProject.name = '$(basename "$PWD")'; includeBuild('build-logic');" > settings.gradle

./gradlew build

Engine Build

The config should be extracted as before in the engine. To test this, clean the config/ directory, then run one of the affected tasks and observe that :extractConfig is part of the dependencies and the configs are extracted properly.

For instance, you can run

git clean -fdx -- config
./gradlew checkstyleMain

Follow-up

  • build the module build harness in CI and archive the ZIP file in the Jenkins job
  • adjust the module build file to use the single build harness archive instead of copying files together
  • version the build harness properly and publish to artifactory (and consume from there)
  • (optional) implement a Github action to fetch the build harness from artifactory and build modules standalone
  • (optional) address the FIXME by revisiting the gradle plugins, how they are structured, what they depend on, etc.

@github-actions github-actions bot added the Category: Build/CI Requests, Issues and Changes targeting gradle, groovy, Jenkins, etc. label Sep 4, 2023
@skaldarnar
Copy link
Member Author

Tried in a Codespace, not working yet 😔

$ ./gradlew build

> Configure project :build-logic
This version of Gradle expects version '4.0.14' of the `kotlin-dsl` plugin but version '4.1.0' has been applied to project ':build-logic'. Let Gradle control the version of `kotlin-dsl` by removing any explicit `kotlin-dsl` version constraints from your build logic.
WARNING: Unsupported Kotlin plugin version.
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.8.20` that might work differently than in the requested version `1.9.0`.

FAILURE: Build failed with an exception.

* Where:
Build file '/workspaces/Health/build.gradle' line: 25

* What went wrong:
An exception occurred applying plugin request [id: 'terasology-module']
> Failed to apply plugin 'terasology-metrics'.
   > Task with path ':extractConfig' not found in root project 'Health'.

@skaldarnar
Copy link
Member Author

skaldarnar commented Sep 7, 2023

Okay,this failing locally is not a problem of the harness assembled here, but it also fails with current develop for module builds, see for instance Modules > H > Health#2.

Edit: The issue was introduced with the Gradle upgrade, 43a7e0 to be precise.

@skaldarnar
Copy link
Member Author

d1d59db should be a workaround for both #5137 (comment) and the failing builds for modules we have right now.

Thus, I propose to get this merged and then address the follow-ups as mentioned in OP.

@skaldarnar skaldarnar marked this pull request as ready for review September 7, 2023 21:31
jdrueckert
jdrueckert previously approved these changes Sep 7, 2023
Copy link
Member

@jdrueckert jdrueckert left a comment

Choose a reason for hiding this comment

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

LGTM

build.gradle Outdated Show resolved Hide resolved
Co-authored-by: jdrueckert <jd.rueckert@googlemail.com>
@skaldarnar skaldarnar merged commit 1ce6368 into develop Sep 10, 2023
10 checks passed
@skaldarnar skaldarnar deleted the topic/module-build-harness branch September 10, 2023 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Build/CI Requests, Issues and Changes targeting gradle, groovy, Jenkins, etc.
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants