-
Notifications
You must be signed in to change notification settings - Fork 1
243 lines (231 loc) · 10.6 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: CI
on: [push]
env:
PIPING_SERVER_CHECK_VERSION: 0.13.1
jobs:
build_x64_executables:
runs-on: ubuntu-20.04
strategy:
matrix:
pkg_target_without_node:
- linuxstatic-x64
- linux-x64
- mac-x64
- alpine-x64
- win-x64
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-node@v3.8.1
with:
node-version: '18'
- run: npm ci
- run: |
set -xeu
npm run piping-build
./node_modules/.bin/pkg --out-path=piping-server-pkg-${{ matrix.pkg_target_without_node }} --targets=node18-${{ matrix.pkg_target_without_node }} ./piping-server
- name: tar.gz or zip
run: |
set -xeu
if [ "${{ matrix.pkg_target_without_node }}" = "win-x64" ]; then
zip -r piping-server-pkg-${{ matrix.pkg_target_without_node }}.zip ./piping-server-pkg-${{ matrix.pkg_target_without_node }}
else
tar czvf piping-server-pkg-${{ matrix.pkg_target_without_node }}.tar.gz ./piping-server-pkg-${{ matrix.pkg_target_without_node }}
fi
- uses: actions/upload-artifact@v3
with:
name: build_x64
path: |
piping-server-pkg-*.tar.gz
piping-server-pkg-*.zip
build_arm_executables:
runs-on: ubuntu-20.04
strategy:
matrix:
pkg_target_without_node:
- linuxstatic-arm64
- linuxstatic-armv7
- linux-arm64
- mac-arm64
- alpine-arm64
- win-arm64
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- run: |
set -xeu
# NOTE: Using node:18 takes over 21 minutes
docker run --rm -i -v $PWD:/app --platform=linux/arm64/v8 node:20 bash << 'EOF'
set -xeu
# Install ldid for macos-arm64 signing
curl -LO https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus2/ldid_linux_aarch64
chmod +x ldid_linux_aarch64
mv ./ldid_linux_aarch64 /usr/local/bin/ldid
cd /app
npm ci
npm run piping-build
./node_modules/.bin/pkg --out-path=piping-server-pkg-${{ matrix.pkg_target_without_node }} --targets=node18-${{ matrix.pkg_target_without_node }} ./piping-server
EOF
- name: tar.gz or zip
run: |
set -xeu
if [ "${{ matrix.pkg_target_without_node }}" = "win-arm64" ]; then
zip -r piping-server-pkg-${{ matrix.pkg_target_without_node }}.zip ./piping-server-pkg-${{ matrix.pkg_target_without_node }}
else
tar czvf piping-server-pkg-${{ matrix.pkg_target_without_node }}.tar.gz ./piping-server-pkg-${{ matrix.pkg_target_without_node }}
fi
- uses: actions/upload-artifact@v3
with:
name: build_arm
path: |
piping-server-pkg-*.tar.gz
piping-server-pkg-*.zip
linux_piping_server_check:
runs-on: ubuntu-20.04
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive tar.gz
run: tar xvf piping-server-pkg-linuxstatic-x64.tar.gz
- 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 --h2 --tls-skip-verify --concurrency 100 --server-command="${SERVER_COMMAND}" --n-simultaneous-requests=60 --transfer-speed-byte $((1024 * 1024 * 1024 * 1024)) --transfer-span 3s --transfer-span 10s --transfer-span 1m --transfer-span 2m --transfer-span 3m
env:
SERVER_COMMAND: 'mkdir -p /tmp/logs && exec ./piping-server-pkg-linuxstatic-x64/piping-server --http-port=$HTTP_PORT --enable-https --https-port=$HTTPS_PORT --crt-path=/tmp/ssl_certs/server.crt --key-path=/tmp/ssl_certs/server.key 2>&1 | tee /tmp/logs/$SERVER_RUN_ID.log > /dev/stderr'
timeout-minutes: 4.5
- name: Show server logs from piping-server-check
if: ${{ always() }}
run: tail -n +1 /tmp/logs/*
alpine_piping_server_check:
runs-on: ubuntu-20.04
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive tar.gz
run: tar xvf piping-server-pkg-alpine-x64.tar.gz
- run: mkdir /tmp/shared
- name: Create certificates
run: cd /tmp/shared && 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/ && curl -L https://github.com/nwtgck/piping-server-check/releases/download/v${PIPING_SERVER_CHECK_VERSION}/piping-server-check-${PIPING_SERVER_CHECK_VERSION}-linux-amd64.tar.gz | tar xzf -
- name: piping-server-check
run: |
docker run --rm -i -e SERVER_COMMAND="${SERVER_COMMAND}" -v $PWD:/app -v /tmp/piping-server-check:/usr/local/bin/piping-server-check -v /tmp/shared:/tmp/shared alpine:3.14 /bin/sh << 'EOF'
set -xeu
export GITHUB_ACTIONS=true
piping-server-check --http1.1 --http1.1-tls --h2 --tls-skip-verify --concurrency 100 --server-command="${SERVER_COMMAND}" --n-simultaneous-requests=60 --transfer-speed-byte $((1024 * 1024 * 1024 * 1024)) --transfer-span 3s --transfer-span 10s --transfer-span 1m --transfer-span 2m --transfer-span 3m
EOF
env:
SERVER_COMMAND: 'mkdir -p /tmp/shared/logs && exec /app/piping-server-pkg-alpine-x64/piping-server --http-port=$HTTP_PORT --enable-https --https-port=$HTTPS_PORT --crt-path=/tmp/shared/ssl_certs/server.crt --key-path=/tmp/shared/ssl_certs/server.key 2>&1 | tee /tmp/shared/logs/$SERVER_RUN_ID.log > /dev/stderr'
timeout-minutes: 4.5
- name: Show server logs from piping-server-check
if: ${{ always() }}
run: tail -n +1 /tmp/shared/logs/*
macos_piping_server_check:
runs-on: macos-11
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive tar.gz
run: tar xvf piping-server-pkg-mac-x64.tar.gz
- 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 && curl -L https://github.com/nwtgck/piping-server-check/releases/download/v${PIPING_SERVER_CHECK_VERSION}/piping-server-check-${PIPING_SERVER_CHECK_VERSION}-darwin-amd64.tar.gz | tar xf - && sudo mv piping-server-check /usr/local/bin
- name: piping-server-check
run: piping-server-check --http1.1 --http1.1-tls --h2 --tls-skip-verify --concurrency 100 --server-command="${SERVER_COMMAND}" --n-simultaneous-requests=60 --transfer-speed-byte $((1024 * 1024 * 1024 * 1024)) --transfer-span 3s --transfer-span 10s --transfer-span 1m --transfer-span 2m --transfer-span 3m
env:
SERVER_COMMAND: 'mkdir -p /tmp/logs && exec ./piping-server-pkg-mac-x64/piping-server --http-port=$HTTP_PORT --enable-https --https-port=$HTTPS_PORT --crt-path=/tmp/ssl_certs/server.crt --key-path=/tmp/ssl_certs/server.key 2>&1 | tee /tmp/logs/$SERVER_RUN_ID.log > /dev/stderr'
timeout-minutes: 4.5
- name: Show server logs from piping-server-check
if: ${{ always() }}
run: tail -n +1 /tmp/logs/*
windows_operational_test:
runs-on: windows-2019
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive zip
run: unzip piping-server-pkg-win-x64.zip
- name: Create certificates
run: |
mkdir ssl_certs
cd ssl_certs
openssl genrsa 2048 > server.key
openssl req -new -key server.key -subj "/C=JP" > server.csr
cat server.csr | openssl x509 -req -days 3650 -signkey server.key > server.crt
- name: Operational test
run: |
# Run a server in background
$args = @("--http-port=8080", "--enable-https", "--https-port=8443", "--key-path=.\ssl_certs\server.key", "--crt-path=.\ssl_certs\server.crt")
$server_pid = Start-Process -PassThru -FilePath .\piping-server-pkg-win-x64\piping-server.exe -ArgumentList $args | foreach { $_.Id }
# Wait for server running
sleep 1
# Create a file to send
echo 'hello, world' > C:\Temp\hello.txt
# Send and wait for a receiver
curl -T C:\Temp\hello.txt localhost:8080/mypath &
# Get data as a file
curl localhost:8080/mypath > C:\Temp\download.txt
# Print downloaded file
cat C:\Temp\download.txt
# Test the equality
diff C:\Temp\hello.txt C:\Temp\download.txt
# Send and wait for a receiver
curl -kT C:\Temp\hello.txt https://localhost:8443/mypath &
# Get data as a file
curl -k https://localhost:8443/mypath > C:\Temp\download_https.txt
# Print downloaded file
cat C:\Temp\download_https.txt
# Test the equality
diff C:\Temp\hello.txt C:\Temp\download_https.txt
# Stop the server
kill $server_pid
release_executables:
if: startsWith( github.ref, 'refs/tags/')
needs:
- linux_piping_server_check
- alpine_piping_server_check
- macos_piping_server_check
- windows_operational_test
- build_arm_executables
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- uses: actions/download-artifact@v3
with:
name: build_arm
path: .
- run: |
set -xeu
mkdir ./publish_dir
mv piping-server-pkg-* ./publish_dir
# 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 -n ${VERSION} ${VERSION} ./publish_dir