-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (180 loc) · 6.57 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
name: CI
on: [push, pull_request]
jobs:
cargo_fmt:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- run: cargo fmt --all -- --check
cross_build:
strategy:
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
- 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-18.04
steps:
- uses: actions/checkout@v2
- name: Install cross
run: curl -L https://github.com/rust-embedded/cross/releases/download/v0.2.1/cross-v0.2.1-x86_64-unknown-linux-gnu.tar.gz | tar xzf -
- run: ./cross build --target=${{ matrix.target }} --release --locked
- name: Archive binary
run: |
set -eu
mkdir ./yamux-${{ matrix.target }}
if [[ "${{ matrix.target }}" == *"-windows-"* ]]; then
cp ./target/${{ matrix.target }}/release/yamux.exe ./yamux-${{ matrix.target }}
zip -r ./yamux-${{ matrix.target }}.zip ./yamux-${{ matrix.target }}
else
cp ./target/${{ matrix.target }}/release/yamux ./yamux-${{ matrix.target }}
tar zcf ./yamux-${{ matrix.target }}.tar.gz ./yamux-${{ matrix.target }}
fi
- uses: actions/upload-artifact@v2
with:
name: cross_build_artifact
path: |
yamux-*.tar.gz
yamux-*.zip
linux_operational_test:
needs:
- cross_build
runs-on: ubuntu-18.04
steps:
- name: Run Nginx
run: docker run -d -p 8080:80 nginx:alpine
- run: sudo apt install -y socat
- name: Serve Unix domain socket
run: socat UNIX-LISTEN:/tmp/my_nginx_socat,fork TCP:localhost:8080 &
- name: Download the artifact (cross build)
uses: actions/download-artifact@v2
with:
name: cross_build_artifact
- name: Extract binary
run: tar xf yamux-x86_64-unknown-linux-musl.tar.gz
- name: Normal TCP
run: |
set -eu
cp ./yamux-x86_64-unknown-linux-musl/yamux yamux
mkfifo my_pipe
cat my_pipe | ./yamux localhost 8080 | ./yamux -l 8081 > ./my_pipe &
sleep 1
curl localhost:8080 > expected_response.txt
# HTTP GET request twice
diff expected_response.txt <(curl localhost:8081)
diff expected_response.txt <(curl localhost:8081)
kill %1
rm my_pipe
- name: Normal TCP specifying host when listening
run: |
set -eu
cp ./yamux-x86_64-unknown-linux-musl/yamux yamux
mkfifo my_pipe
cat my_pipe | ./yamux localhost 8080 | ./yamux -l localhost 8081 > ./my_pipe &
sleep 1
curl localhost:8080 > expected_response.txt
# HTTP GET request twice
diff expected_response.txt <(curl localhost:8081)
diff expected_response.txt <(curl localhost:8081)
kill %1
rm my_pipe
- name: Unix domain socket (connect)
run: |
set -eu
cp ./yamux-x86_64-unknown-linux-musl/yamux yamux
mkfifo my_pipe
cat my_pipe | ./yamux -U /tmp/my_nginx_socat | ./yamux -l 8081 > ./my_pipe &
sleep 1
curl localhost:8080 > expected_response.txt
# HTTP GET request twice
diff expected_response.txt <(curl localhost:8081)
diff expected_response.txt <(curl localhost:8081)
kill %1
rm my_pipe
- name: Unix domain socket (listen)
run: |
set -eu
cp ./yamux-x86_64-unknown-linux-musl/yamux yamux
mkfifo my_pipe
cat my_pipe | ./yamux localhost 8080 | ./yamux -l -U /tmp/my_unginx > ./my_pipe &
sleep 1
curl localhost:8080 > expected_response.txt
# HTTP GET request twice
diff expected_response.txt <(curl --unix-socket /tmp/my_unginx http:/index.html)
diff expected_response.txt <(curl --unix-socket /tmp/my_unginx http:/index.html)
kill %1
rm my_pipe
- name: UDP
run: |
set -eu
cp ./yamux-x86_64-unknown-linux-musl/yamux yamux
mkfifo my_pipe
cat my_pipe | ./yamux -u 1.1.1.1 53 | ./yamux -ul 1053 > ./my_pipe &
sleep 1
# DNS request twice
# NOTE: if 1053 port is not available they will be timeout errors
dig example.com @127.0.0.1 -p 1053
dig example.com @127.0.0.1 -p 1053
kill %1
rm my_pipe
build_for_mac:
strategy:
matrix:
target:
- x86_64-apple-darwin
- aarch64-apple-darwin
runs-on: macOS-11
steps:
- uses: actions/checkout@v2
- run: rustup target add ${{ matrix.target }}
- run: cargo build --target=${{ matrix.target }} --release --locked
- name: Archive binary
run: |
set -eu
mkdir ./yamux-${{ matrix.target }}
cp ./target/${{ matrix.target }}/release/yamux ./yamux-${{ matrix.target }}
tar zcf ./yamux-${{ matrix.target }}.tar.gz ./yamux-${{ matrix.target }}
- uses: actions/upload-artifact@v2
with:
name: mac_build_artifact
path: |
yamux-*.tar.gz
release_if_tag_exits:
needs:
- cargo_fmt
- linux_operational_test
- build_for_mac
runs-on: ubuntu-18.04
steps:
- name: Download the artifact (cross build)
uses: actions/download-artifact@v2
with:
name: cross_build_artifact
path: ./publish_dir
- name: Download the artifact (macOS)
uses: actions/download-artifact@v2
with:
name: mac_build_artifact
path: ./publish_dir
- 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