Skip to content

Upload Gradle build scan#5104

Merged
ikhoon merged 7 commits intoline:mainfrom
ikhoon:gradle-build-scan
Aug 18, 2023
Merged

Upload Gradle build scan#5104
ikhoon merged 7 commits intoline:mainfrom
ikhoon:gradle-build-scan

Conversation

@ikhoon
Copy link
Copy Markdown
Contributor

@ikhoon ikhoon commented Aug 6, 2023

Motivation:

It must be useful to see test results on a website and share the link
with other folks. Since Gradle enterprise is activated in the Armeria
project, we can upload build scans to https://ge.armeria.dev.

An access token is required to upload build scans. As GitHub secrets are
not exposed to the pull requests from public forks, it is not possible to
directly upload the build scans in a CI build workflow while keeping the
access token securely.

@ribafish suggested a good idea that uploads build-scan-data to GitHub
Actions artifacts and then publishes the backup scan data in a sperate
workflow run on the Armeria repository later.

Modifications:

Result:

You can now see Gradle build scan of a pull request on https://ge.armeria.dev

Motivation:

It must be useful to see test results on a website and share the link
with other folks. Since Gradle enterprise is activated in the Armeria
project, we can upload build scans to https://ge.armeria.dev.

An access token is required to upload build scans. As GitHub secrets are
not exposed to the pull requests from public forks, it is not possible to
directly upload the build scans in a CI build workflow while keeping the
access token securely.

@ribafish suggested a good idea that uploads `build-scan-data` to GitHub
Actions artifacts and then publishing the backup scan data in a sperate
workflow run on Armeria repository later.

Modifications:

- Added a new step that uploads Gradle build scan data to GitHub Actions
  artifacts to the CI build.
- Redefined the build job name as a deterministic name.
  - A job name is used to fetch the job result from the JOB API.
  - GitHub does not provide a way to get a job ID or a job name in a workflow,
    - https://github.com/orgs/community/discussions/8945
    - https://stackoverflow.com/questions/71593861/how-to-get-github-actions-matrix-job-name-within-job
- Added some useful GitHub links to the build scan.
- Added `gradle-build-scan.yml` for downloading and executing the
  previous build scan.
- Added `get-pr-number-by-sha.ts` to find a pull request number based on
  the given commit SHA that was triggered the build.
  - The pull request number is used to comment the scan result on a pull
    request.
- Miscellaneous)
  - Bump `actions/checkout` to v3 from v2
  - Bump `actions/setup-java` to v3 from v2

Result:

You can now see Gradle build scan of a pull request on https://ge.armeria.dev
@ikhoon
Copy link
Copy Markdown
Contributor Author

ikhoon commented Aug 6, 2023

ikhoon#39 (comment) is an example of the scan result.

Comment thread settings.gradle Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 7, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01% ⚠️

Comparison is base (2ca9b4a) 74.33% compared to head (70dd121) 74.32%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5104      +/-   ##
============================================
- Coverage     74.33%   74.32%   -0.01%     
- Complexity    19603    19604       +1     
============================================
  Files          1682     1682              
  Lines         72252    72252              
  Branches       9241     9241              
============================================
- Hits          53707    53702       -5     
- Misses        14204    14211       +7     
+ Partials       4341     4339       -2     

see 18 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

name: Upload build scans
run: |
DOWNLOAD_DIR="build-scans/"
BUILD_SCAN_DIR="${HOME}/.gradle/build-scan-data"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a way to upload the build scans at a specified directory other than the default location? We could upload from build-scans/ without copying them to a shared directory (~/.gradle/build-scan-data), which could potentially cause a race condition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When I read the Javadoc of buildScan, there is no option to customize the folder (~/.gradle/build-scan-data).
As GitHub Actions executes only one run in an instance, we would not encounter race conditions at the moment. That said, it sounds very helpful if we can specify the folder.

@ribafish Please correct me if I'm wrong.

Copy link
Copy Markdown
Contributor

@ribafish ribafish Aug 8, 2023

Choose a reason for hiding this comment

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

Correct, there's no way to specify a different directory to upload the build scans from as such. If you wanted to run these in parallel, you could create copies of the project to run parallel builds while specifying a different gradle user home directory for each build with -Dgradle.user.home=(path to directory).

Copy link
Copy Markdown
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

Thanks, @ikhoon! 🚀 🚀 🚀

Copy link
Copy Markdown
Member

@trustin trustin left a comment

Choose a reason for hiding this comment

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

🚀🚀🚀

@ikhoon ikhoon merged commit 5da5ea4 into line:main Aug 18, 2023
jrhee17 added a commit to jrhee17/armeria that referenced this pull request Aug 21, 2023
@ikhoon ikhoon deleted the gradle-build-scan branch June 28, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants