-
Notifications
You must be signed in to change notification settings - Fork 8
136 lines (130 loc) · 3.7 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
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:
CARGO_TERM_COLOR: always
defaults:
run:
shell: bash
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
run: rustup component add clippy rustfmt
- name: Lint (clippy)
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Lint (rustfmt)
run: cargo fmt --all --check
build:
name: Build and test
needs: lint
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: Install Cross
if: matrix.os == 'ubuntu-latest' && matrix.arch == 'aarch64'
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Setup environment
run: |
if [ "${{ matrix.os }}" = "macos-latest" ]; then
CARGO_CMD=cargo
CARGO_BUILD_TARGET="${{ matrix.arch }}-apple-darwin"
rustup target add $CARGO_BUILD_TARGET
else
if [ "${{ matrix.arch }}" = "aarch64" ]; then
CARGO_CMD=cross
else
CARGO_CMD=cargo
fi
CARGO_BUILD_TARGET="${{ matrix.arch }}-unknown-linux-gnu"
fi
echo "CARGO_CMD=$CARGO_CMD" >> $GITHUB_ENV
echo "CARGO_BUILD_TARGET=$CARGO_BUILD_TARGET" >> $GITHUB_ENV
- name: Build (maa-cli)
run: |
$CARGO_CMD build --package maa-cli --locked
- name: Test (maa-cli)
if: matrix.arch == 'x86_64' || matrix.os == 'ubuntu-latest'
run: |
$CARGO_CMD test --package maa-cli --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)"
RESOURCE_DIR="$(cargo run -- dir resource)"
cd "$MAA_CORE_DIR" || exit 1
ls -l "$MAA_CORE_DIR"
cd "$RESOURCE_DIR" || exit 1
ls -l "$RESOURCE_DIR"
echo "MAA_CORE_DIR=$MAA_CORE_DIR" >> $GITHUB_ENV
- name: Try run with MaaCore
if: matrix.arch == 'x86_64'
run: |
export DYLD_FALLBACK_LIBRARY_PATH="$MAA_CORE_DIR"
cargo run -- version
- name: Test (maa-sys, static)
if: matrix.arch == 'x86_64'
run: |
cargo test --package maa-sys --locked
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