-
Notifications
You must be signed in to change notification settings - Fork 670
159 lines (155 loc) · 5.69 KB
/
cargo.yml
File metadata and controls
159 lines (155 loc) · 5.69 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: Cargo
on:
workflow_dispatch:
push:
branches:
- main
- release/*
pull_request:
branches:
- main
- release/*
permissions:
contents: read
pull-requests: write
jobs:
cargo:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-xlarge]
vec: [
{ tls: "quictls", features: "" },
{ tls: "quictls", features: "--features static" },
{ tls: "quictls", features: "--features quictls" },
{ tls: "quictls", features: "--features quictls,static" },
{ tls: "openssl", features: "--features openssl" },
{ tls: "openssl", features: "--features openssl,static" },
{ tls: "quictls", features: "--features overwrite" }
]
runs-on: ${{ matrix.os }}
name: Cargo
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Prepare Machine
run: scripts/prepare-machine.ps1 -Tls ${{ matrix.vec.tls }} -ForBuild -InstallTestCertificates
shell: pwsh
- name: Install Perl
if: runner.os == 'Windows'
uses: shogo82148/actions-setup-perl@a198315ec4e9244f206879ea7b63078003aec8a6
with:
perl-version: '5.34'
- name: Install NASM
if: runner.os == 'Windows'
uses: ilammy/setup-nasm@72793074d3c8cdda771dba85f6deafe00623038b
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: 1.91.1
components: rustfmt, clippy
- name: Cargo fmt
run: cargo fmt --all -- --check
- name: Cargo clippy
run: cargo clippy --all-targets ${{ matrix.vec.features }} -- -D warnings
- name: Cargo build
run: cargo build --all ${{ matrix.vec.features }}
- name: Check all generated files with git
id: bindings_diff
shell: bash
run: |
if git diff --exit-code >> cargo_binding_update.patch; then
echo "diff-found=false" >> $GITHUB_OUTPUT
else
echo "diff-found=true" >> $GITHUB_OUTPUT
{
echo 'diff-content<<@@@'
echo "$(cat cargo_binding_update.patch)"
echo '@@@'
} >> $GITHUB_OUTPUT
echo "$(cat cargo_binding_update.patch)"
fi
- name: Upload the patch file
if: steps.bindings_diff.outputs.diff-found == 'true'
id: upload_patch
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: cargo_binding_update_${{ matrix.os }}
path: cargo_binding_update.patch
- name: Post a comment on PR on mismatch
if: |
!github.event.pull_request.head.repo.fork &&
steps.bindings_diff.outputs.diff-found == 'true'
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.number }}
body: |
## ${{ github.workflow }} - ${{ matrix.os }}
The rust bindings need to be updated. Please apply (`git apply`) this [patch](${{ steps.upload_patch.outputs.artifact-url }}):
```diff
${{ steps.bindings_diff.outputs.diff-content }}
```
edit-mode: replace
- name: Fail if generated files are not up to date
if: steps.bindings_diff.outputs.diff-found == 'true'
run: exit 1
- name: Cargo test
run: cargo test --all ${{ matrix.vec.features }}
- name: Cargo Publish (dry run)
run: cargo publish --dry-run --allow-dirty --no-verify
- name: Validate crate size (< 10MB)
# Temporary: skip size check for OpenSSL TLS builds which currently exceed 10MiB.
# We still validate for other TLS configs (e.g., quictls) on ubuntu-latest.
if: matrix.os == 'ubuntu-latest' && matrix.vec.tls != 'openssl'
shell: bash
run: |
set -euo pipefail
# Create the crate package (source tarball)
cargo package --allow-dirty --no-verify
crate_file=$(ls -1 target/package/*.crate | head -n1)
if [[ -z "${crate_file:-}" ]]; then
echo "Error: No .crate file found under target/package" >&2
exit 1
fi
size_bytes=$(stat -c%s "$crate_file")
limit_bytes=$((10 * 1024 * 1024))
echo "Crate: $crate_file"
echo "Size: $size_bytes bytes"
if (( size_bytes > limit_bytes )); then
echo "Crate size exceeds 10MB limit (crates.io max). Please prune package contents." >&2
exit 1
fi
echo "Crate size is within limit."
# Test rust crate with preinstalled msquic lib.
cargo-preinstall:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
features: ["--no-default-features --features find"]
runs-on: ${{ matrix.os }}
name: Cargo-Preinstall
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: 1.91.1
components: rustfmt, clippy
- name: Install msquic from apt
run: |
wget -q https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb;
yes | sudo dpkg -i packages-microsoft-prod.deb;
sudo apt-get update;
sudo apt-get install -y libmsquic;
dpkg -L libmsquic;
- name: Cargo fmt
run: cargo fmt --all -- --check
- name: Cargo clippy
run: cargo clippy --all-targets ${{ matrix.features }} -- -D warnings
- name: Cargo build
run: cargo build --all ${{ matrix.features }}
- name: Cargo test
run: cargo test --all ${{ matrix.features }}