Skip to content

Commit

Permalink
Merge pull request #514 from takahirom/takahirom/add-dependecy-diff/2…
Browse files Browse the repository at this point in the history
…024-10-28

Add dependency diff
  • Loading branch information
takahirom authored Oct 28, 2024
2 parents 0f528a1 + 1fbb174 commit 83cd7dd
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/dependency-diff-comment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Dependency Diff Comment

on:
workflow_run:
workflows: ["Dependency Diff Report"]
types:
- completed

jobs:
comment-dependency-diff:
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest

permissions:
actions: read
contents: write
pull-requests: write

steps:
- name: Download PR number artifact
uses: dawidd6/action-download-artifact@v2
with:
name: pr
run_id: ${{ github.event.workflow_run.id }}

- name: Get pull request number
id: get-pr-number
run: |
PR_NUMBER=$(cat pr/NR)
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- name: Download dependency diff artifacts
uses: dawidd6/action-download-artifact@v2
with:
name: dependency-diff
run_id: ${{ github.event.workflow_run.id }}
path: dependency-diff

- name: Process dependency diff reports
id: process-diff
run: |
report_library_exists_diff=$(grep 'exists-diff=' dependency-diff/outputs/report-library.txt | cut -d'=' -f2)
report_plugin_exists_diff=$(grep 'exists-diff=' dependency-diff/outputs/report-plugin.txt | cut -d'=' -f2)
echo "report_library_exists_diff=$report_library_exists_diff" >> $GITHUB_ENV
echo "report_plugin_exists_diff=$report_plugin_exists_diff" >> $GITHUB_ENV
- name: Comment on PR for library
if: env.report_library_exists_diff == 'true' || failure()
uses: yumemi-inc/comment-pull-request@v1
with:
pull-request-number: ${{ env.PR_NUMBER }}
comment: ':warning: There are differences in library dependencies. See details [here](${{ env.LOG_URL }}).'
comment-if-failure: ':exclamation: Report workflow failed. See details [here](${{ env.LOG_URL }}).'

- name: Comment on PR for plugin
if: env.report_plugin_exists_diff == 'true' || failure()
uses: yumemi-inc/comment-pull-request@v1
with:
pull-request-number: ${{ env.PR_NUMBER }}
comment: ':warning: There are differences in plugin dependencies. See details [here](${{ env.LOG_URL }}).'
comment-if-failure: ':exclamation: Report workflow failed. See details [here](${{ env.LOG_URL }}).'
64 changes: 64 additions & 0 deletions .github/workflows/dependency-diff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Dependency Diff Report

on: pull_request

jobs:
report:
runs-on: ubuntu-latest
permissions:
contents: read
env:
LOG_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
distribution: 'zulu'
java-version: 19
- name: Generate dependency diff report for library
uses: yumemi-inc/gradle-dependency-diff-report@v2
id: report-library
with:
configuration: 'releaseRuntimeClasspath'
modules: |
roborazzi-compose-ios|commonMainImplementationDependenciesMetadata
roborazzi-compose-desktop|commonMainImplementationDependenciesMetadata
roborazzi
roborazzi-compose
roborazzi-compose-preview-scanner-support
- name: Save report-library outputs
run: |
mkdir -p outputs
echo "exists-diff=${{ steps.report-library.outputs.exists-diff }}" > outputs/report-library.txt
- name: Generate dependency diff report for plugin
uses: yumemi-inc/gradle-dependency-diff-report@v2
id: report-plugin
with:
modules: 'roborazzi-gradle-plugin'
configuration: 'runtimeClasspath'
project-dir: 'include-build'

- name: Save report-plugin outputs
run: |
echo "exists-diff=${{ steps.report-plugin.outputs.exists-diff }}" > outputs/report-plugin.txt
- name: Save PR number
if: ${{ github.event_name == 'pull_request' }}
run: |
mkdir -p pr
echo ${{ github.event.number }} > pr/NR
- name: Upload Dependency Diff Artifacts
uses: actions/upload-artifact@v4
with:
name: dependency-diff
path: outputs/
retention-days: 30

- name: Upload PR Number Artifact
uses: actions/upload-artifact@v4
with:
name: pr
path: pr/
retention-days: 30

0 comments on commit 83cd7dd

Please sign in to comment.