-
Notifications
You must be signed in to change notification settings - Fork 19
211 lines (197 loc) · 8.49 KB
/
ci.yml
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: CI
on: [push]
env:
CROSS_VERSION: 0.2.5
RUST_VERSION: 1.67.0
PIPING_SERVER_CHECK_VERSION: 0.14.0
jobs:
cargo_fmt:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: cargo fmt --all -- --check
cargo_test:
strategy:
matrix:
runs-on:
- ubuntu-22.04
- macOS-13
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- run: cargo test -- --color=always --nocapture
# MSRV (minimum supported Rust version)
cargo_test_msrv:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: rustup default 1.65.0
- run: cargo test -- --color=always --nocapture
cross_build:
strategy:
max-parallel: 8
matrix:
target:
- aarch64-unknown-linux-musl
- arm-linux-androideabi
- arm-unknown-linux-musleabi
- arm-unknown-linux-musleabihf
- armv5te-unknown-linux-musleabi
- armv7-linux-androideabi
- armv7-unknown-linux-musleabihf
- armv7-unknown-linux-musleabi
- i586-unknown-linux-musl
- i686-linux-android
- i686-unknown-linux-musl
- x86_64-linux-android
- x86_64-pc-windows-gnu
- x86_64-unknown-linux-musl
runs-on: ubuntu-22.04
steps:
- run: rustup default ${RUST_VERSION}
- uses: actions/checkout@v4
- name: Install cross
run: cd /tmp && curl -L https://github.com/cross-rs/cross/releases/download/v${CROSS_VERSION}/cross-x86_64-unknown-linux-musl.tar.gz | tar xzf -
- run: /tmp/cross build --target=${{ matrix.target }} --release --locked
- name: Archive binary
run: |
set -eu
mkdir ./piping-server-${{ matrix.target }}
if [[ "${{ matrix.target }}" == *"-windows-"* ]]; then
cp ./target/${{ matrix.target }}/release/piping-server.exe ./piping-server-${{ matrix.target }}
zip -r ./piping-server-${{ matrix.target }}.zip ./piping-server-${{ matrix.target }}
else
cp ./target/${{ matrix.target }}/release/piping-server ./piping-server-${{ matrix.target }}
tar zcf ./piping-server-${{ matrix.target }}.tar.gz ./piping-server-${{ matrix.target }}
fi
- uses: actions/upload-artifact@v4
with:
name: build_artifact_${{ matrix.target }}
path: |
piping-server-*.tar.gz
piping-server-*.zip
linux_operational_test:
needs:
- cross_build
runs-on: ubuntu-22.04
steps:
- name: Download the artifact
uses: actions/download-artifact@v4
with:
name: build_artifact_x86_64-unknown-linux-musl
- name: Extract binary
run: tar xf piping-server-x86_64-unknown-linux-musl.tar.gz
- name: Operational test
run: |
set -xeu
# Create certificates
(mkdir ssl_certs && cd ssl_certs && openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -sha256 -nodes --subj '/CN=localhost/')
# Run a server
./piping-server-x86_64-unknown-linux-musl/piping-server --http-port=8181 --enable-https --https-port=8443 --crt-path=./ssl_certs/server.crt --key-path=./ssl_certs/server.key &
sleep 3
# Transfer data over HTTP
echo "hello, world" | curl -T - localhost:8181/mypath &
diff <(echo "hello, world") <(curl localhost:8181/mypath)
# Make a large random file
dd if=/dev/urandom iflag=count_bytes count=500M bs=1M of=/tmp/500M.dat
# Transfer large data over HTTP
cat /tmp/500M.dat | curl -T - localhost:8181/mypath &
diff <(cat /tmp/500M.dat) <(curl localhost:8181/mypath)
rm /tmp/500M.dat
# Transfer data over HTTPS
echo "hello, world with HTTPS" | curl -kT - https://localhost:8443/mypath2 &
diff <(echo "hello, world with HTTPS") <(curl -k https://localhost:8443/mypath2)
# Make a large random file
dd if=/dev/urandom iflag=count_bytes count=500M bs=1M of=/tmp/500M.dat
# Transfer large data over HTTPS
cat /tmp/500M.dat | curl -kT - https://localhost:8443/mypath2 &
diff <(cat /tmp/500M.dat) <(curl -k https://localhost:8443/mypath2)
rm /tmp/500M.dat
# HTTP/2 support
(echo hello | curl -ksST- https://localhost:8443/mypath3 -o /dev/null -w '%{http_version}:%{http_code}\n' > /tmp/http2_post.txt) &
post_pid=$!
diff <(echo '2:200') <(curl -ksS https://localhost:8443/mypath3 -o /dev/null -w '%{http_version}:%{http_code}\n')
wait $post_pid
diff <(echo '2:200') /tmp/http2_post.txt
# Transfer data using multipart
# Make a large random file
dd if=/dev/urandom iflag=count_bytes count=500M bs=1M of=/tmp/500M.dat
# Transfer large data over HTTP
curl -F myfile=@/tmp/500M.dat localhost:8181/mypath3 &
diff <(cat /tmp/500M.dat) <(curl localhost:8181/mypath3)
rm /tmp/500M.dat
timeout-minutes: 1
build_for_mac:
strategy:
matrix:
target:
- x86_64-apple-darwin
- aarch64-apple-darwin
runs-on: macOS-13
steps:
- run: rustup default ${RUST_VERSION}
- uses: actions/checkout@v4
- run: rustup target add ${{ matrix.target }}
- run: cargo build --target=${{ matrix.target }} --release --locked
- name: Archive binary
run: |
set -eu
mkdir ./piping-server-${{ matrix.target }}
cp ./target/${{ matrix.target }}/release/piping-server ./piping-server-${{ matrix.target }}
tar zcf ./piping-server-${{ matrix.target }}.tar.gz ./piping-server-${{ matrix.target }}
- uses: actions/upload-artifact@v4
with:
name: build_artifact_${{ matrix.target }}
path: |
piping-server-*.tar.gz
docker:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: docker build -t piping-server-rust .
- name: Create certificates
run: cd /tmp && mkdir ssl_certs && cd ssl_certs && openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -sha256 -nodes --subj '/CN=localhost/'
- name: Install piping-server-check
run: cd /tmp && wget -O piping-server-check.deb https://github.com/nwtgck/piping-server-check/releases/download/v${PIPING_SERVER_CHECK_VERSION}/piping-server-check-${PIPING_SERVER_CHECK_VERSION}-linux-amd64.deb && sudo dpkg -i piping-server-check.deb
- name: piping-server-check
run: piping-server-check --http1.1 --http1.1-tls --h2c --h2 --tls-skip-verify --compromise post_cancel_post --compromise get_cancel_get --concurrency 100 --server-command='mkdir -p /tmp/logs && exec docker run -p $HTTP_PORT:8080 -p $HTTPS_PORT:8443 -v /tmp/ssl_certs:/tmp/ssl_certs piping-server-rust --http-port=8080 --enable-https --https-port=8443 --crt-path=/tmp/ssl_certs/server.crt --key-path=/tmp/ssl_certs/server.key 2>&1 | tee /tmp/logs/$(date "+%s%3N").log > /dev/stderr' --transfer-speed-byte $((1024 * 1024 * 1024 * 1024)) --transfer-span 3s --transfer-span 10s --transfer-span 1m --transfer-span 2m --transfer-span 3m --transfer-span 4m
timeout-minutes: 6
- name: Show server logs from piping-server-check
run: cat /tmp/logs/*
- uses: docker/login-action@v3
with:
username: nwtgck
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Push if branch is develop
if: github.ref == 'refs/heads/develop'
run: |
set -eu
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
docker tag piping-server-rust nwtgck/piping-server-rust:${GIT_BRANCH}
docker push nwtgck/piping-server-rust:${GIT_BRANCH}
release_if_tag_exits:
needs:
- cargo_fmt
- cargo_test
- linux_operational_test
- build_for_mac
runs-on: ubuntu-22.04
steps:
- name: Download the artifacts
uses: actions/download-artifact@v4
with:
pattern: build_artifact_*
path: ./publish_dir
merge-multiple: true
- run: ls -la ./publish_dir
- name: Release
if: contains(github.ref, 'refs/tags/')
run: |
set -eux
# Show and create checksums
(cd publish_dir && sha256sum * | tee /dev/stderr > sha256sums.txt)
TAG=$(echo $GITHUB_REF | cut -d / -f 3)
VERSION=$TAG
REPO=$(echo $GITHUB_REPOSITORY | cut -d / -f 2)
curl -L https://github.com/tcnksm/ghr/releases/download/v0.14.0/ghr_v0.14.0_linux_amd64.tar.gz | tar xzf -
./ghr_v0.14.0_linux_amd64/ghr -t ${{ secrets.GITHUB_TOKEN }} -u ${GITHUB_ACTOR} -r ${REPO} -c ${GITHUB_SHA} -delete ${VERSION} ./publish_dir