-
Notifications
You must be signed in to change notification settings - Fork 640
Fix part of #6106: Implement generate changelog workflow and update bazel setup step #6341
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
4aa8470
Add VertexAiClient interface and FakeVertexAiClient for changelog gen…
Sandesh282 14bee6f
Add GoogleVertexAiClient: production Vertex AI REST implementation
Sandesh282 8e13e92
Add GenerateChangelogs script and Bazel targets for automated changel…
Sandesh282 0bf63b8
Fix: remove unused kt_jvm_binary from release/BUILD.bazel load statement
Sandesh282 9814e60
minor fix
Sandesh282 a07aac8
Add unit tests for GenerateChangelogs script
Sandesh282 368ffc3
Fix mutable companion apiBaseUrl; add GoogleVertexAiClientTest
Sandesh282 c6af637
Add gh pr create arg assertions to GenerateChangelogsTest
Sandesh282 510cb3e
Fix ktlint blank line violations in GenerateChangelogsTest
Sandesh282 3161be3
Exempt VertexAiClient and FakeVertexAiClient from test file check
Sandesh282 e6bac62
Move FakeVertexAiClient to src/javatests; exempt VertexAiClient inter…
Sandesh282 6ee5859
Fix buildifier blank lines in release BUILD.bazel
Sandesh282 f583f28
Add FakeVertexAiClientTest to satisfy test file presence check
Sandesh282 8985c0e
move FakeVertexAiClient to prod source set to fix test file presence …
Sandesh282 f95b6d3
remove unused kt_jvm_library from javatests BUILD load statement
Sandesh282 66120f5
apply buildifier reformat to javatests BUILD
Sandesh282 aa6d3e3
add generate_changelog.yml workflow triggered on version.bzl push
Sandesh282 1136d88
Address reviewer comments: fix action pins, Closes→Fix/Fixes, cleanup…
Sandesh282 ab14f99
Add target_version input to workflow_dispatch
Sandesh282 cdd68bc
Wire target_version input to TARGET_VERSION env var in script step
Sandesh282 53c0ee2
Add set-up-android-bazel-build-environment and Bazel 6.5.0 version pin
Sandesh282 6ece400
add git fetch command
Sandesh282 302b027
Use oppia-android-automation-env (no approval gate) for changelog wor…
Sandesh282 4b67051
Merge upstream/develop into pr2.2 (pr2.1 landed)
Sandesh282 bf29ef0
Clarify secrets setup; drop automated-changelog label; delete 0.18.md…
Sandesh282 422044a
Update Set up Bazel step
Sandesh282 3eed5c3
Address review: use dedicated changelog SA, fix release branch refs t…
Sandesh282 de8a9af
Fix ktlint: wrap long gitMergeBase call
Sandesh282 cfddd58
Fix ktlint: wrap gitMergeBase args
Sandesh282 8efcd23
Update Bazel setup step
Sandesh282 6317a13
Address review: trim overinflated docstrings in generate_changelog.yml
Sandesh282 5dbd4e4
Add 0.18 and 0.18_alpha changelogs from upstream develop
Sandesh282 1a489e2
Address review
Sandesh282 d73380f
minor fix
Sandesh282 8a045e4
Fix KDoc placement: move private constants before KDoc block
Sandesh282 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # Triggered when a version-bump PR is merged to develop (path filter: version.bzl). | ||
| # Runs the GenerateChangelogs Kotlin script, which: | ||
| # 1. Reads the new MINOR_VERSION from version.bzl and derives the *previous* version | ||
| # (e.g. 0.17->0.18 bump generates the changelog for 0.17). | ||
| # 2. Collects all PRs merged into develop between the two most recent release branches. | ||
| # 3. Parses "Fixes #NNNN" / "Closes #NNNN" references to surface issue titles. | ||
|
adhiamboperes marked this conversation as resolved.
Outdated
|
||
| # 4. Calls Vertex AI (Gemini) to produce a 2-3 sentence user-facing changelog summary. | ||
| # 5. Writes config/changelogs/<major>.<minor>.md and opens a PR on develop for review. | ||
| # | ||
| # If the Vertex AI call fails (timeout, quota, API error), the workflow still creates the | ||
| # PR with a raw commit list and an <!-- LLM generation failed --> marker. The release | ||
| # coordinator then writes the summary manually. | ||
| # | ||
| # Can also be triggered manually via workflow_dispatch to test or regenerate a changelog. | ||
| # | ||
| # Note: this workflow authenticates to GCP to call the Vertex AI API. The environment | ||
| # (oppia-android-release-env) must NOT have required reviewers configured, since the | ||
| # workflow is triggered automatically on every version.bzl push. If required reviewers | ||
| # are needed for other workflows in that environment, consider creating a separate | ||
| # non-gated environment for changelog generation (e.g. oppia-android-automation-env). | ||
|
adhiamboperes marked this conversation as resolved.
Outdated
|
||
|
|
||
| name: Generate Changelog | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - develop | ||
| paths: | ||
| - 'version.bzl' | ||
| workflow_dispatch: | ||
|
adhiamboperes marked this conversation as resolved.
|
||
|
|
||
| # Only one changelog generation may run at a time. An in-flight run is never cancelled | ||
| # (cancel-in-progress: false) so that a rapid double-push to version.bzl does not leave | ||
| # a half-committed changelog branch in an inconsistent state. | ||
| concurrency: | ||
| group: generate-changelog | ||
|
adhiamboperes marked this conversation as resolved.
|
||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| generate_changelog: | ||
| name: Generate Changelog | ||
| runs-on: ubuntu-24.04 | ||
| environment: oppia-android-release-env | ||
| permissions: | ||
| id-token: write # Required for Workload Identity Federation (Vertex AI auth). | ||
| contents: write # Required so the script can push the changelog branch. | ||
| pull-requests: write # Required so the script can open the PR via gh. | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 | ||
|
adhiamboperes marked this conversation as resolved.
Outdated
|
||
| with: | ||
| # Full history is required: the script uses `git log` to collect commits between | ||
|
adhiamboperes marked this conversation as resolved.
Outdated
|
||
| # release branches and needs the complete DAG to find merge bases correctly. | ||
| fetch-depth: 0 | ||
|
|
||
| # Configure a bot identity so that the commit the script creates on the changelog | ||
| # branch is attributed to github-actions[bot] rather than an arbitrary user. | ||
| - name: Configure git identity | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
|
adhiamboperes marked this conversation as resolved.
adhiamboperes marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Allow the script to `git push` the changelog branch and `gh pr create` without a | ||
| # personal access token. The built-in GITHUB_TOKEN is sufficient here because: | ||
| # - contents: write allows pushing a new branch. | ||
| # - pull-requests: write allows opening the PR. | ||
| - name: Configure git remote credentials | ||
| run: | | ||
| git remote set-url origin \ | ||
| https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | ||
|
|
||
| - name: Authenticate to GCP via Workload Identity Federation | ||
| uses: google-github-actions/auth@c200f3691d83b41bf9bbd8638997a462592937ed | ||
|
adhiamboperes marked this conversation as resolved.
Outdated
|
||
| with: | ||
| workload_identity_provider: ${{ secrets.WIF_PROVIDER }} | ||
|
adhiamboperes marked this conversation as resolved.
|
||
| service_account: ${{ secrets.GCP_RELEASE_SERVICE_ACCOUNT }} | ||
|
adhiamboperes marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Set up Google Cloud SDK | ||
| uses: google-github-actions/setup-gcloud@e427ad8a34f8676edf47cf7d7925499adf3eb74f | ||
|
|
||
| # Obtain a short-lived OAuth2 access token for the WIF-impersonated service account. | ||
| # GenerateChangelogs passes this as the Bearer token when calling the Vertex AI API. | ||
| - name: Get and mask GCP access token | ||
| run: | | ||
| ACCESS_TOKEN="$(gcloud auth print-access-token)" | ||
| echo "::add-mask::$ACCESS_TOKEN" | ||
| echo "GCP_ACCESS_TOKEN=$ACCESS_TOKEN" >> "$GITHUB_ENV" | ||
|
|
||
| # The GenerateChangelogs script is a pure Kotlin script with no Android resources. | ||
| # The Android build environment (NDK, SDK, etc.) is not needed here. | ||
|
adhiamboperes marked this conversation as resolved.
Outdated
|
||
| - name: Set up Bazel | ||
| uses: bazel-contrib/setup-bazel@8cb04a772ab4c1eb984e9c1b493a182e96c5e425 | ||
| with: | ||
| bazelisk-cache: true | ||
|
adhiamboperes marked this conversation as resolved.
|
||
|
|
||
| # Run the GenerateChangelogs script. It will: | ||
| # - Determine the version to generate for from version.bzl. | ||
| # - Collect commits between the two newest release branches. | ||
| # - Call Vertex AI and write config/changelogs/<version>.md. | ||
| # - Push the automated/changelog-<version> branch and open a PR. | ||
| # | ||
| # The GITHUB_TOKEN env var is picked up by the `gh` CLI (used internally by the | ||
| # script for `gh pr create`). GCP_PROJECT, GCP_LOCATION, and VERTEX_MODEL are | ||
| # non-sensitive configuration values stored as repository variables | ||
| # (Settings -> Variables -> Actions). | ||
|
adhiamboperes marked this conversation as resolved.
Outdated
|
||
| - name: Generate changelog and open PR | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| bazel run //scripts:generate_changelogs -- \ | ||
| "$(pwd)" \ | ||
| "${{ vars.GCP_PROJECT }}" \ | ||
| "${{ vars.GCP_LOCATION }}" \ | ||
| "${{ vars.VERTEX_MODEL }}" \ | ||
| "$GCP_ACCESS_TOKEN" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
scripts/src/java/org/oppia/android/scripts/release/FakeVertexAiClient.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package org.oppia.android.scripts.release | ||
|
|
||
| /** | ||
| * In-memory fake implementation of [VertexAiClient] for use in unit tests. | ||
| * | ||
| * By default, [generateText] returns [defaultResponse]. Tests can simulate an LLM failure by | ||
| * setting [shouldFail] to `true`, which causes the next call to throw an [IllegalStateException]. | ||
| * The flag resets to `false` after each thrown exception so that subsequent calls succeed again | ||
| * (unless re-set). All prompts received are recorded in [receivedPrompts] for assertion. | ||
| * | ||
| * @property defaultResponse the text returned by [generateText] when [shouldFail] is false | ||
| */ | ||
| class FakeVertexAiClient( | ||
| private val defaultResponse: String = "Fake generated changelog summary." | ||
| ) : VertexAiClient { | ||
|
|
||
| /** Whether the next call to [generateText] should throw to simulate an LLM failure. */ | ||
| var shouldFail = false | ||
|
|
||
| /** All prompts passed to [generateText], in call order. */ | ||
| val receivedPrompts = mutableListOf<String>() | ||
|
|
||
| override fun generateText(prompt: String): String { | ||
| receivedPrompts += prompt | ||
| if (shouldFail) { | ||
| shouldFail = false | ||
| error("FakeVertexAiClient: simulated Vertex AI failure") | ||
| } | ||
| return defaultResponse | ||
| } | ||
|
|
||
| /** Resets all recorded state and configuration to defaults. */ | ||
| fun reset() { | ||
| shouldFail = false | ||
| receivedPrompts.clear() | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.