-
Notifications
You must be signed in to change notification settings - Fork 653
Create unit test report workflow #7422
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2db2227
Add unit test report generator
emilypgoogle a06ce49
Copyright headers
emilypgoogle 78d08af
Convert to kotlin
emilypgoogle 8ed754a
Clean up
emilypgoogle 464adfc
Create unit test report workflow
emilypgoogle 4818643
Update plugin
emilypgoogle 2f5506c
Copyright
emilypgoogle 8ce97b0
Resolve duplication
emilypgoogle 16e04b7
Adjust plugin name
emilypgoogle a15ebbd
Format
emilypgoogle 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,35 @@ | ||
| name: Generate Test Report | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: 51 8 * * * # Runs automatically once a day | ||
| workflow_dispatch: # Allow triggering the workflow manually | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write | ||
|
|
||
| jobs: | ||
| report: | ||
| name: "Generate Test Report" | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
| with: | ||
| submodules: true | ||
|
|
||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 | ||
| with: | ||
| java-version: 17 | ||
| distribution: temurin | ||
| cache: gradle | ||
|
|
||
| - name: Generate Test Report | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: ./gradlew generateTestReport | ||
|
|
||
| - name: Update tracking issue | ||
| run: gh issue edit 7421 --body-file test-report.md | ||
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
31 changes: 31 additions & 0 deletions
31
plugins/src/main/java/com/google/firebase/gradle/plugins/report/TestReportPlugin.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,31 @@ | ||
| /* | ||
| * Copyright 2025 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.google.firebase.gradle.plugins.report | ||
|
|
||
| import org.gradle.api.Plugin | ||
| import org.gradle.api.Project | ||
| import org.gradle.kotlin.dsl.register | ||
|
|
||
| class TestReportPlugin : Plugin<Project> { | ||
| override fun apply(project: Project) { | ||
| project.tasks.register<TestReportTask>("generateTestReport") { | ||
| outputFile.set(project.file("test-report.md")) | ||
| commitCount.set(8 as Integer) | ||
| apiToken.set(System.getenv("GH_TOKEN")) | ||
| } | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
plugins/src/main/java/com/google/firebase/gradle/plugins/report/TestReportTask.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,46 @@ | ||
| /* | ||
| * Copyright 2025 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.google.firebase.gradle.plugins.report | ||
|
|
||
| import org.gradle.api.DefaultTask | ||
| import org.gradle.api.file.RegularFileProperty | ||
| import org.gradle.api.provider.Property | ||
| import org.gradle.api.tasks.Input | ||
| import org.gradle.api.tasks.OutputFile | ||
| import org.gradle.api.tasks.TaskAction | ||
|
|
||
| /** | ||
| * Creates a markdown unit test report file based on recent runs of GitHub Actions. Task simply | ||
| * aggregates live test data and does not rely on the current state of the repository. | ||
| * | ||
| * @property outputFile The file path to output the markdown test report to. | ||
| * @property commitCount The number of remote commits to aggregate test results from. | ||
| * @property apiToken The GitHub API token with adequate permissions to read test result data and | ||
| * execute GraphQL queries. | ||
| */ | ||
| abstract class TestReportTask : DefaultTask() { | ||
| @get:OutputFile abstract val outputFile: RegularFileProperty | ||
|
|
||
| @get:Input abstract val commitCount: Property<Integer> | ||
|
|
||
| @get:Input abstract val apiToken: Property<String> | ||
|
|
||
| @TaskAction | ||
| fun make() { | ||
| TestReportGenerator(apiToken.get()) | ||
| .createReport(outputFile.asFile.get(), commitCount.get().toInt()) | ||
| } | ||
| } |
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.