binary-compatibility-validator icon indicating copy to clipboard operation
binary-compatibility-validator copied to clipboard

BCV checks KLib ABIs under `build` dirs

Open Goooler opened this issue 1 year ago • 9 comments

Enable KLib ABI validation with the version 0.16.2 and dump KLib ABIs, apiCheck works on my local device but CI:

* What went wrong:
Execution failed for task ':compose-multiplatform:library:klibApiCheck'.
> API check failed for project library.

  --- /home/runner/work/Calendar/Calendar/compose-multiplatform/library/build/api/klib-all/extracted/library.klib.api
  +++ /home/runner/work/Calendar/Calendar/compose-multiplatform/library/build/api/klib/library.klib.api
  @@ -5,7 +5,7 @@
   // - Show manifest properties: true
   // - Show declarations: true
   
  -// Library unique name: <kizitonwose-calendar.compose-multiplatform:library>
  +// Library unique name: <Calendar.compose-multiplatform:library>
   final enum class com.kizitonwose.calendar.compose.heatmapcalendar/HeatMapWeekHeaderPosition : kotlin/Enum<com.kizitonwose.calendar.compose.heatmapcalendar/HeatMapWeekHeaderPosition> { // com.kizitonwose.calendar.compose.heatmapcalendar/HeatMapWeekHeaderPosition|null[0]
       enum entry End // com.kizitonwose.calendar.compose.heatmapcalendar/HeatMapWeekHeaderPosition.End|null[0]
       enum entry Start // com.kizitonwose.calendar.compose.heatmapcalendar/HeatMapWeekHeaderPosition.Start|null[0]
  @@ -364,6 +364,12 @@
       final fun toString(): kotlin/String // com.kizitonwose.calendar.data/WeekDateRange.toString|toString(){}[0]
   }

You can repro this issue at https://github.com/kizitonwose/Calendar/pull/566.

Goooler avatar Jul 24 '24 03:07 Goooler

@Goooler, the current klib-abi-validation pipeline extracts an ABI for supported targets from a file stored within the source's api-dir and writes a resulting file into build/api/klib-all/extracted/....

In your example, the first file is a file created by filtering out unsupported targets from an ABI file stored within project sources, and the second file is an ABI generated for the current revision:

  --- /home/runner/work/Calendar/Calendar/compose-multiplatform/library/build/api/klib-all/extracted/library.klib.api
  +++ /home/runner/work/Calendar/Calendar/compose-multiplatform/library/build/api/klib/library.klib.api

So there's nothing wrong in both files being stored in build dir.

The problem with the validation failing in CI seems to be caused by the rootProject.name property not being set in the kizitonwose/Calendar project. Unless the property set, Gradle will use the root directory name as a project name.

fzhinkin avatar Aug 12 '24 19:08 fzhinkin

Thanks! It works now.

Is this related to #257?

Goooler avatar Aug 13 '24 00:08 Goooler

Not sure, it should be just kizitonwose/Calendar’s misconfiguration. While #257 is a bug on BCV side

fzhinkin avatar Aug 13 '24 00:08 fzhinkin

rootProject.name is not necessary for every project, it's possible to cause this issue when we miss that.

Goooler avatar Aug 13 '24 00:08 Goooler

It's recommended to set rootProject.name as a name inferred from a directory name could be unstable (and the CI issue from the issue's summary is one example how lack of stability shows itself).

fzhinkin avatar Aug 13 '24 14:08 fzhinkin

Should we note this point in README?

Goooler avatar Aug 14 '24 00:08 Goooler

The failed tests from https://github.com/Kotlin/binary-compatibility-validator/pull/262#issuecomment-2247592185, they ref to the settings.gradle.kts already declare rootProject. See

https://github.com/Kotlin/binary-compatibility-validator/blob/18cd0df801cde896675b0a4b6fdf082e3eef33f7/src/functionalTest/resources/examples/gradle/settings/settings-name-testproject.gradle.kts#L1

Goooler avatar Aug 14 '24 08:08 Goooler

Should we note this point in README?

Yes, it definitely won't harm.

fzhinkin avatar Aug 15 '24 12:08 fzhinkin

I'm facing same issue, and even adding rootProject.name didn't help. Can it be because my project's name and inner module's name is same?

* What went wrong:
Execution failed for task ':inspektor:jvmApiCheck'.
> API check failed for project inspektor.
  --- /Users/runner/work/inspektor/inspektor/inspektor/api/jvm/inspektor.api
  +++ /Users/runner/work/inspektor/inspektor/inspektor/build/api/jvm/inspektor.api

Failing Run: https://github.com/ShreyashKore/inspektor/actions/runs/11087059708/job/30805337163 Project: https://github.com/ShreyashKore/inspektor

ShreyashKore avatar Sep 29 '24 08:09 ShreyashKore

As part of the migration of separate BCV functionality to Kotlin Gradle Plugin, the addition of new features to a separate plugin has been discontinued.

It will be developed a format that eliminates this problem there: https://youtrack.jetbrains.com/issue/KT-78009

shanshin avatar Jun 06 '25 13:06 shanshin