ci: build without cross #303
Workflow file for this run
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: | |
- "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 | |
arch: | |
- x86_64 | |
- aarch64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: ./.github/actions/setup | |
with: | |
os: ${{ matrix.os }} | |
arch: ${{ matrix.arch }} | |
- name: Lint (clippy) | |
if: matrix.arch == 'x86_64' | |
run: | | |
cargo clippy --all-targets --all-features -- -D warnings | |
- name: Lint (rustfmt) | |
if: matrix.arch == 'x86_64' | |
run: | | |
cargo fmt --all -- --check | |
- name: Build (maa-cli) | |
run: | | |
cargo build --package maa-cli --locked | |
- name: Test (maa-cli) | |
if: matrix.arch == 'x86_64' | |
run: | | |
cargo test --package maa-cli --locked | |
- name: Test (maa-cli, no-default-features) | |
if: matrix.arch == 'x86_64' | |
run: | | |
cargo test --package maa-cli --no-default-features --locked | |
- name: Install MaaCore | |
if: matrix.arch == 'x86_64' | |
env: | |
MAA_API_URL: https://github.com/MaaAssistantArknights/MaaRelease/raw/main/MaaAssistantArknights/api/version | |
run: | | |
cargo run -- install beta -t0 | |
- name: Show installation | |
if: matrix.arch == 'x86_64' | |
run: | | |
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: Test (maa-sys) | |
# It seems rust needs a static library to check the linking. | |
# Without this, we can not build maa-sys on Windows. | |
# https://stackoverflow.com/questions/63394094/rust-linker-seeks-a-lib-rather-than-a-dll | |
if: matrix.arch == 'x86_64' && matrix.os != 'windows-latest' | |
run: | | |
cargo test --package maa-sys --locked | |
- name: Run with MaaCore (default path) | |
if: matrix.arch == 'x86_64' | |
timeout-minutes: 1 | |
continue-on-error: ${{ matrix.os == 'windows-latest' }} | |
env: | |
MAA_CONFIG_DIR: ${{ github.workspace }}/config_examples | |
run: | | |
cargo run -- version | |
cargo run -- run daily --dry-run --batch | |
- name: Run with MaaCore (relative path) | |
if: matrix.arch == 'x86_64' | |
timeout-minutes: 1 | |
continue-on-error: ${{ matrix.os == 'windows-latest' }} | |
env: | |
MAA_CONFIG_DIR: ${{ github.workspace }}/config_examples | |
run: | | |
target_dir="target/${CARGO_BUILD_TARGET}" | |
lib_dir="$target_dir/lib" | |
share_dir="$target_dir/share/maa" | |
mv "$MAA_CORE_DIR" "$lib_dir" | |
ls -l "$lib_dir" | |
mkdir -p "$share_dir" | |
mv "$MAA_RESOURCE_DIR" "$share_dir/resource" | |
ls -l "$share_dir" | |
cargo run -- version | |
cargo run -- run daily --dry-run --batch | |
- name: Cat MaaCore Log if failed | |
if: failure() | |
run: | | |
cat "$(cargo run -- dir log)/asst.log" | |
coverage: | |
name: Coverage | |
needs: build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Cargo tarpaulin | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-tarpaulin | |
- name: Generate code coverage | |
run: | | |
cargo tarpaulin --all-features --workspace --timeout 120 --out xml | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v3 | |
with: | |
fail_ci_if_error: true |