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

ci: add binary-compatibility-validator plugin #176

Merged
merged 1 commit into from
Jul 2, 2024
Merged

ci: add binary-compatibility-validator plugin #176

merged 1 commit into from
Jul 2, 2024

Conversation

nicklasl
Copy link
Member

@nicklasl nicklasl commented Jul 2, 2024

This PR adds a validation step to ensure that we do not change the public API without noticing.

The gradle check step (runs on CI builds) will validate the current API of the classes in the gradle project against the checked in file (confidence/api/confidence.api or Provider/api/Provider.api). If it detects changes in the API, it will fail like this:
I added a String parameter to the flush function

> Task :Confidence:apiCheck FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Confidence:apiCheck'.
> API check failed for project Confidence.
  --- /Users/nicklasl/src/confidence/confidence-openfeature-provider-kotlin/Confidence/api/Confidence.api
  +++ /Users/nicklasl/src/confidence/confidence-openfeature-provider-kotlin/Confidence/build/api/Confidence.api
  @@ -35,7 +35,7 @@
        public final fun asyncFetch ()V
        public final fun awaitReconciliation (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
        public final fun fetchAndActivate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
  -     public fun flush ()V
  +     public fun flush (Ljava/lang/String;)V
        public fun getContext ()Ljava/util/Map;
        public final fun getFlag (Ljava/lang/String;Ljava/lang/Object;)Lcom/spotify/confidence/Evaluation;
        public final fun getValue (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;
  @@ -428,7 +428,7 @@
   }

   public abstract interface class com/spotify/confidence/EventSender : com/spotify/confidence/Contextual {
  -     public abstract fun flush ()V
  +     public abstract fun flush (Ljava/lang/String;)V
        public abstract fun stop ()V
        public abstract fun track (Lcom/spotify/confidence/EventProducer;)V
        public abstract fun track (Ljava/lang/String;Ljava/util/Map;)V

  You can run :Confidence:apiDump task to overwrite API declarations

If the change was intended, you would run ./gradlew confidence:apiDump to re-generate the "golden file" in the api/ folder and amend that file with your commit.

@nicklasl nicklasl marked this pull request as ready for review July 2, 2024 06:35
@nicklasl nicklasl changed the title feat: add binary-compatibility-validator plugin ci: add binary-compatibility-validator plugin Jul 2, 2024
Copy link

@andreas-karlsson andreas-karlsson left a comment

Choose a reason for hiding this comment

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

Nice!

```

## Binary compatibility validations
Copy link
Member

Choose a reason for hiding this comment

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

Nice with the added docs ⭐️

@nicklasl nicklasl merged commit 111e8bd into main Jul 2, 2024
4 checks passed
@nicklasl nicklasl deleted the api-dump branch July 2, 2024 12:36
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.

3 participants