Repository navigation
158 lines (131 loc) · 5.05 KB
/
Copy pathci-test.yml
File metadata and controls
158 lines (131 loc) · 5.05 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: CI Tests
on:
pull_request:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: jdx/mise-action@v4
- name: Install dependencies
run: npm install
- name: Lint and type-check
run: |
npm run typecheck
npm run typecheck:tests
- name: Check public API compatibility
run: npm run check:api-compat
android-unit-test:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: jdx/mise-action@v4
- name: Cache npm packages
uses: actions/cache@v6
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json', 'test/test.mts') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
run: npm install
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Run Android unit tests
working-directory: android
run: ./gradlew :app:test
android-test:
needs: [lint, android-unit-test]
runs-on: bitrise-react-native-code-push-linux-runner
strategy:
matrix:
variant: [bare, expo]
include:
- variant: bare
test-command: test:android
- variant: expo
test-command: test:expo:android
steps:
- uses: actions/checkout@v7
- uses: jdx/mise-action@v4
- name: Cache npm packages
uses: actions/cache@v6
with:
path: ~/.npm
# Note about test.mts: some NPM package versions are hardcoded here and installed during the test run.
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json', 'test/test.mts') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
run: npm install
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
with:
# This job's Gradle build lives in a test app generated at runtime by the test harness,
# not a project checked into this repo, so there's nothing meaningful for it to
# contribute back to the cache. Read-only avoids each matrix variant (bare/expo) writing
# its own redundant entry; it still reuses whatever android-unit-test wrote, since
# setup-gradle shares its cache across jobs in the same workflow run.
cache-read-only: true
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Add Android tools to PATH
run: |
echo "/usr/local/lib/android/sdk/emulator" >> $GITHUB_PATH
echo "/usr/local/lib/android/sdk/platform-tools" >> $GITHUB_PATH
- name: Run Android Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 27
target: google_apis
arch: x86
disable-animations: true
# connectedAndroidTest is included here (rather than a separate job or step) to reuse
# this job's already-booted emulator. The emulator only lives for the duration of this
# action (it's killed at the end of the same invocation, not in a post/cleanup step),
# so the logic can't be split into a later workflow step - it has to run here.
# android-emulator-runner also runs each line of `script` as its own separate `sh -c`
# invocation, so multi-line shell logic is delegated to a script file instead of inlining here.
script: .github/scripts/run-android-tests.sh ${{ matrix.variant }} ${{ matrix.test-command }}
ios-test:
needs: lint
runs-on: bitrise-react-native-code-push-macos-runner
strategy:
matrix:
variant: [bare, expo]
include:
- variant: bare
test-command: test:ios
- variant: expo
test-command: test:expo:ios
steps:
- uses: actions/checkout@v7
- uses: jdx/mise-action@v4
- name: Cache npm packages
uses: actions/cache@v6
with:
path: ~/.npm
# Note about test.mts: some NPM package versions are hardcoded here and installed during the test run.
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json', 'test/test.mts') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
run: npm install
- name: Run iOS unit tests
# These tests are independent of the bare/expo distinction. Bare tests are slightly faster.
if: matrix.variant == 'bare'
run: npm run test:unit:ios
- name: Run iOS E2E Tests
run: npm run ${{ matrix.test-command }}
- name: Upload iOS Simulator crash reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: ios-crash-logs-${{ matrix.variant }}
path: test/crash-logs/
if-no-files-found: ignore