Skip to content

Commit 5050964

Browse files
authored
Setup dependency diff and diffuse actions (#865)
* Dependency diff github action * diffuse action * add permissions to actions * update comment action versions * Put diffuse into separate job due to java version diff * Use adopt 17 for actions * name artifact correctly * clean up job logic
1 parent 6f423d6 commit 5050964

2 files changed

Lines changed: 122 additions & 2 deletions

File tree

‎.github/workflows/android.yml‎

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
- 'NOTICE'
1717
- '.gitignore'
1818

19+
permissions:
20+
contents: read
21+
pull-requests: write
22+
1923
jobs:
2024
build:
2125
runs-on: ubuntu-latest
@@ -30,7 +34,7 @@ jobs:
3034
submodules: recursive
3135

3236
- name: set up JDK 17
33-
uses: actions/setup-java@v3.12.0
37+
uses: actions/setup-java@v4
3438
with:
3539
java-version: '17'
3640
distribution: 'adopt'
@@ -54,9 +58,15 @@ jobs:
5458
git fetch origin main --depth 1
5559
./gradlew spotlessCheck
5660
57-
- name: Build with Gradle
61+
- name: Build and test with Gradle
5862
run: ./gradlew assembleRelease livekit-android-test:testRelease
5963

64+
- name: Upload AAR
65+
uses: actions/upload-artifact@v6
66+
with:
67+
name: livekit-android-sdk-release.aar
68+
path: client-sdk-android/livekit-android-sdk/build/outputs/aar/livekit-android-sdk-release.aar
69+
6070
# TODO: Figure out appropriate place to run this. Takes ~3 mins, so pretty slow.
6171
# # generates coverage-report.md and publishes as checkrun
6272
# - name: JaCoCo Code Coverage Report
@@ -174,6 +184,20 @@ jobs:
174184
if: github.event_name == 'push' && contains(steps.version_name.outputs.version_name,'SNAPSHOT')
175185
run: ./gradlew publishReleasePublicationToMavenRepository
176186

187+
# Setting up diffuse artifacts
188+
- name: Setup cache for base source file for diffuse
189+
if: github.event_name == 'push'
190+
uses: actions/cache@v4
191+
with:
192+
path: diffuse-source-file
193+
key: diffuse-${{ github.sha }}
194+
195+
# Copy your build artifact under `diffuse-source-file` name which will be saved in cache
196+
- name: Copy diffuse source file
197+
run: cp ./livekit-android-sdk/build/outputs/aar/livekit-android-sdk-release.aar diffuse-source-file
198+
if: github.event_name == 'push'
199+
shell: bash
200+
177201
- name: Repository Dispatch
178202
if: github.event_name == 'push'
179203
uses: peter-evans/repository-dispatch@v2
@@ -182,3 +206,52 @@ jobs:
182206
repository: livekit/e2e-android
183207
event-type: client-sdk-android-push
184208
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
209+
210+
diffuse:
211+
runs-on: ubuntu-latest
212+
if: ${{ github.event_name == 'pull_request' }}
213+
name: Diffuse checker
214+
needs: build
215+
steps:
216+
- uses: actions/setup-java@v4
217+
with:
218+
java-version: '17'
219+
distribution: 'adopt'
220+
221+
# Diffuse checking for pull requests
222+
- uses: actions/cache@v4
223+
name: Download base source file for diffuse
224+
with:
225+
path: diffuse-source-file
226+
key: diffuse-${{ github.event.pull_request.base.sha }}
227+
228+
- id: diffuse
229+
uses: usefulness/diffuse-action@v1
230+
with:
231+
old-file-path: diffuse-source-file
232+
new-file-path: client-sdk-android/livekit-android-sdk/build/outputs/aar/livekit-android-sdk-release.aar
233+
234+
# Consuming diffuse action output
235+
236+
- uses: peter-evans/find-comment@v4
237+
id: find_comment
238+
with:
239+
issue-number: ${{ github.event.pull_request.number }}
240+
body-includes: Diffuse output
241+
242+
- uses: peter-evans/create-or-update-comment@v5
243+
if: ${{ steps.diffuse.outputs.diff-raw != null || steps.find_comment.outputs.comment-id != null }}
244+
with:
245+
body: |
246+
Diffuse output:
247+
248+
${{ steps.diffuse.outputs.diff-gh-comment }}
249+
edit-mode: replace
250+
comment-id: ${{ steps.find_comment.outputs.comment-id }}
251+
issue-number: ${{ github.event.pull_request.number }}
252+
token: ${{ secrets.GITHUB_TOKEN }}
253+
254+
- uses: actions/upload-artifact@v6
255+
with:
256+
name: diffuse-output
257+
path: ${{ steps.diffuse.outputs.diff-file }}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Generate dependency diff
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
jobs:
11+
generate-diff:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-java@v4
18+
with:
19+
distribution: 'adopt'
20+
java-version: 17
21+
22+
- uses: gradle/actions/setup-gradle@v4
23+
24+
- id: dependency-diff
25+
name: Generate dependency diff
26+
uses: usefulness/dependency-tree-diff-action@v2
27+
with:
28+
project: 'livekit-android-sdk'
29+
30+
- uses: peter-evans/find-comment@v4
31+
id: find_comment
32+
with:
33+
issue-number: ${{ github.event.pull_request.number }}
34+
body-includes: Dependency diff
35+
36+
- uses: peter-evans/create-or-update-comment@v5
37+
if: ${{ steps.dependency-diff.outputs.text-diff != null || steps.find_comment.outputs.comment-id != null }}
38+
with:
39+
body: |
40+
Dependency diff (customize your message here):
41+
```diff
42+
${{ steps.dependency-diff.outputs.text-diff }}
43+
```
44+
edit-mode: replace
45+
comment-id: ${{ steps.find_comment.outputs.comment-id }}
46+
issue-number: ${{ github.event.pull_request.number }}
47+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)