feat(ci): add OpenHarmony ci support #1081
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
paths: | |
- '**.rs' | |
- '**.toml' | |
- '.github/workflows/ci.yml' | |
push: | |
branches: [master] | |
paths: | |
- '**.rs' | |
- '**.toml' | |
- '.github/workflows/ci.yml' | |
jobs: | |
check-formatting: | |
name: Check formatting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: taiki-e/checkout-action@v1 | |
- uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: rustfmt | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: typos-cli | |
- name: Check Formatting | |
run: cargo fmt --all -- --check | |
- name: run typos | |
run: typos | |
- name: Typos info | |
if: failure() | |
run: | | |
echo 'To fix typos, please run `typos -w`' | |
echo 'To check for a diff, run `typos`' | |
echo 'You can find typos here: https://crates.io/crates/typos' | |
tests: | |
name: Tests | |
strategy: | |
fail-fast: false | |
matrix: | |
rust_version: [1.70.0, stable, nightly] | |
platform: | |
- { target: x86_64-pc-windows-msvc, os: windows-latest, } | |
- { target: i686-pc-windows-msvc, os: windows-latest, } | |
- { target: i686-pc-windows-msvc, os: windows-latest, options: --no-default-features, features: wgl } | |
- { target: i686-pc-windows-msvc, os: windows-latest, options: --no-default-features, features: egl } | |
- { target: x86_64-pc-windows-gnu, os: windows-latest, host: -x86_64-pc-windows-gnu } | |
- { target: i686-pc-windows-gnu, os: windows-latest, host: -i686-pc-windows-gnu } | |
- { target: i686-unknown-linux-gnu, os: ubuntu-latest, } | |
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, } | |
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, options: --no-default-features, features: "egl,wayland,x11" } | |
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, options: --no-default-features, features: "egl,wayland" } | |
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, options: --no-default-features, features: "egl,x11" } | |
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, options: --no-default-features, features: glx } | |
- { target: aarch64-unknown-linux-ohos, os: ubuntu-latest, options: --no-default-features, features: egl } | |
- { target: x86_64-unknown-linux-ohos, os: ubuntu-latest, options: --no-default-features, features: egl } | |
- { target: aarch64-linux-android, os: ubuntu-latest, cmd: 'apk --' } | |
- { target: x86_64-apple-darwin, os: macos-latest, } | |
exclude: | |
# Android is tested on stable-3 | |
- rust_version: '1.70.0' | |
platform: { target: aarch64-linux-android, os: ubuntu-latest, cmd: 'apk --' } | |
- rust_version: '1.70.0' | |
platform: { target: aarch64-unknown-linux-ohos, os: ubuntu-latest, options: --no-default-features, features: egl } | |
- rust_version: '1.70.0' | |
platform: { target: x86_64-unknown-linux-ohos, os: ubuntu-latest, options: --no-default-features, features: egl } | |
include: | |
- rust_version: '1.70.0' | |
platform: { target: aarch64-linux-android, os: ubuntu-latest, cmd: 'apk --' } | |
env: | |
RUST_BACKTRACE: 1 | |
CARGO_INCREMENTAL: 0 | |
RUSTFLAGS: "-C debuginfo=0" | |
OPTIONS: ${{ matrix.platform.options }} | |
CMD: ${{ matrix.platform.cmd }} | |
FEATURES: ${{ format(',{0}', matrix.platform.features ) }} | |
RUSTDOCFLAGS: -Dwarnings | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
# Used to cache cargo-web | |
- name: Cache cargo folder | |
uses: actions/cache@v1 | |
with: | |
path: ~/.cargo | |
key: ${{ matrix.platform.target }}-cargo-${{ matrix.rust_version }} | |
- uses: hecrj/setup-rust-action@v1 | |
with: | |
rust-version: ${{ matrix.rust_version }}${{ matrix.platform.host }} | |
targets: ${{ matrix.platform.target }} | |
components: clippy | |
# We need those for examples. | |
- name: Install GCC Multilib | |
if: (matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686') | |
run: sudo apt-get update && sudo apt-get install gcc-multilib | |
- name: Install cargo-apk | |
if: contains(matrix.platform.target, 'android') | |
run: cargo +stable install cargo-apk | |
- name: Setup OpenHarmony SDK | |
id: setup_sdk | |
if: contains(matrix.platform.target, 'ohos') | |
uses: openharmony-rs/[email protected] | |
with: | |
version: "4.1" | |
components: "native;toolchains;ets;js;previewer" | |
- name: Install ohrs | |
if: contains(matrix.platform.target, 'ohos') | |
run: cargo +stable install ohrs | |
- name: Build tests | |
shell: bash | |
if: ${{ !contains(matrix.platform.target, 'ohos') }} | |
run: cargo $CMD test -p glutin --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES | |
- name: Build ohos tests | |
shell: bash | |
if: contains(matrix.platform.target, 'ohos') | |
run: ohrs cargo test -- -p glutin --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES | |
env: | |
OHOS_NDK_HOME: ${{ steps.setup_sdk.outputs.OHOS_BASE_SDK_HOME }} | |
- name: Run tests | |
shell: bash | |
if: ( | |
!contains(matrix.platform.target, 'android') && | |
!contains(matrix.platform.target, 'ios') && | |
!contains(matrix.platform.target, 'wasm32') && | |
!contains(matrix.platform.target, 'ohos')) | |
run: cargo test --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES | |
- name: Check documentation | |
shell: bash | |
run: cd glutin && cargo doc --no-deps --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES --document-private-items | |
- name: Lint with clippy | |
shell: bash | |
if: ( | |
(matrix.rust_version == '1.70.0') && | |
!contains(matrix.platform.options, '--no-default-features') && | |
!contains(matrix.platform.target, 'ohos')) | |
run: cargo clippy --workspace --all-targets --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES -- -Dwarnings | |