Skip to content

Commit ced10b9

Browse files
committed
ci: checks
1 parent 6751b5c commit ced10b9

File tree

1 file changed

+68
-11
lines changed

1 file changed

+68
-11
lines changed

.github/workflows/ui-tests.yml

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,79 @@
1-
name: Compose UI Tests
1+
name: UI Tests
22

33
on:
44
workflow_run:
55
workflows: ["CI"]
66
types:
77
- completed
8-
branches: [ "master" ]
8+
branches:
9+
- "master"
910

1011
jobs:
11-
compose-tests:
12-
if: >
13-
# github.event.workflow_run.conclusion == 'success' &&
14-
# github.event.workflow_run.event == 'pull_request' &&
15-
github.event.workflow_run.pull_requests[0].draft == false
12+
check-conditions:
1613
runs-on: ubuntu-latest
14+
outputs:
15+
should_run: ${{ steps.check-pr-status.outputs.should_run }}
16+
pr_number: ${{ steps.find-pr.outputs.pr_number }}
1717

1818
steps:
19-
- name: Checkout code
19+
- name: Find associated pull request
20+
id: find-pr
21+
uses: actions/github-script@v7
22+
with:
23+
script: |
24+
const commitSha = '${{ github.event.workflow_run.head_sha }}';
25+
const { data: pullRequests } = await github.rest.pulls.list({
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
state: 'open',
29+
sort: 'updated',
30+
direction: 'desc',
31+
per_page: 100
32+
});
33+
34+
for (const pr of pullRequests) {
35+
if (pr.head.sha === commitSha) {
36+
console.log(`Found matching PR: #${pr.number}`);
37+
core.setOutput('pr_number', pr.number);
38+
return;
39+
}
40+
}
41+
42+
console.log('No matching PR found for this commit');
43+
core.setOutput('pr_number', '');
44+
45+
- name: Check PR draft status
46+
id: check-pr-status
47+
if: steps.find-pr.outputs.pr_number != ''
48+
uses: actions/github-script@v7
49+
with:
50+
script: |
51+
const prNumber = parseInt('${{ steps.find-pr.outputs.pr_number }}');
52+
if (!prNumber) {
53+
console.log('No PR number found, skipping UI tests');
54+
core.setOutput('should_run', 'false');
55+
return;
56+
}
57+
58+
const { data: pr } = await github.rest.pulls.get({
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
pull_number: prNumber
62+
});
63+
64+
const shouldRun = !pr.draft;
65+
console.log(`PR #${prNumber} draft status: ${pr.draft}`);
66+
console.log(`Should run UI tests: ${shouldRun}`);
67+
68+
core.setOutput('should_run', shouldRun.toString());
69+
70+
ui-tests:
71+
needs: check-conditions
72+
if: ${{ needs.check-conditions.outputs.should_run == 'true' }}
73+
runs-on: ubuntu-latest
74+
75+
steps:
76+
- name: Checkout the code
2077
uses: actions/checkout@v4
2178

2279
- name: Set up JDK 17
@@ -43,7 +100,7 @@ jobs:
43100
- name: Make gradlew executable
44101
run: chmod +x gradlew
45102

46-
- name: Build debug APK
103+
- name: Build for debug with gradle
47104
run: ./gradlew assembleDebug
48105

49106
- name: Start Android Emulator
@@ -57,9 +114,9 @@ jobs:
57114
- name: Run Compose UI tests
58115
run: ./gradlew connectedDebugAndroidTest
59116

60-
- name: Upload test reports
61-
uses: actions/upload-artifact@v4
117+
- name: Upload UI test report
62118
if: always()
119+
uses: actions/upload-artifact@v4
63120
with:
64121
name: compose_test_report
65122
path: app/build/reports/androidTests/connected/

0 commit comments

Comments
 (0)