-
Notifications
You must be signed in to change notification settings - Fork 4
197 lines (179 loc) · 5.92 KB
/
ci.yaml
File metadata and controls
197 lines (179 loc) · 5.92 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
193
194
195
196
197
name: ci
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
permissions:
contents: read
pull-requests: read
packages: write
concurrency:
# Support push/pr as event types with different behaviors each:
# 1. push: queue up builds
# 2. pr: only allow one run per PR
group: ${{ github.workflow }}-${{ github.event_name }}${{ github.event.pull_request.number }}
# If there is already a workflow running for the same pull request, cancel it
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
RUST_STABLE: 1.89.0
RUST_NIGHTLY: nightly-2025-08-07
jobs:
changed-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changed
with:
filters: |
rust:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
cargo-toml:
- '**/Cargo.toml'
rustfmt-toml:
- 'rustfmt.toml'
clippy-toml:
- 'clippy.toml'
deny-toml:
- 'deny.toml'
dockerfile:
- 'Dockerfile'
- 'infra/Dockerfile.*'
version:
- 'VERSION'
outputs:
rust: ${{ steps.changed.outputs.rust }}
cargo-toml: ${{ steps.changed.outputs.cargo-toml }}
rustfmt-toml: ${{ steps.changed.outputs.rustfmt-toml }}
clippy-toml: ${{ steps.changed.outputs.clippy-toml }}
deny-toml: ${{ steps.changed.outputs.deny-toml }}
dockerfile: ${{ steps.changed.outputs.dockerfile }}
version: ${{ steps.changed.outputs.version }}
bump-version:
needs: [changed-files]
if: github.event_name == 'pull_request' && (needs.changed-files.outputs.rust == 'true' || needs.changed-files.outputs.dockerfile == 'true')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: "main"
- id: get-current-version
run: echo MAIN_VERSION=$(cat VERSION) >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
token: ${{ secrets.RELEASE_PAT }}
- id: bump-version
run: |
MAIN_MAJOR=$(echo "$MAIN_VERSION" | cut -d. -f1)
MAIN_MINOR=$(echo "$MAIN_VERSION" | cut -d. -f2)
TODAY=$(date +"%y%m%d")
if [[ $MAIN_MAJOR == $TODAY ]]; then
NEW_VERSION=$MAIN_MAJOR.$((MAIN_MINOR + 1))
else
NEW_VERSION=$TODAY.0
fi
LOCAL_VERSION=$(cat VERSION)
if [[ $LOCAL_VERSION == $NEW_VERSION ]]; then
exit 0
fi
echo "${NEW_VERSION}" > VERSION
git config user.name "Github Bot"
git config user.email "github@walletconnect.com"
git add VERSION
git commit -m "Bump VERSION to ${NEW_VERSION}"
git push
misspell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-misspell@v1
cargo-build:
needs: [changed-files]
if: needs.changed-files.outputs.rust == 'true'
runs-on:
group: ubuntu-runners
steps:
- uses: actions/checkout@v4
- run: bash .github/install-deps.sh
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_STABLE }}
- uses: Swatinem/rust-cache@v2
- run: cargo build --workspace --all-features
# Check that `wcn_operator` specifically builds outside of the cargo workspace
- run: cargo build -p wcn_operator
cargo-test:
needs: [changed-files]
if: needs.changed-files.outputs.rust == 'true'
timeout-minutes: 30
runs-on:
group: ubuntu-runners
strategy:
fail-fast: false
matrix:
test: [doc, unit, integration]
steps:
- uses: actions/checkout@v4
- run: bash .github/install-deps.sh
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_STABLE }}
- uses: Swatinem/rust-cache@v2
- uses: foundry-rs/foundry-toolchain@v1
with:
version: stable
cache: true
- run: |
TEST_KIND=${{ matrix.test }}
if [[ $TEST_KIND == 'doc' ]] ; then
cargo test --workspace --doc --all-features
elif [[ $TEST_KIND == 'unit' ]]; then
RUST_LOG=info cargo test --all-features --workspace --exclude wcn_testing
elif [[ $TEST_KIND == 'integration' ]]; then
RUST_LOG=info,relay_rocks=warn cargo test -p wcn_testing --all-features --release
else
echo Unexpected test kind $TEST_KIND
exit 1
fi
cargo-fmt:
needs: [changed-files]
if: needs.changed-files.outputs.rust == 'true' || needs.changed-files.outputs.rustfmt-toml == 'true'
runs-on:
group: ubuntu-runners
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_NIGHTLY }}
components: rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all --check
cargo-clippy:
needs: [changed-files]
if: needs.changed-files.outputs.rust == 'true' || needs.changed-files.outputs.clippy-toml == 'true'
runs-on:
group: ubuntu-runners
steps:
- uses: actions/checkout@v4
- run: bash .github/install-deps.sh
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_NIGHTLY }}
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --workspace --all-targets --all-features --tests -- -D warnings
cargo-deny:
needs: [changed-files]
if: needs.changed-files.outputs.cargo-toml == 'true' || needs.changed-files.outputs.deny-toml == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
rust-version: ${{ env.RUST_STABLE }}
command: check license