Skip to content

Commit 7b21f10

Browse files
toasteaterufoot
andcommitted
Port macOS and iOS tests, add Android from #649
Co-authored-by: Christian Mauduit (ufoot) <[email protected]>
1 parent 27f18bc commit 7b21f10

File tree

1 file changed

+108
-24
lines changed

1 file changed

+108
-24
lines changed

.github/workflows/ci.yml

Lines changed: 108 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,22 @@ defaults:
1616
shell: bash
1717

1818
jobs:
19+
rustfmt:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f
24+
with:
25+
profile: minimal
26+
toolchain: stable
27+
components: rustfmt
28+
- name: Checking rustfmt
29+
run: cargo fmt --all -- --check;
30+
1931
clippy:
2032
runs-on: ubuntu-latest
2133
continue-on-error: ${{ matrix.experimental }}
34+
needs: rustfmt
2235
strategy:
2336
matrix:
2437
include:
@@ -35,35 +48,36 @@ jobs:
3548
components: clippy
3649
- run: cargo clippy --all --all-features -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented;
3750

38-
rustfmt:
39-
runs-on: ubuntu-latest
40-
steps:
41-
- uses: actions/checkout@v2
42-
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f
43-
with:
44-
profile: minimal
45-
toolchain: stable
46-
components: rustfmt
47-
- name: Checking rustfmt
48-
run: cargo fmt --all -- --check;
49-
5051
test:
5152
continue-on-error: ${{ matrix.experimental }}
53+
needs: rustfmt
5254
strategy:
5355
matrix:
5456
include:
5557
- rust: stable
5658
os: ubuntu-latest
5759
experimental: false
60+
is_windows: false
5861
- rust: nightly
5962
os: ubuntu-latest
6063
experimental: true
64+
is_windows: false
65+
- rust: stable
66+
os: macos-latest
67+
experimental: false
68+
is_windows: false
69+
- rust: nightly
70+
os: macos-latest
71+
experimental: true
72+
is_windows: false
6173
- rust: stable
6274
os: windows-latest
6375
experimental: false
76+
is_windows: true
6477
- rust: nightly
6578
os: windows-latest
6679
experimental: true
80+
is_windows: true
6781
runs-on: ${{ matrix.os }}
6882
steps:
6983
- uses: actions/checkout@v2
@@ -75,26 +89,68 @@ jobs:
7589
with:
7690
version: 10.0
7791
directory: ${{ runner.temp }}/llvm
78-
- run: cargo test --all --all-features;
79-
# cargo test --target x86_64-pc-windows-msvc --all --all-features;
92+
- name: Non-Windows test
93+
if: ${{ !matrix.is_windows }}
94+
run: cargo test --all --all-features;
95+
- name: Non-Windows release build
96+
if: ${{ !matrix.is_windows }}
97+
run: cargo build --release;
98+
- name: Windows test
99+
if: ${{ matrix.is_windows }}
100+
run: cargo test --target x86_64-pc-windows-msvc --all --all-features;
101+
- name: Windows release build
102+
if: ${{ matrix.is_windows }}
103+
run: cargo build --target x86_64-pc-windows-msvc --release;
80104

81-
build_release:
105+
test_ios:
82106
continue-on-error: ${{ matrix.experimental }}
107+
needs: rustfmt
83108
strategy:
84109
matrix:
85110
include:
86111
- rust: stable
87-
os: ubuntu-latest
112+
os: macos-latest
88113
experimental: false
89114
- rust: nightly
90-
os: ubuntu-latest
115+
os: macos-latest
91116
experimental: true
117+
runs-on: ${{ matrix.os }}
118+
steps:
119+
- uses: actions/checkout@v2
120+
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f
121+
with:
122+
profile: minimal
123+
toolchain: stable
124+
- uses: KyleMayes/install-llvm-action@01144dc97b1e2693196c3056414a44f15180648b
125+
with:
126+
version: 10.0
127+
directory: ${{ runner.temp }}/llvm
128+
- name: Installing cargo-dinghy
129+
run: |
130+
rustup target add x86_64-apple-ios;
131+
curl -L https://github.com/snipsco/dinghy/releases/download/cargo-dinghy%2F0.4.37/cargo-dinghy-macos.tgz -o cargo-dinghy-macos.tar.gz;
132+
tar -zxvf cargo-dinghy-macos.tar.gz;
133+
mkdir -p $HOME/.cargo/bin;
134+
cp cargo-dinghy-macos/cargo-dinghy $HOME/.cargo/bin;
135+
- run: |
136+
RUNTIME_ID=$(xcrun simctl list runtimes | grep iOS | cut -d ' ' -f 7 | tail -1);
137+
export SIM_ID=$(xcrun simctl create My-iphone11 com.apple.CoreSimulator.SimDeviceType.iPhone-11 $RUNTIME_ID);
138+
xcrun simctl boot $SIM_ID;
139+
cd gdnative-core;
140+
cargo dinghy --platform auto-ios-x86_64 test;
141+
cd ..;
142+
cd gdnative-sys;
143+
cargo dinghy --platform auto-ios-x86_64 test;
144+
145+
test_android:
146+
continue-on-error: ${{ matrix.experimental }}
147+
needs: rustfmt
148+
strategy:
149+
matrix:
150+
include:
92151
- rust: stable
93-
os: windows-latest
152+
os: ubuntu-latest
94153
experimental: false
95-
- rust: nightly
96-
os: windows-latest
97-
experimental: true
98154
runs-on: ${{ matrix.os }}
99155
steps:
100156
- uses: actions/checkout@v2
@@ -106,11 +162,38 @@ jobs:
106162
with:
107163
version: 10.0
108164
directory: ${{ runner.temp }}/llvm
109-
- run: cargo build --release;
110-
# cargo build --target x86_64-pc-windows-msvc --release;
165+
- run: |
166+
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64;
167+
export ANDROID_SDK_ROOT=/opt/ndk/android-ndk-r21d;
168+
# aarch64 and armv7 cover most Android phones & tablets.;
169+
rustup target add aarch64-linux-android armv7-linux-androideabi;
170+
sudo apt-get update;
171+
sudo apt-get install openjdk-8-jdk;
172+
sudo apt-get install llvm-dev libclang-dev clang g++-multilib gcc-multilib libc6-dev libc6-dev-arm64-cross;
173+
# Downloading NDK. This file is huge (1Gb) maybe extract only what's needed and repackage.;
174+
# See https://developer.android.com/ndk/downloads for updates.;
175+
# The Android SDK which comes with Android Studio is not required. Only Java + NDK are.;
176+
mkdir /opt/ndk
177+
install -d /opt/ndk;
178+
cd /opt/ndk && wget -nc -nv https://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip && cd $GITHUB_WORKSPACE;
179+
echo "bcf4023eb8cb6976a4c7cff0a8a8f145f162bf4d /opt/ndk/android-ndk-r21d-linux-x86_64.zip" >> /opt/ndk/SHA1SUM.txt;
180+
sha1sum --check /opt/ndk/SHA1SUM.txt;
181+
cd /opt/ndk && unzip -q android-ndk-r21d-linux-x86_64.zip && cd $GITHUB_WORKSPACE;
182+
# Using clang linker from NDK when building Android programs.;
183+
install -d $HOME/.cargo;
184+
echo >> $HOME/.cargo/config;
185+
echo "[target.aarch64-linux-android]" >> $HOME/.cargo/config;
186+
find /opt/ndk -name aarch64-linux-android21-clang++ -printf 'linker = "%p"\n' >> $HOME/.cargo/config;
187+
echo >> $HOME/.cargo/config;
188+
echo "[target.armv7-linux-androideabi]" >> $HOME/.cargo/config;
189+
find /opt/ndk -name armv7a-linux-androideabi21-clang++ -printf 'linker = "%p"\n' >> $HOME/.cargo/config;
190+
echo >> $HOME/.cargo/config;
191+
cargo build --target aarch64-linux-android --release;
192+
cargo build --target armv7-linux-androideabi --release;
111193
112194
godot_test:
113195
continue-on-error: ${{ matrix.experimental }}
196+
needs: rustfmt
114197
strategy:
115198
matrix:
116199
include:
@@ -165,7 +248,8 @@ jobs:
165248
- clippy
166249
- rustfmt
167250
- test
168-
- build_release
251+
- test_ios
252+
- test_android
169253
- godot_test
170254
runs-on: ubuntu-latest
171255
steps:

0 commit comments

Comments
 (0)