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

Running CI via GitHub actions #21

Merged
merged 6 commits into from
Oct 9, 2024
Merged

Running CI via GitHub actions #21

merged 6 commits into from
Oct 9, 2024

Conversation

stigi
Copy link
Member

@stigi stigi commented Oct 3, 2024

Change description

This PR reenables CI for the Android SDK. The previous CI setup was configured for CircleCI and wasn't running. Now things run again via GitHub Actions.

Workflows

Gradle Build and Tests

Builds and tests the SDKs and example app.

Doing a ./gradlew build also runs the linter, which currently fails, so I've added -x lint to exclude the linter. I will address the linter error in a seperate PR (#23).

linter error
  /Users/ullrich/Projects/magicbell/magicbell-android/sdk/build.gradle:15: Error: Google Play requires that apps target API level 33 or higher. [ExpiredTargetSdkVersion]
      targetSdk 31
      ~~~~~~~~~~~~

     Explanation for issues of type "ExpiredTargetSdkVersion":
     Configuring your app to target a recent API level ensures that users
     benefit from significant security and performance improvements, while still
     allowing your app to run on older Android versions (down to the
     minSdkVersion).

     To update your targetSdkVersion, follow the steps from "Meeting Google Play
     requirements for target API level",
     https://developer.android.com/distribute/best-practices/develop/target-sdk.
     html

     https://support.google.com/googleplay/android-developer/answer/113469#targetsdk
     https://developer.android.com/distribute/best-practices/develop/target-sdk.html

Instead of running only debug tests I opted for running all tests via ./gradlew test which runs testDebug and testRelease tasks in all targets (mostly sdk but also sdk-compose and example app if we add tests there).

The setup-gradle action will also manage build results cache, but only write to the cache from the default (main) branch.

The google-services.json file, which is needed to build the example app, is stored base64 encoded in the Github action secrets.

Gradle Dependency Submission

The PR also adds the dependency-submission action from the official gradle actions pack to support vulnerability tracking in our SDK via dependabot.

Fixing tests

The biggest challenge in this PR was debugging why tests were failing on CI, while they consistently passed when run locally. It turned out that the test assertions via coVerify(...) were flaky. They are used to verify how often a stub method was invoked from a kotlin co routine (aka, asynchronous). On my fast machine those asynchronous tasks weren't a problem. On the (presumably) slower CI machines the coVerify calls needed an optional timeout. I gave all a 1 second timeout which fixed the flakiness and let tests pass locally and on CI.

Test Plan

Test run, fail (I saw them fail a lot!) and test failures are reported in Checks and annotated to the PR.

Type of Change

  • Bug fix
  • Feature
  • Enhancement

Guidelines

  • A changeset is included, or the change is not noteworthy enough to warrant one

@stigi stigi force-pushed the ullrich/github-ci branch 18 times, most recently from f1c5bbf to 83dc303 Compare October 7, 2024 16:38
@stigi stigi force-pushed the ullrich/github-ci branch from 83dc303 to ccfd7e8 Compare October 7, 2024 16:41
@stigi stigi force-pushed the ullrich/github-ci branch from ccfd7e8 to 2c1c94a Compare October 7, 2024 16:43
@stigi stigi changed the title CI via GitHub actions Running CI via GitHub actions Oct 8, 2024
@stigi stigi requested a review from smeijer October 8, 2024 09:29
@stigi stigi marked this pull request as ready for review October 8, 2024 09:36
@stigi stigi merged commit d248dc9 into main Oct 9, 2024
2 checks passed
@stigi stigi deleted the ullrich/github-ci branch October 9, 2024 13:40
@stigi stigi self-assigned this Oct 15, 2024
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.

2 participants