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

Set up Android Github Action pipeline. Fixes #2892 #2893

Merged
merged 4 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,41 @@ jobs:
chmod +x codecov
./codecov

#
# Android build job
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI #2894
(I don't think it's necessary for this pipeline PR, but was inspired :) )

#
android:
runs-on: macos-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"

# Definition of the build matrix
strategy:
matrix:
java: [ 11 ]
entry:
- { mock-maker: 'mock-maker-default', member-accessor: 'member-accessor-default' }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to keep a 1-element matrix?
It could be fully inlined to the env var values?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually might want to introduce more API levels in the future, because they have different JVMs. See my comment on the issue, API 21 fails, while API 31 passes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think we could remove the mock-maker part

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we settled on level 26 as the minimum: https://github.com/mockito/mockito/blob/main/build.gradle#L102

Copy link
Contributor

Choose a reason for hiding this comment

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

For reference the official docs only list some new APIs, so even Android 8 doesn't support Java 11. However, as I understand with desugaring Java 11+ APIs can be used as low as API 1. This is of course not practical, I think an API 21 minimum would be enough. That said official full Java 11 support is only in 33.

Anyway, based on the info, starting with android-api: [26,27,28,29,30,31,33] would work.
(32 has no Java changes, it was a "feature drop", not given a major version, if it works, it could be included though)

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify, the matrix should only change the emulator version, the compile/target/minSdk should be hardcoded to highest/lowest values as Google recommends it (TL;DR: we have ~1 year to use the latest target, otherwise cannot publish).


# All build steps
steps:
- name: 1. Check out code
uses: actions/checkout@v3 # https://github.com/actions/checkout
reta marked this conversation as resolved.
Show resolved Hide resolved
with:
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci

- name: 2. Set up Java ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}

- name: 3. Run Android tests on Java ${{ matrix.java }} with ${{ matrix.entry.mock-maker }} and ${{ matrix.entry.member-accessor }}
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
script: ./gradlew :androidTest:connectedCheck --no-daemon --no-build-cache
TimvdLippe marked this conversation as resolved.
Show resolved Hide resolved
env:
MOCK_MAKER: ${{ matrix.entry.mock-maker }}
MEMBER_ACCESSOR: ${{ matrix.entry.member-accessor }}

#
# Release job, only for pushes to the main development branch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class BasicInstrumentedTests {
fun mockAndUseBasicClassUsingAnnotatedMock() {
val basicClass = BasicOpenClassReceiver(mockedViaAnnotationBasicOpenClass)
basicClass.callDependencyMethod()
throw Exception("java")
TimvdLippe marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
Expand Down