-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (130 loc) · 4.89 KB
/
pr-main.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
156
157
158
159
160
161
162
163
164
165
166
167
name: PR Validation
on:
pull_request:
branches:
- main
push:
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
build-and-test:
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
command: cargo
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
command: cross
- os: windows-latest
target: x86_64-pc-windows-msvc
command: cargo
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Cache Cargo and cross
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ matrix.platform.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ matrix.platform.target }}-cargo
- name: Install cross
if: matrix.platform.command == 'cross'
run: |
if ! command -v cross &>/dev/null; then
cargo install cross
fi
- name: Build stable
id: build
run: ${{ matrix.platform.command }} build --target ${{ matrix.platform.target }};
- name: Test stable
id: test
run: ${{ matrix.platform.command }} test --target ${{ matrix.platform.target }};
- name: Set up Rust beta
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: beta
- name: Build beta
id: build-beta
run: ${{ matrix.platform.command }} +beta build --target ${{ matrix.platform.target }};
continue-on-error: true
- name: Test beta
id: test-beta
if: ${{ steps.build-beta.outcome == 'success' }}
run: ${{ matrix.platform.command }} +beta test --target ${{ matrix.platform.target }};
continue-on-error: true
- name: Set up Rust nightly
if: ${{ steps.build-beta.outcome == 'success' }}
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
- name: Build nightly
id: build-nightly
if: ${{ steps.build-beta.outcome == 'success' }}
run: ${{ matrix.platform.command }} +nightly build --target ${{ matrix.platform.target }};
continue-on-error: true
- name: Test nightly
id: test-nightly
if: ${{ steps.build-nightly.outcome == 'success' }}
run: ${{ matrix.platform.command }} +nightly test --target ${{ matrix.platform.target }};
continue-on-error: true
- name: Issue warnings for beta/ nightly fails
if: ${{ steps.build-beta.outcome == 'failure' || steps.test-beta.outcome == 'failure' || steps.build-nightly.outcome == 'failure' || steps.test-nightly.outcome == 'failure' }}
uses: actions/github-script@v7
with:
script: |
let body = "";
const beta_build_fail = ${{ steps.build-beta.outcome == 'failure' }};
const nightly_build_fail = ${{ steps.build-nightly.outcome == 'failure' }};
if (beta_build_fail || nightly_build_fail) {
const failed_toolchain = beta_build_fail ? "beta" : "nightly"
body = body.concat(`🚨 🛠️ Build Failures on **${failed_toolchain}** Rust with **${{ matrix.platform.target }}** target.\n`)
}
const beta_test_fail = ${{ steps.test-beta.outcome == 'failure' }};
const nightly_test_fail = ${{ steps.test-nightly.outcome == 'failure' }};
if (beta_test_fail || nightly_test_fail) {
let failed_toolchain = beta_build_fail ? "beta" : ""
if (nightly_test_fail) {
failed_toolchain = failed_toolchain.concat(" and nightly")
}
body = body.concat(`🚨 ❌ Test Failures on **${failed_toolchain}** Rust with **${{ matrix.platform.target }}** target.`)
}
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: body
});
format:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install nightly
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: rustfmt
- name: Format
run: cargo +nightly fmt --check
clippy:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Clippy lint
run: cargo clippy -- -D warnings