Skip to content

refactor: rename Value to MAAValue #495

refactor: rename Value to MAAValue

refactor: rename Value to MAAValue #495

Workflow file for this run

name: CI
on:
push:
branches: [ "main" ]
paths:
- "maa-cli/**"
- "maa-sys/**"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/ci.yml"
pull_request:
branches: [ "main" ]
paths:
- "maa-cli/**"
- "maa-sys/**"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/ci.yml"
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-latest
- windows-latest
env:
MAA_EXTRA_SHARE_NAME: maa-test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: ./.github/actions/setup
with:
os: ${{ matrix.os }}
arch: x86_64
coverage: true
- 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 -- -D warnings
- name: Lint (rustfmt)
run: |
cargo fmt --all -- --check
- name: Install MaaCore
env:
MAA_CONFIG_DIR: ${{ github.workspace }}/config_examples
run: |
cargo run -- install stable
ls -l "$(cargo run -- dir library)"
ls -l "$(cargo run -- dir resource)"
ls -l "$(cargo run -- dir cache)"
package_name=$(basename "$(ls "$(cargo run -- dir cache)")")
echo "Downloaded MaaCore package: $package_name"
version=${package_name#MAA-v}
version=${version%%-*}
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Downloaded MaaCore version: $version"
echo "MAA_CORE_VERSION=v$version" >> "$GITHUB_ENV"
fi
echo "MAA_CORE_INSTALLED=true" >> "$GITHUB_ENV"
- name: Test
run: |
cargo test
- name: Coverage
run: |
cargo tarpaulin --packages maa-cli --timeout 120 --out xml \
${{ github.run_attempt == 1 && '--skip-clean' || '' }}
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
build-aarch64:
name: Build (aarch64)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: ./.github/actions/setup
with:
os: ${{ matrix.os }}
arch: aarch64
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- 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-latest
- 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: Setup Rust
uses: ./.github/actions/setup
with:
os: ${{ matrix.os }}
arch: x86_64
- name: Setup Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.feature }}
- name: Build
run: |
cargo build --package maa-cli --locked \
--no-default-features --features ${{ matrix.feature }}
- name: Test
run: |
cargo test
build-sys:
name: Build and test (maa-sys, static)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: ./.github/actions/setup
with:
os: ${{ matrix.os }}
arch: x86_64
coverage: true
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Install MaaCore
env:
MAA_CONFIG_DIR: ${{ github.workspace }}/config_examples
run: |
cargo run -- install stable -t0
MAA_CORE_DIR="$(cargo run -- dir lib)"
MAA_RESOURCE_DIR="$(cargo run -- dir resource)"
ls -l "$MAA_CORE_DIR"
ls -l "$MAA_RESOURCE_DIR"
echo "MAA_CORE_DIR=$MAA_CORE_DIR" >> $GITHUB_ENV
echo "MAA_RESOURCE_DIR=$MAA_RESOURCE_DIR" >> $GITHUB_ENV
- name: Build
run: cargo build --package maa-sys --locked
- name: Lint (clippy)
run: cargo clippy --package maa-sys -- -D warnings
- name: Lint (fmt)
run: cargo 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
- name: Coverage
if: ${{ !startsWith(matrix.os, 'windows') }}
run: |
cargo tarpaulin --packages maa-sys --timeout 120 --out xml \
${{ github.run_attempt == 1 && '--skip-clean' || '' }}
- name: Upload to codecov.io
if: ${{ !startsWith(matrix.os, 'windows') }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true