-
Notifications
You must be signed in to change notification settings - Fork 39
187 lines (161 loc) · 4.51 KB
/
ci.yml
File metadata and controls
187 lines (161 loc) · 4.51 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
name: ci
permissions:
contents: read
packages: read
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
paths-ignore:
- '**.md'
- 'docs/**'
- 'LICENSE'
- '.gitignore'
- '.github/**.md'
env:
CARGO_TERM_COLOR: always
GITHUB_ACTOR: pop-cli
CARGO_INCREMENTAL: 1
RUST_BACKTRACE: 1
# It is important to always use the same flags. Otherwise, the cache will not work.
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:
lint:
uses: ./.github/workflows/lint.yml
setup:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.out.outputs.image }}
rust_version: ${{ steps.out.outputs.rust_version }}
steps:
- uses: actions/checkout@v4
- name: Set environment variables
id: out
env:
HASH: ${{ hashFiles('Dockerfile.ci') }}
run: |
set -xeuo pipefail
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 }}
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: pop-cache
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check no default features
run: cargo check --locked --no-default-features
- name: Check contract feature
run: cargo check --locked --no-default-features --features contract
- name: Check chain feature
run: cargo check --locked --no-default-features --features chain
- name: Check default features
run: cargo check --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: pop-cache
- name: Annotate with Clippy warnings
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --no-default-features --features telemetry,contract,chain --all-targets -- -D warnings
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/build-push-action@v5
with:
context: .
docs:
needs:
- setup
- build
runs-on: ubuntu-latest
container:
image: ${{ needs.setup.outputs.image }}
permissions:
checks: write
packages: read
env:
# We cannot propagate the "mising_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:
shared-key: pop-cache-docs
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check all features
run: cargo doc --locked --no-default-features --features telemetry,contract,chain --no-deps
documentation-tests:
needs:
- setup
- build
runs-on: ubuntu-latest
container:
image: ${{ needs.setup.outputs.image }}
volumes:
- /:/host
steps:
- name: Free disk space
run: |
rm -rf /host/usr/share/dotnet
rm -rf /host/usr/local/lib/android
rm -rf /host/opt/ghc
rm -rf /host/opt/hostedtoolcache/CodeQL
df -h
- uses: actions/checkout@v4
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
save-if: false
shared-key: pop-cache
- name: Run doc tests
run: cargo test --locked --no-default-features --features telemetry,contract,chain --doc