feat: add serialize for TouchMode and TaskType enum #1048
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: | |
push: | |
branches: ["main"] | |
paths: | |
- "*/src/**" | |
- "*/Cargo.toml" | |
- "*/build.rs" | |
- "Cargo.lock" | |
- "codecov.yml" | |
- ".github/workflows/ci.yml" | |
- ".github/actions/setup/**" | |
- ".github/actions/install-core/**" | |
pull_request: | |
branches: ["main"] | |
paths: | |
- "*/src/**" | |
- "*/Cargo.toml" | |
- "*/build.rs" | |
- "Cargo.lock" | |
- "codecov.yml" | |
- ".github/workflows/ci.yml" | |
- ".github/actions/setup/**" | |
- ".github/actions/install-core/**" | |
env: | |
RUST_BACKTRACE: full | |
CARGO_TERM_COLOR: always | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-13 # x86_64 runner | |
- macos-14 # aarch64 runner | |
- windows-latest | |
env: | |
MAA_EXTRA_SHARE_NAME: maa-test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Build (maa-cli) | |
run: | | |
cargo build --package maa-cli --locked | |
- name: Lint (clippy) | |
run: | | |
cargo clippy --package maa-cli -- -D warnings | |
- name: Lint (rustfmt) | |
run: | | |
rustup toolchain install nightly -c rustfmt | |
cargo +nightly fmt --package maa-cli -- --check | |
- name: Install MaaCore | |
env: | |
MAA_CONFIG_DIR: ${{ github.workspace }}/maa-cli/config_examples | |
run: | | |
cargo run -- install beta | |
core_dir=$(cargo run -- dir library) | |
resource_dir=$(cargo run -- dir resource) | |
cache_dir=$(cargo run -- dir cache) | |
package_name=$(basename "$cache_dir"/MAA-v*) | |
version=${package_name#MAA-v} | |
version=${version%%-linux*} | |
version=${version%%-macos*} | |
version=${version%%-win*} | |
ls -l "$core_dir" | |
ls -l "$resource_dir" | |
ls -l "$cache_dir" | |
echo "Downloaded MaaCore version: $version" | |
{ | |
echo "MAA_CORE_DIR=$core_dir" | |
echo "MAA_RESOURCE_DIR=$resource_dir" | |
echo "MAA_CORE_VERSION=v$version" | |
} >> "$GITHUB_ENV" | |
- name: Test | |
run: | | |
cargo test -- --include-ignored | |
build-cross: | |
name: Cross Build to aarch64 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Cross Compilation Toolchains | |
uses: ./.github/actions/setup | |
with: | |
os: ${{ matrix.os }} | |
target_arch: aarch64 | |
- name: Build | |
run: | | |
cargo build --package maa-cli --locked \ | |
--features vendored-openssl | |
build-feature: | |
name: Build and Test (no default features) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-14 | |
- windows-latest | |
feature: | |
- core_installer # disabled cli_installer and git2, used by package manager | |
- git2 # disabled both cli_installer and core_installer, used by appimage | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build | |
run: | | |
cargo build --package maa-cli --locked \ | |
--no-default-features --features '${{ matrix.feature }}' | |
- name: Test | |
env: | |
SKIP_CORE_TEST: true | |
run: | | |
cargo test -- --include-ignored | |
build-sys: | |
name: Build and Test (maa-sys, static) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-13 # x86_64 runner | |
- macos-14 # aarch64 runner | |
- windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install MaaCore | |
uses: ./.github/actions/install-core | |
- name: Build | |
run: cargo build --package maa-sys --locked | |
- name: Lint (clippy) | |
run: cargo clippy --package maa-sys -- -D warnings | |
- name: Lint (fmt) | |
run: | | |
rustup toolchain install nightly -c rustfmt | |
cargo +nightly fmt --package maa-sys -- --check | |
- name: Test | |
# It seems rust needs a static library to check the linking. | |
# Without this, we can not link maa-sys to MaaCore on Windows. | |
# https://stackoverflow.com/questions/63394094/rust-linker-seeks-a-lib-rather-than-a-dll | |
if: ${{ !startsWith(matrix.os, 'windows') }} | |
run: cargo test --package maa-sys | |
coverage: | |
name: Coverage | |
needs: [build, build-sys] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-14 # aarch64 runner | |
- windows-latest | |
env: | |
MAA_EXTRA_SHARE_NAME: maa-test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Cargo tarpaulin | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-tarpaulin | |
- name: Install MaaCore | |
uses: ./.github/actions/install-core | |
- name: Setup Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Coverage | |
run: | | |
cargo tarpaulin --out xml --workspace --timeout 120 \ | |
${{ github.run_attempt == 1 && '--skip-clean' || '' }} \ | |
-- --include-ignored | |
- name: Upload to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true |