OpenAPITools / OpenAPITools/openapi-generator

Build cache entry from openapi-generator-mill-plugin:surefire:test is not relocatable

Open
#23,110 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Context
  • The openapi-generator project is integrated with Develocity
  • Develocity provides build acceleration through its build cache feature
  • The cache key is based on the goal inputs
  • Surefire's test goal defines environmentVariables and testClasspathElements as goal inputs (among others)
Issue

The build cache usage is not optimal as the openapi-generator-mill-plugin:surefire:test goal cache entry can't be relocated.
A cache entry is considered relocatable if its output can be reused when the task is executed in a different location.

This is surfaced in a Develocity build scan comparison of 2 builds run from different locations:
Image

The goal's inputs have references to absolute paths:

  • environmentVariables: MILL_TEST_RESOURCE_DIR is set to a subfolder of ${project.basedir} here
  • testClasspathElements: openapi-generator/modules/openapi-generator-mill-plugin/target/classes/org/openapitools/generator/mill contains some generated classes with absolute paths in their definition
public interface OpenApiModule extends Module {
    [...]

    default Task.Command<BoxedUnit> validateOpenapiSpec(final String spec, final boolean recommend, final boolean failOnWarnings) {
        return new Task.Command(.MODULE$.Nil(), (items, ctx) -> {
            [...]
        }, [...], sourcecode.File..MODULE$.apply("<THIS_IS_AN_ABSOLUTE_PATH>/modules/openapi-generator-mill-plugin/src/main/scala/org/openapitools/generator/mill/OpenApiModule.scala"), [...]
Impact

The cache entries are populated in the Develocity cache node from CI, therefore remote cache hit can't happen for local developers.
In my experience, the goal duration takes around 5 seconds. When possible, this wasted time could be almost eliminated.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/openapi-generator-mill-plugin/pom.xml around line 171 and inspect the surefire:test inputs, especially MILL_TEST_RESOURCE_DIR. Then inspect the generated classes under target/classes/org/openapitools/generator/mill and the Scala source path shown in the issue; done means the goal's cache entry is relocatable across build locations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.