-
Notifications
You must be signed in to change notification settings - Fork 0
192 lines (164 loc) · 4.46 KB
/
Copy pathci.yml
File metadata and controls
192 lines (164 loc) · 4.46 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: ci
permissions:
contents: read
packages: read
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
env:
CARGO_TERM_COLOR: always
GITHUB_ACTOR: pop-mcp
CARGO_INCREMENTAL: 1
RUST_BACKTRACE: 1
RUSTFLAGS: "-Dwarnings"
RUSTDOCFLAGS: "-Dwarnings"
concurrency:
# Cancel any in-progress jobs for the same pull request or branch
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
setup:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.out.outputs.image }}
rust_version: ${{ steps.out.outputs.rust_version }}
steps:
- uses: actions/checkout@v4
- name: Install yq
uses: mikefarah/yq@v4.44.1
- name: Set environment variables
id: out
run: |
set -xeuo pipefail
HASH=$(sha256sum Dockerfile.ci | cut -d ' ' -f 1)
RUST_VERSION=$(yq -r '.toolchain.channel' rust-toolchain.toml)
echo "rust_version=$RUST_VERSION" >> "$GITHUB_OUTPUT"
echo "image=ghcr.io/${GITHUB_REPOSITORY,,}:${RUST_VERSION}-${HASH}" >> "$GITHUB_OUTPUT"
prepare-ci-image:
needs:
- setup
uses: ./.github/workflows/docker-ci.yml
permissions:
contents: read
packages: write
with:
docker_image: ${{ needs.setup.outputs.image }}
rust_version: ${{ needs.setup.outputs.rust_version }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
components: rustfmt
override: true
- name: Check formatting
run: cargo +nightly fmt --all -- --check
build:
needs:
- setup
- lint
- prepare-ci-image
runs-on: ubuntu-latest
container:
image: ${{ needs.setup.outputs.image }}
steps:
- uses: actions/checkout@v4
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
shared-key: shared-${{ github.head_ref || github.ref_name }}
- name: Check no default features
run: cargo check --locked --no-default-features
- name: Check all features
run: cargo check --locked --all-features
- name: Check default features
run: cargo check --locked
tests:
needs:
- setup
- lint
- prepare-ci-image
runs-on: ubuntu-latest
container:
image: ${{ needs.setup.outputs.image }}
steps:
- uses: actions/checkout@v4
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: shared-tests-${{ github.head_ref || github.ref_name }}
- name: Run tests
run: cargo test --locked
clippy:
needs:
- build
- setup
runs-on: ubuntu-latest
container:
image: ${{ needs.setup.outputs.image }}
permissions:
checks: write
packages: read
steps:
- uses: actions/checkout@v4
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
save-if: false
shared-key: shared-${{ github.head_ref || github.ref_name }}
- name: Annotate with Clippy warnings
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets -- -D warnings
docs:
needs:
- setup
- build
runs-on: ubuntu-latest
container:
image: ${{ needs.setup.outputs.image }}
permissions:
checks: write
packages: read
env:
# We cannot propagate the "missing_docs" flag, as otherwise other tests fail.
RUSTFLAGS: "-Dwarnings -Dmissing_docs"
steps:
- uses: actions/checkout@v4
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
save-if: false
shared-key: shared-docs-${{ github.head_ref || github.ref_name }}
- name: Check no default features
run: cargo doc --locked --no-deps
documentation-tests:
needs:
- setup
- build
runs-on: ubuntu-latest
container:
image: ${{ needs.setup.outputs.image }}
steps:
- uses: actions/checkout@v4
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
save-if: false
shared-key: shared-${{ github.head_ref || github.ref_name }}
- name: Run doc tests
run: cargo test --locked --doc