|
| 1 | +name: CI |
| 2 | + |
| 3 | +env: |
| 4 | + RUST_BACKTRACE: 1 |
| 5 | + GODOT_VER: 3.2 |
| 6 | + GODOT_REL: stable |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - staging |
| 12 | + - trying |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + shell: bash |
| 17 | + |
| 18 | +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 | + |
| 31 | + clippy: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + continue-on-error: ${{ matrix.experimental }} |
| 34 | + needs: rustfmt |
| 35 | + strategy: |
| 36 | + matrix: |
| 37 | + include: |
| 38 | + - rust: stable |
| 39 | + experimental: false |
| 40 | + - rust: nightly |
| 41 | + experimental: true |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v2 |
| 44 | + - uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f |
| 45 | + with: |
| 46 | + profile: minimal |
| 47 | + toolchain: ${{ matrix.rust }} |
| 48 | + components: clippy |
| 49 | + - 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; |
| 50 | + |
| 51 | + test: |
| 52 | + continue-on-error: ${{ matrix.experimental }} |
| 53 | + needs: rustfmt |
| 54 | + strategy: |
| 55 | + matrix: |
| 56 | + include: |
| 57 | + - rust: stable |
| 58 | + os: ubuntu-latest |
| 59 | + experimental: false |
| 60 | + is_windows: false |
| 61 | + - rust: nightly |
| 62 | + os: ubuntu-latest |
| 63 | + 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 |
| 73 | + - rust: stable |
| 74 | + os: windows-latest |
| 75 | + experimental: false |
| 76 | + is_windows: true |
| 77 | + - rust: nightly |
| 78 | + os: windows-latest |
| 79 | + experimental: true |
| 80 | + is_windows: true |
| 81 | + runs-on: ${{ matrix.os }} |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v2 |
| 84 | + - uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f |
| 85 | + with: |
| 86 | + profile: minimal |
| 87 | + toolchain: stable |
| 88 | + - uses: KyleMayes/install-llvm-action@01144dc97b1e2693196c3056414a44f15180648b |
| 89 | + with: |
| 90 | + version: 10.0 |
| 91 | + directory: ${{ runner.temp }}/llvm |
| 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; |
| 104 | + |
| 105 | + test_ios: |
| 106 | + continue-on-error: ${{ matrix.experimental }} |
| 107 | + needs: rustfmt |
| 108 | + strategy: |
| 109 | + matrix: |
| 110 | + include: |
| 111 | + - rust: stable |
| 112 | + os: macos-latest |
| 113 | + experimental: false |
| 114 | + - rust: nightly |
| 115 | + os: macos-latest |
| 116 | + 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: |
| 151 | + - rust: stable |
| 152 | + os: ubuntu-latest |
| 153 | + experimental: false |
| 154 | + runs-on: ${{ matrix.os }} |
| 155 | + steps: |
| 156 | + - uses: actions/checkout@v2 |
| 157 | + - uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f |
| 158 | + with: |
| 159 | + profile: minimal |
| 160 | + toolchain: stable |
| 161 | + - uses: KyleMayes/install-llvm-action@01144dc97b1e2693196c3056414a44f15180648b |
| 162 | + with: |
| 163 | + version: 10.0 |
| 164 | + directory: ${{ runner.temp }}/llvm |
| 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; |
| 193 | +
|
| 194 | + godot_test: |
| 195 | + continue-on-error: ${{ matrix.experimental }} |
| 196 | + needs: rustfmt |
| 197 | + strategy: |
| 198 | + matrix: |
| 199 | + include: |
| 200 | + - rust: stable |
| 201 | + os: ubuntu-latest |
| 202 | + experimental: false |
| 203 | + - rust: nightly |
| 204 | + os: ubuntu-latest |
| 205 | + experimental: true |
| 206 | + runs-on: ${{ matrix.os }} |
| 207 | + steps: |
| 208 | + - uses: actions/checkout@v2 |
| 209 | + - uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f |
| 210 | + with: |
| 211 | + profile: minimal |
| 212 | + toolchain: stable |
| 213 | + - uses: KyleMayes/install-llvm-action@01144dc97b1e2693196c3056414a44f15180648b |
| 214 | + with: |
| 215 | + version: 10.0 |
| 216 | + directory: ${{ runner.temp }}/llvm |
| 217 | + - name: Installing Godot |
| 218 | + run: | |
| 219 | + wget "https://downloads.tuxfamily.org/godotengine/$GODOT_VER/Godot_v${GODOT_VER}-${GODOT_REL}_linux_headless.64.zip" -O /tmp/godot.zip |
| 220 | + unzip /tmp/godot.zip -d ${{ runner.temp }}/godot_bin |
| 221 | + - name: Building Godot-Rust |
| 222 | + run: | |
| 223 | + cd test; |
| 224 | + cargo build; |
| 225 | + - name: Running Godot Tests |
| 226 | + run: | |
| 227 | + cd test; |
| 228 | + mkdir -p ./project/lib; |
| 229 | + cp ../target/debug/libgdnative_test.so ./project/lib/; |
| 230 | + "${{ runner.temp }}/godot_bin/Godot_v${GODOT_VER}-${GODOT_REL}_linux_headless.64" --path ./project/; |
| 231 | + "${{ runner.temp }}/godot_bin/Godot_v${GODOT_VER}-${GODOT_REL}_linux_headless.64" -e --path ./project/ --run-editor-tests; |
| 232 | + cargo build --features=type_tag_fallback; |
| 233 | + mkdir -p ./project/lib; |
| 234 | + cp ../target/debug/libgdnative_test.so ./project/lib/; |
| 235 | + "${{ runner.temp }}/godot_bin/Godot_v${GODOT_VER}-${GODOT_REL}_linux_headless.64" --path ./project/; |
| 236 | + "${{ runner.temp }}/godot_bin/Godot_v${GODOT_VER}-${GODOT_REL}_linux_headless.64" -e --path ./project/ --run-editor-tests; |
| 237 | + |
| 238 | + # This job doesn't actually test anything, but they're used to tell bors the |
| 239 | + # build completed, as there is no practical way to detect when a workflow is |
| 240 | + # successful listening to webhooks only. |
| 241 | + # |
| 242 | + # ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB! |
| 243 | + |
| 244 | + ci-success: |
| 245 | + name: ci |
| 246 | + if: github.event_name == 'push' && success() |
| 247 | + needs: |
| 248 | + - clippy |
| 249 | + - rustfmt |
| 250 | + - test |
| 251 | + - test_ios |
| 252 | + - test_android |
| 253 | + - godot_test |
| 254 | + runs-on: ubuntu-latest |
| 255 | + steps: |
| 256 | + - name: Mark the job as a success |
| 257 | + run: exit 0 |
0 commit comments