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

Klib validation failing on CI but not locally #199

Closed
JakeWharton opened this issue Mar 20, 2024 · 5 comments · Fixed by #200
Closed

Klib validation failing on CI but not locally #199

JakeWharton opened this issue Mar 20, 2024 · 5 comments · Fixed by #200
Assignees
Labels
bug Something isn't working klib

Comments

@JakeWharton
Copy link

* What went wrong:	
Execution failed for task ':redwood-layout-modifiers:klibApiMerge'.	
> java.io.FileNotFoundException: File does not exist: /Users/runner/work/redwood/redwood/redwood-layout-modifiers/build/api/js/redwood-layout-modifiers.klib.api	

Attempt 1

Attempt 2

Attempt 3

I have not been able to reproduce this locally on my Mac. I tried executing the same command (after a clean) with --max-workers=3 to match the core count of the CI machine but it always succeeds (5 attempts).

I also don't know why it's always this specific module and the JS target that fails. I apply it to ~40 modules in this build, most of which are multiplatform containing JS targets. Very weird.

It's possible the problem can be identified just from looking at the code of the plugin, but I don't have time to do that right now. I can try investigating more later tonight or tomorrow, but figured I'd file the issue first.

@fzhinkin fzhinkin self-assigned this Mar 20, 2024
@fzhinkin fzhinkin added bug Something isn't working klib labels Mar 20, 2024
@fzhinkin
Copy link
Collaborator

@JakeWharton thanks for reporting!

@fzhinkin
Copy link
Collaborator

There's nothing specific about JS target in this particular case, it just appears to be the first target to load a dump for merging.
For API build tasks, we're skipping a task if there are no sources associated with it (and :redwood-layout-modifiers is indeed "empty"), but all other tasks are not skipped and thus fail.

@JakeWharton
Copy link
Author

That module contains only generated sources, which are correctly picked up by the dump: https://github.com/cashapp/redwood/pull/1884/files#diff-01c56a8c31dca2ba8b0d2218624f995999da354e5ac75bc91877b5dbb6abd60c

The sources are produced by adding a Task to the source set here: https://github.com/cashapp/redwood/blob/0b99e1067cc61ee58b3560ac949bb83cba3bb506/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodGeneratorPlugin.kt#L106-L107. Adding the task directly means Gradle will automatically run the task before anyone can consume the source set. The task's @OutputDirectory has the files which are then included in the source set.

@JakeWharton
Copy link
Author

I tried adding the task to the source set as soon as possible (when the multiplatform plugin is applied), but it didn't change the outcome.

@lukellmann
Copy link

I get a similar exception on Windows for this project when klib validation is enabled here (by adding klib.enabled = true):

> Task :core:live-tests:klibApiMergeInferred FAILED                                                                                                                                                                                                                                                                           

FAILURE: Build failed with an exception.                                                                                                                                                                                                                                                                                      

* What went wrong:
Execution failed for task ':core:live-tests:klibApiMergeInferred'.
> java.io.FileNotFoundException: File does not exist: C:\...\kord\core\live-tests\build\api\js\live-tests.klib.api 

The relevant parts of the project layout look like this:

kord (root project, BCV plugin not applied)
|
+-- core (public api subproject, BCV plugin applied)
    |
    +-- live-tests (internal subproject, BCV plugin not applied)

It seems like BCV tries to find the .klib.api file for a subproject that won't ever create one because the BCV plugin isn't applied there.

The workaround I found is putting this into kord/core/build.gradle.kts:

apiValidation {
    ignoredProjects += "live-tests"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working klib
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants