Repository navigation
ci: report Java to Kotlin migration progress on pull requests #850
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |
| contents: read | ||
| pull-requests: read | ||
| checks: write | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| # Code quality checks | ||
|
|
@@ -247,6 +247,94 @@ | |
| name: "api-compat-reports" | ||
| path: build/api-compat/** | ||
|
|
||
| kotlin-migration-progress: | ||
| name: "Kotlin Migration Progress" | ||
| # Posts the Java-to-Kotlin conversion numbers on every pull request. The last step fails | ||
| # when a pull request adds Java to the published modules without the allow-new-java label. | ||
| if: github.event_name == 'pull_request' | ||
| timeout-minutes: 10 | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| env: | ||
| COMMENT_IDENTIFIER: "<!-- kotlin-migration-progress -->" | ||
| steps: | ||
| # The default pull_request ref is the merge result; see the size-report job below for why | ||
| # that is the right side to measure and what happens on a conflicted pull request. | ||
| - name: "Checkout PR head" | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - name: "Checkout base branch" | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| ref: ${{ github.event.pull_request.base.sha }} | ||
| path: base | ||
| - name: "Test the progress script" | ||
| run: python3 -m unittest scripts/test_kotlin_migration_progress.py | ||
| - name: "Measure head and base" | ||
| id: measure | ||
| run: | | ||
| set -euo pipefail | ||
| read_metric() { grep "^$2=" "$1" | cut -d= -f2; } | ||
| python3 scripts/kotlin_migration_progress.py --format env > "${RUNNER_TEMP}/head.env" | ||
| python3 scripts/kotlin_migration_progress.py > "${RUNNER_TEMP}/head.md" | ||
| # The base is measured with the head's facade list, so editing the list cannot masquerade as progress. | ||
| python3 scripts/kotlin_migration_progress.py --root base --facades scripts/kotlin-migration-facades.txt --format env > "${RUNNER_TEMP}/base.env" | ||
| head_left=$(read_metric "${RUNNER_TEMP}/head.env" JAVA_LEFT_LOC) | ||
| base_left=$(read_metric "${RUNNER_TEMP}/base.env" JAVA_LEFT_LOC) | ||
| head_java=$(read_metric "${RUNNER_TEMP}/head.env" JAVA_LOC) | ||
| base_java=$(read_metric "${RUNNER_TEMP}/base.env" JAVA_LOC) | ||
| delta_left=$((head_left - base_left)) | ||
| delta_java=$((head_java - base_java)) | ||
| if [ "${delta_left}" -lt 0 ]; then | ||
| headline="This pull request converts **$((-delta_left)) lines** of Java to Kotlin." | ||
| elif [ "${delta_java}" -gt 0 ]; then | ||
| headline=":warning: This pull request **adds ${delta_java} lines** of Java to the published modules." | ||
| else | ||
| headline="No change to the Java left to convert." | ||
| fi | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Headline misreports when Java-left increases silentlyLow Severity The headline logic has a gap: when Additional Locations (1)Reviewed by Cursor Bugbot for commit e31d469. Configure here. |
||
| { | ||
| echo "${COMMENT_IDENTIFIER}" | ||
| echo "### Kotlin migration progress" | ||
| echo | ||
| echo "${headline}" | ||
| echo | ||
| cat "${RUNNER_TEMP}/head.md" | ||
| } > "${RUNNER_TEMP}/comment.md" | ||
| cat "${RUNNER_TEMP}/comment.md" >> "${GITHUB_STEP_SUMMARY}" | ||
| echo "delta_java=${delta_java}" >> "${GITHUB_OUTPUT}" | ||
| # A pull_request from a fork gets a read-only token, so commenting would 403. | ||
| - name: "Find existing comment" | ||
| id: existing | ||
| if: github.event.pull_request.head.repo.full_name == github.repository | ||
| uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4 | ||
| with: | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| comment-author: "github-actions[bot]" | ||
| body-includes: ${{ env.COMMENT_IDENTIFIER }} | ||
| - name: "Create or update PR comment" | ||
| if: github.event.pull_request.head.repo.full_name == github.repository | ||
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 | ||
| with: | ||
| comment-id: ${{ steps.existing.outputs.comment-id }} | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| edit-mode: replace | ||
| body-path: ${{ runner.temp }}/comment.md | ||
| - name: "Ratchet: no new Java in the published modules" | ||
| if: > | ||
| steps.measure.outputs.delta_java > 0 && | ||
| !contains(github.event.pull_request.labels.*.name, 'allow-new-java') | ||
| env: | ||
| DELTA_JAVA: ${{ steps.measure.outputs.delta_java }} | ||
| run: | | ||
| echo "This pull request adds ${DELTA_JAVA} lines of Java to android-core or android-kit-base." >&2 | ||
| echo "New code in these modules is written in Kotlin. If the Java is unavoidable, add the" >&2 | ||
| echo "allow-new-java label and explain why in the description." >&2 | ||
| exit 1 | ||
|
|
||
| automerge-dependabot: | ||
| name: "Save PR Number for Dependabot Automerge" | ||
| if: github.event_name == 'pull_request' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # Java files that stay Java by design for the duration of the migration. | ||
| # | ||
| # These declare the public API that customers and kit authors compile against | ||
| # (see docs/kotlin-migration/PLAYBOOK.md, "Scope"), plus package-info.java, | ||
| # which has no Kotlin equivalent. scripts/kotlin_migration_progress.py counts | ||
| # them separately so that "Java left to convert" can honestly reach zero. | ||
| # | ||
| # Adding a file here is an API-surface decision that needs a maintainer's | ||
| # review, not just the author's. One repository-relative path per line. | ||
| android-core/src/main/java/com/mparticle/AttributionError.java | ||
| android-core/src/main/java/com/mparticle/AttributionListener.java | ||
| android-core/src/main/java/com/mparticle/AttributionResult.java | ||
| android-core/src/main/java/com/mparticle/BaseEvent.java | ||
| android-core/src/main/java/com/mparticle/Configuration.java | ||
| android-core/src/main/java/com/mparticle/MPEvent.java | ||
| android-core/src/main/java/com/mparticle/MPReceiver.java | ||
| android-core/src/main/java/com/mparticle/MPService.java | ||
| android-core/src/main/java/com/mparticle/MParticle.java | ||
| android-core/src/main/java/com/mparticle/MParticleOptions.java | ||
| android-core/src/main/java/com/mparticle/MParticleTask.java | ||
| android-core/src/main/java/com/mparticle/SdkListener.java | ||
| android-core/src/main/java/com/mparticle/Session.java | ||
| android-core/src/main/java/com/mparticle/commerce/CommerceEvent.java | ||
| android-core/src/main/java/com/mparticle/commerce/Impression.java | ||
| android-core/src/main/java/com/mparticle/commerce/Product.java | ||
| android-core/src/main/java/com/mparticle/commerce/Promotion.java | ||
| android-core/src/main/java/com/mparticle/commerce/TransactionAttributes.java | ||
| android-core/src/main/java/com/mparticle/commerce/package-info.java | ||
| android-core/src/main/java/com/mparticle/consent/CCPAConsent.java | ||
| android-core/src/main/java/com/mparticle/consent/ConsentInstance.java | ||
| android-core/src/main/java/com/mparticle/consent/ConsentState.java | ||
| android-core/src/main/java/com/mparticle/consent/GDPRConsent.java | ||
| android-core/src/main/java/com/mparticle/consent/package-info.java | ||
| android-core/src/main/java/com/mparticle/identity/AliasRequest.java | ||
| android-core/src/main/java/com/mparticle/identity/AliasResponse.java | ||
| android-core/src/main/java/com/mparticle/identity/BaseIdentityTask.java | ||
| android-core/src/main/java/com/mparticle/identity/IdentityApi.java | ||
| android-core/src/main/java/com/mparticle/identity/IdentityApiRequest.java | ||
| android-core/src/main/java/com/mparticle/identity/IdentityApiResult.java | ||
| android-core/src/main/java/com/mparticle/identity/IdentityHttpResponse.java | ||
| android-core/src/main/java/com/mparticle/identity/IdentityStateListener.java | ||
| android-core/src/main/java/com/mparticle/identity/MParticleUser.java | ||
| android-core/src/main/java/com/mparticle/identity/TaskFailureListener.java | ||
| android-core/src/main/java/com/mparticle/identity/TaskSuccessListener.java | ||
| android-core/src/main/java/com/mparticle/identity/package-info.java | ||
| android-core/src/main/java/com/mparticle/internal/package-info.java | ||
| android-core/src/main/java/com/mparticle/media/MPMediaAPI.java | ||
| android-core/src/main/java/com/mparticle/media/MediaCallbacks.java | ||
| android-core/src/main/java/com/mparticle/media/package-info.java | ||
| android-core/src/main/java/com/mparticle/messaging/InstanceIdService.java | ||
| android-core/src/main/java/com/mparticle/messaging/MPMessagingAPI.java | ||
| android-core/src/main/java/com/mparticle/messaging/MPMessagingRouter.java | ||
| android-core/src/main/java/com/mparticle/messaging/MessagingConfigCallbacks.java | ||
| android-core/src/main/java/com/mparticle/messaging/ProviderCloudMessage.java | ||
| android-core/src/main/java/com/mparticle/messaging/PushAnalyticsReceiver.java | ||
| android-core/src/main/java/com/mparticle/messaging/PushAnalyticsReceiverCallback.java | ||
| android-core/src/main/java/com/mparticle/messaging/package-info.java | ||
| android-core/src/main/java/com/mparticle/networking/BaseNetworkConnection.java | ||
| android-core/src/main/java/com/mparticle/networking/Certificate.java | ||
| android-core/src/main/java/com/mparticle/networking/DomainMapping.java | ||
| android-core/src/main/java/com/mparticle/networking/MPConnection.java | ||
| android-core/src/main/java/com/mparticle/networking/MPUrl.java | ||
| android-core/src/main/java/com/mparticle/networking/NetworkOptions.java | ||
| android-core/src/main/java/com/mparticle/package-info.java | ||
| android-core/src/main/java/com/mparticle/segmentation/Segment.java | ||
| android-core/src/main/java/com/mparticle/segmentation/SegmentListener.java | ||
| android-core/src/main/java/com/mparticle/segmentation/SegmentMembership.java | ||
| android-core/src/main/java/com/mparticle/segmentation/package-info.java | ||
| android-kit-base/src/main/java/com/mparticle/kits/CommerceEventUtils.java | ||
| android-kit-base/src/main/java/com/mparticle/kits/FilteredIdentityApiRequest.java | ||
| android-kit-base/src/main/java/com/mparticle/kits/FilteredMParticleUser.java | ||
| android-kit-base/src/main/java/com/mparticle/kits/KitIntegration.java | ||
| android-kit-base/src/main/java/com/mparticle/kits/KitUtils.java | ||
| android-kit-base/src/main/java/com/mparticle/kits/ReportingMessage.java |


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Headline hides warning when ratchet will fire
Low Severity
The headline branches on
delta_left(non-facade Java) first, but the ratchet checksdelta_java(all Java including facades). Whendelta_left < 0anddelta_java > 0— e.g., a PR converts some non-facade Java while also growing a facade file — the headline cheerfully says "converts N lines" while the ratchet step fails the job. The PR comment gives no hint that the ratchet will fire, creating a confusing disconnect between the sticky comment and the red CI status.Additional Locations (1)
.github/workflows/pull-request.yml#L313-L317Reviewed by Cursor Bugbot for commit 6ade310. Configure here.