forked from OutlineFoundation/outline-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (120 loc) · 5.73 KB
/
Copy pathtest.yml
File metadata and controls
142 lines (120 loc) · 5.73 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
name: Build and Test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
OUTPUT_DIR: ${{ github.workspace }}/out
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "${{ github.workspace }}/go.mod"
- name: Build SDK
run: go build -v ./...
- name: Build X
run: go build -C x -tags psiphon -o "${{ env.OUTPUT_DIR }}/" -v ./...
- name: Build Go Mobile
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'
run: go build -C x -o "${{ env.OUTPUT_DIR }}/" golang.org/x/mobile/cmd/gomobile golang.org/x/mobile/cmd/gobind
- name: Build Mobileproxy (Android)
if: matrix.os == 'ubuntu-latest'
working-directory: ${{ github.workspace }}/x
run: PATH="${{ env.OUTPUT_DIR }}:$PATH" gomobile bind -ldflags='-s -w' -v -tags=psiphon -target=android -androidapi=21 -o "${{ env.OUTPUT_DIR }}/mobileproxy.aar" github.com/Jigsaw-Code/outline-sdk/x/mobileproxy
- name: Build Mobileproxy (iOS)
if: matrix.os == 'macos-latest'
working-directory: ${{ github.workspace }}/x
run: PATH="${{ env.OUTPUT_DIR }}:$PATH" gomobile bind -ldflags='-s -w' -v -tags=psiphon -target=ios -iosversion=11.0 -o "${{ env.OUTPUT_DIR }}/mobileproxy.xcframework" github.com/Jigsaw-Code/outline-sdk/x/mobileproxy
- name: Check SDK licenses
# We allow only "notice" type of licenses.
run: go tool go-licenses check --ignore=golang.org/x --allowed_licenses=Apache-2.0,Apache-3,BSD-3-Clause,BSD-4-Clause,CC0-1.0,MIT ./...
- name: Check x licenses
env: { GO_FLAGS: -C x }
run: go tool go-licenses check --ignore=golang.org/x --allowed_licenses=Apache-2.0,Apache-3,BSD-3-Clause,BSD-4-Clause,CC0-1.0,MIT ./...
- name: Test SDK
# Enable nettests, which executes external network requests.
run: go test -tags nettest -race -bench '.' ./... -benchtime=100ms
- name: Test x
# Enable nettests, which executes external network requests.
run: go test -C x -tags nettest,psiphon -race -bench '.' ./... -benchtime=100ms
android-test:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
api-level: [34]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "${{ github.workspace }}/go.mod"
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
# Free up disk space to avoid "Not enough space to create userdata partition" error.
# See https://github.com/Jigsaw-Code/outline-sdk/actions/runs/20183073943/job/58094204027?pr=556#step:7:98
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
# Android recipe from https://github.com/ReactiveCircus/android-emulator-runner/blob/v2/README.md#usage--examples
# KVM makes the emulator faster.
- 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: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
arch: x86_64
target: aosp_atd
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: |
echo "Generated AVD snapshot for caching."
ls ~/.android/avd
ls ~/.android/
- name: Run Android unit tests
uses: reactivecircus/android-emulator-runner@v2
with:
arch: x86_64
# Using Automated Test Device because they are leaner. See
# https://developer.android.com/studio/test/gradle-managed-devices#gmd-atd
target: aosp_atd
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: |
# We can't set environment variables in this script, nor refer to $ANDROID_NDK_HOME in the job.step.env block, so
# we set it explicitly here. (#pain)
CC="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android${{ matrix.api-level }}-clang" GOOS=android GOARCH=amd64 CGO_ENABLED=1 go test -tags nettest -exec "${{ github.workspace }}/run_on_android.sh" -v ./...
# TODO(fortuna): Fix psiphon and support testdata.
CC="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android${{ matrix.api-level }}-clang" GOOS=android GOARCH=amd64 CGO_ENABLED=1 go test -C x -tags nettest,psiphon -exec "${{ github.workspace }}/run_on_android.sh" -v ./...