-
-
Notifications
You must be signed in to change notification settings - Fork 967
137 lines (123 loc) · 5.3 KB
/
pr-emulator-wtf.yml
File metadata and controls
137 lines (123 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: PR Emulator.wtf
on: # yamllint disable-line rule:truthy
workflow_run:
workflows: ['Pull Request']
types: [completed]
concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true
permissions: {}
jobs:
emulator_wtf:
name: "Instrumentation Test app"
runs-on: ubuntu-latest
environment: ui-test
if: >
github.event.workflow_run.event == 'pull_request'
&& github.event.workflow_run.conclusion != 'cancelled'
&& github.event.workflow_run.conclusion != 'skipped'
permissions:
id-token: write # Needed for OIDC authentication
actions: read # Needed for retrieving artifacts
steps:
# Halt before spending any emulator.wtf credits if the triggering Pull Request
# workflow did not succeed (publish_test_results still runs afterward to
# aggregate whatever results pr.yml produced).
- name: Halt if triggering workflow did not succeed
if: github.event.workflow_run.conclusion != 'success'
env:
CONCLUSION: ${{ github.event.workflow_run.conclusion }}
run: |
echo "::error::Triggering 'Pull Request' workflow concluded as '$CONCLUSION'; skipping emulator.wtf to save resources"
exit 1
- name: Download emulator.wtf inputs
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: emulator-wtf-inputs
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: emulator-wtf-inputs
- name: Load device list
id: devices
# The artifact comes from a PR build that may originate from a fork; validate
# every line strictly before piping the contents into GITHUB_OUTPUT to prevent
# heredoc-terminator injection.
run: |
if [ ! -s emulator-wtf-inputs/devices.txt ]; then
echo "::error::devices.txt is empty or missing"
exit 1
fi
while IFS= read -r line; do
if [[ ! "$line" =~ ^model=Pixel7,version=(2[3-9]|3[0-9]|40)$ ]]; then
echo "::error::Invalid line in devices.txt"
exit 1
fi
done < emulator-wtf-inputs/devices.txt
{
echo 'list<<DEVICES_EOF'
cat emulator-wtf-inputs/devices.txt
echo 'DEVICES_EOF'
} >> "$GITHUB_OUTPUT"
- uses: emulator-wtf/actions/configure-credentials@42753a2a6bda2e657741a7385131bf61db464899 # v1.0.0
with:
oidc-configuration-id: ${{ vars.EMULATOR_WTF_OIDC_CONFIGURATION_ID }}
- name: Run tests full
uses: emulator-wtf/actions/run-tests@42753a2a6bda2e657741a7385131bf61db464899 # v1.0.0
with:
devices: ${{ steps.devices.outputs.list }}
app: emulator-wtf-inputs/app/build/outputs/apk/full/debug/app-full-debug.apk
test: emulator-wtf-inputs/app/build/outputs/apk/androidTest/full/debug/app-full-debug-androidTest.apk
outputs-dir: build/test-results/full
- name: Run tests minimal
uses: emulator-wtf/actions/run-tests@42753a2a6bda2e657741a7385131bf61db464899 # v1.0.0
with:
devices: ${{ steps.devices.outputs.list }}
app: emulator-wtf-inputs/app/build/outputs/apk/minimal/debug/app-minimal-debug.apk
test: emulator-wtf-inputs/app/build/outputs/apk/androidTest/minimal/debug/app-minimal-debug-androidTest.apk
outputs-dir: build/test-results/minimal
- name: Upload test results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: Instrumentation Test app results
path: |
**/build/test-results/**/TEST-*.xml
**/build/test-results/**/results.xml
- name: Upload test reports
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: Instrumentation Test app reports
path: build/test-results/**
publish_test_results:
name: "Publish Tests Results"
needs: [emulator_wtf]
if: always()
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
actions: read
contents: read
steps:
- name: Download artifacts from pr.yml run
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: pr-artifacts
- name: Download emulator.wtf results from this run
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Instrumentation Test app results
path: pr-artifacts/Instrumentation Test app results
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@c950f6fb443cb5af20a377fd0dfaa78838901040 # v2.23.0
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_name: ${{ github.event.workflow_run.event }}
comment_mode: "failures"
action_fail: true
files: |
pr-artifacts/**/TEST-*.xml
pr-artifacts/**/results.xml