-
Notifications
You must be signed in to change notification settings - Fork 1
159 lines (131 loc) · 4.02 KB
/
ci.yml
File metadata and controls
159 lines (131 loc) · 4.02 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
name: CI
on:
push:
pull_request:
permissions:
contents: read
jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check commit messages
env:
CI_COMMIT_BEFORE: ${{ github.event.before }}
CI_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
CI_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: ./scripts/check-commit-messages.sh
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Rustfmt
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Test
run: cargo test --all-targets --all-features
coverage:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Coverage
run: ./scripts/check-coverage.sh
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/coverage/lcov.info
disable_search: true
fail_ci_if_error: true
- name: Upload coverage artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
target/coverage/lcov.info
target/coverage/html
if-no-files-found: error
release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs:
- lint-and-test
- coverage
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Prepare release assets
env:
GIT_TAG: ${{ github.ref_name }}
run: ./scripts/package-release-assets.sh "${GIT_TAG}" dist/release
- name: Generate release notes
env:
GIT_TAG: ${{ github.ref_name }}
run: ./scripts/generate-release-notes.sh "${GIT_TAG}" dist/release/release-notes.md
- name: Publish release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_TAG: ${{ github.ref_name }}
run: |
release_title="CRIEW ${GIT_TAG}"
notes_file="dist/release/release-notes.md"
tar_asset="dist/release/criew-${GIT_TAG}-src.tar.gz"
zip_asset="dist/release/criew-${GIT_TAG}-src.zip"
if gh release view "${GIT_TAG}" >/dev/null 2>&1; then
gh release upload "${GIT_TAG}" \
"${tar_asset}" \
"${zip_asset}" \
--clobber
gh release edit "${GIT_TAG}" \
--title "${release_title}" \
--notes-file "${notes_file}"
else
gh release create "${GIT_TAG}" \
"${tar_asset}" \
"${zip_asset}" \
--title "${release_title}" \
--notes-file "${notes_file}"
fi