-
Notifications
You must be signed in to change notification settings - Fork 8
135 lines (130 loc) · 3.59 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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
exclude:
# Failed to cross compile ring on Windows
- os: windows-latest
arch: aarch64
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: ${{ matrix.arch }}
coverage: true
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Build (maa-cli)
run: |
cargo build --package maa-cli --locked
- 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: Install MaaCore
if: matrix.arch == 'x86_64'
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
if: matrix.arch == 'x86_64'
run: |
cargo test
- name: Coverage
if: matrix.arch == 'x86_64'
run: |
cargo tarpaulin --all-features --workspace --timeout 120 --out xml ${{ github.run_attempt == 1 && '--skip-clean' || '' }}
- name: Upload to codecov.io
if: matrix.arch == 'x86_64'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
features:
name: Build and Test (no default features)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
features:
- --features core_installer
- --features cli_installer
- ""
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: feature-${{ matrix.features }}
- name: Build
run: |
cargo build --package maa-cli --no-default-features ${{ matrix.features }} --locked
- name: Test
run: |
cargo test