-
Notifications
You must be signed in to change notification settings - Fork 63
192 lines (164 loc) · 6.14 KB
/
test.yml
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
---
name: Test
on:
pull_request:
branches:
- master
jobs:
go_core:
name: Test and build Go Core
runs-on: macos-latest
timeout-minutes: 30
strategy:
matrix:
golang:
- 1.18
steps:
- name: Checkout changes
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.golang }}
- name: Set GOPATH in env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
mkdir -p $(go env GOPATH)/src/github.com/ipfs-shipyard
ln -s $PWD $(go env GOPATH)/src/github.com/ipfs-shipyard/gomobile-ipfs
shell: bash
- name: Restore Go mod cache
id: cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('go/go.sum') }}
- name: Install Go mod
if: steps.cache.outputs.cache-hit != 'true'
working-directory: go
run: GO111MODULE=on go mod vendor
- name: Run Go Core tests
working-directory: go
run: go test ./...
- name: Install Java
uses: actions/setup-java@v3
with:
java-version: 1.8
- name: Set TARGET_SDK in env
run: |
pip3 install -r utils/manifest_get/requirements.txt
export GET_BIN=utils/manifest_get/manifest_get.py
export GET_KEY=global.android.target_sdk_version
echo "TARGET_SDK=$($GET_BIN $GET_KEY)" >> $GITHUB_ENV
- name: Install Android SDK
run:
SDK_MAN=$HOME/Library/Android/sdk/tools/bin/sdkmanager;
BTOOLS=$($SDK_MAN --list | grep "build-tools;$TARGET_SDK");
BTOOL=$(echo $BTOOLS | tail -n1 | cut -d'|' -f1 | tr -d ' ');
PLATFORMS=$($SDK_MAN --list | grep "platforms;android-$TARGET_SDK");
PLATFORM=$(echo $PLATFORMS | tail -n1 | cut -d'|' -f1 | tr -d ' ');
$SDK_MAN --install "$BTOOL" platform-tools "$PLATFORM" ndk-bundle
> /dev/null
- name: Build Go Core
working-directory: packages
run: |
make build_core.android GOMOBILE_TARGET=/amd64
make build_core.ios
- name: Save build outputs
uses: actions/upload-artifact@v3
with:
name: build-${{ github.run_id }}
path: build
android_bridge:
name: Test Android Bridge
needs: go_core
runs-on: macos-latest
timeout-minutes: 30
steps:
- name: Checkout changes
uses: actions/checkout@v3
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Restore build outputs
uses: actions/download-artifact@v3
with:
name: build-${{ github.run_id }}
path: build
- name: Set TARGET_SDK in env
run: |
pip3 install -r utils/manifest_get/requirements.txt
export GET_BIN=utils/manifest_get/manifest_get.py
export GET_KEY=global.android.target_sdk_version
echo "TARGET_SDK=$($GET_BIN $GET_KEY)" >> $GITHUB_ENV
- name: Install Android SDK and Emulator
run:
SDK_MAN=$HOME/Library/Android/sdk/tools/bin/sdkmanager;
BTOOLS=$($SDK_MAN --list | grep "build-tools;$TARGET_SDK");
BTOOL=$(echo $BTOOLS | tail -n1 | cut -d'|' -f1 | tr -d ' ');
PLATFORMS=$($SDK_MAN --list | grep "platforms;android-$TARGET_SDK");
PLATFORM=$(echo $PLATFORMS | tail -n1 | cut -d'|' -f1 | tr -d ' ');
$SDK_MAN --install "$BTOOL" platform-tools "$PLATFORM" emulator
"system-images;android-$TARGET_SDK;default;x86_64" > /dev/null
echo no | $HOME/Library/Android/sdk/tools/bin/avdmanager
create avd --force -n test --abi 'default/x86_64'
--package "system-images;android-$TARGET_SDK;default;x86_64"
- name: Run Android Bridge tests
working-directory: android
run:
$HOME/Library/Android/sdk/emulator/emulator -avd test -no-boot-anim
-no-window -no-snapshot-save -gpu swiftshader_indirect -noaudio
& EMULATOR_PID=$!;
$HOME/Library/Android/sdk/platform-tools/adb wait-for-device shell
'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 2; done;';
./gradlew bridge:test bridge:connectedAndroidTest; kill $EMULATOR_PID
- name: Build Android Bridge
working-directory: android
run: ./gradlew bridge:javadocJar bridge:sourcesJar bridge:assemble
ios_bridge:
name: Test iOS Bridge
needs: go_core
runs-on: macos-latest
timeout-minutes: 30
steps:
- name: Checkout changes
uses: actions/checkout@v3
- name: Restore build outputs
uses: actions/download-artifact@v3
with:
name: build-${{ github.run_id }}
path: build
- name: Set simulator destination in env
working-directory: ios/Bridge
run:
DESTINATION=$(
xcodebuild -showdestinations
-project GomobileIPFS.xcodeproj
-scheme GomobileIPFS
| awk '/Ineligible destinations for/ {exit} {print}'
| grep 'platform:iOS Simulator'
| awk -F 'id:' '{print $2}'
| cut -d',' -f1
| tail -n1
);
if [ -z "$DESTINATION" ]; then
echo "::error::No compatible simulator found to run the test"
exit 1;
fi;
echo "DESTINATION=$DESTINATION" >> $GITHUB_ENV
- name: Run iOS Bridge tests
working-directory: ios/Bridge
run:
xcodebuild test
-project GomobileIPFS.xcodeproj
-scheme GomobileIPFS
-sdk iphonesimulator
-destination "platform=iOS Simulator,id=$DESTINATION"
- name: Build iOS Bridge
run:
xcodebuild
-project ../ios/Bridge/GomobileIPFS.xcodeproj
-scheme GomobileIPFS
-sdk iphonesimulator
-destination "platform=iOS Simulator,id=$DESTINATION"
&& pip3 install -r utils/cocoapod_format/requirements.txt
&& utils/cocoapod_format/cocoapod_format_bridge.py