-
Notifications
You must be signed in to change notification settings - Fork 8
155 lines (150 loc) · 4.55 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: ./.github/actions/setup
with:
os: ${{ matrix.os }}
arch: ${{ matrix.arch }}
- 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: 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: 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
MAA_EXE: ${{ startsWith(matrix.os, 'windows') && 'maa.exe' || 'maa' }}
run: |
local_dir="local"
bin_dir="$local_dir/bin"
lib_dir="$local_dir/lib"
share_dir="$local_dir/share/maa"
mkdir -p "$local_dir"
mkdir -p "$bin_dir"
mkdir -p "$share_dir"
cp -v "target/$CARGO_BUILD_TARGET/debug/$MAA_EXE" "$bin_dir"
mv -v "$MAA_CORE_DIR" "$lib_dir"
mv -v "$MAA_RESOURCE_DIR" "$share_dir/resource"
ls -l "$local_dir"
ls -l "$local_dir/bin"
ls -l "$local_dir/lib"
ls -l "$share_dir"
$bin_dir/$MAA_EXE version
$bin_dir/$MAA_EXE run daily --dry-run --batch
- name: Cat MaaCore Log
if: matrix.arch == 'x86_64'
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: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Generate code coverage
run: |
cargo tarpaulin --all-features --workspace --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