-
Notifications
You must be signed in to change notification settings - Fork 90
157 lines (139 loc) · 5.13 KB
/
check.yaml
File metadata and controls
157 lines (139 loc) · 5.13 KB
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
156
157
name: check
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
inputs:
target:
description: '指定 target(留空跑全部)'
required: false
default: ''
phase:
description: 'check / feature / test / mutant / profile / all'
required: false
default: 'all'
toolchain:
description: 'Rust toolchain (e.g. nightly-2024-09-18)'
required: false
default: 'nightly-2024-09-18'
permissions:
contents: read
jobs:
check-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-musl
- x86_64-pc-windows-gnu
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Detect legacy check scripts
id: legacy_check
shell: bash
run: |
if [[ -f scripts/check/check.sh && -f scripts/check/profile.sh ]]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Legacy scripts/check not found, skip legacy check steps."
fi
- name: Install Rust toolchain
if: steps.legacy_check.outputs.exists == 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ github.event.inputs.toolchain || 'nightly-2024-09-18' }}
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: steps.legacy_check.outputs.exists == 'true'
run: |
sudo apt-get update
sudo apt-get install -y gcc-mingw-w64-x86-64 musl-tools protobuf-compiler
sudo ln -sf /usr/bin/musl-gcc /usr/local/bin/x86_64-linux-musl-gcc
- name: Rust cache
if: steps.legacy_check.outputs.exists == 'true'
uses: Swatinem/rust-cache@v2
with:
shared-key: "check-${{ matrix.target }}"
cache-targets: true
cache-all-crates: true
save-if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
- name: Fix line endings
if: steps.legacy_check.outputs.exists == 'true'
run: |
sudo apt-get install -y dos2unix 2>/dev/null || true
find scripts/check -name '*.sh' -exec dos2unix {} + 2>/dev/null || \
find scripts/check -name '*.sh' -exec sed -i 's/\r$//' {} +
- name: Determine phase
id: phase
if: steps.legacy_check.outputs.exists == 'true'
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "value=${{ github.event.inputs.phase || 'all' }}" >> $GITHUB_OUTPUT
else
echo "value=test" >> $GITHUB_OUTPUT
fi
- name: Run checks
if: steps.legacy_check.outputs.exists == 'true'
run: |
chmod +x scripts/check/check.sh scripts/check/profile.sh
./scripts/check/check.sh --target ${{ matrix.target }} --phase ${{ steps.phase.outputs.value }} --ci
check-darwin:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Detect legacy check scripts
id: legacy_check
shell: bash
run: |
if [[ -f scripts/check/check.sh && -f scripts/check/profile.sh ]]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Legacy scripts/check not found, skip legacy check steps."
fi
- name: Install protobuf
if: steps.legacy_check.outputs.exists == 'true'
run: brew install protobuf
- name: Install Rust toolchain
if: steps.legacy_check.outputs.exists == 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ github.event.inputs.toolchain || 'nightly-2024-09-18' }}
- name: Rust cache
if: steps.legacy_check.outputs.exists == 'true'
uses: Swatinem/rust-cache@v2
with:
shared-key: "check-aarch64-apple-darwin"
cache-targets: true
cache-all-crates: true
save-if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
- name: Fix line endings
if: steps.legacy_check.outputs.exists == 'true'
run: |
find scripts/check -name '*.sh' -exec sed -i '' 's/\r$//' {} +
- name: Determine phase
id: phase
if: steps.legacy_check.outputs.exists == 'true'
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "value=${{ github.event.inputs.phase || 'all' }}" >> $GITHUB_OUTPUT
else
echo "value=test" >> $GITHUB_OUTPUT
fi
- name: Run checks
if: steps.legacy_check.outputs.exists == 'true'
run: |
chmod +x scripts/check/check.sh scripts/check/profile.sh
./scripts/check/check.sh --target aarch64-apple-darwin --phase ${{ steps.phase.outputs.value }} --ci