Skip to content

Commit b6ae787

Browse files
authored
Add CI workflow (#6)
1 parent 77f0d86 commit b6ae787

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/setup-go@v2
16+
with:
17+
go-version: 1.14.12
18+
- uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 1
21+
22+
- name: Style checks
23+
run: |
24+
make style
25+
if ! git diff --exit-code HEAD; then
26+
echo
27+
echo "*** Files are not formatted properly. See the above diff for more info."
28+
exit 1
29+
fi
30+
31+
- name: Unit tests
32+
run: |
33+
make unit-tests
34+
35+
- name: Integration tests
36+
run: |
37+
make integration-tests

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@ generate-go-srcs: dev
6363
@echo "+ $@"
6464
@go generate ./...
6565

66-
### UNIT TESTS
66+
### TESTS
6767

6868
.PHONY: unit-tests
6969
unit-tests: deps
7070
@echo "+ $@"
7171
@go test $(TESTFLAGS) ./...
72+
73+
.PHONY: integration-tests
74+
integration-tests: deps
75+
@echo "+ $@"
76+
@cd _integration-tests ; go test -count=1 -p 4 .

client/ws_proxy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,13 @@ func (h *http2WebSocketProxy) ServeHTTP(w http.ResponseWriter, req *http.Request
238238
// gRPC already performs compression, so no need for WebSocket to add compression as well.
239239
CompressionMode: websocket.CompressionDisabled,
240240
})
241-
if resp != nil {
241+
if resp != nil && resp.Body != nil {
242242
// Not strictly necessary because the library already replaces resp.Body with a NopCloser,
243243
// but seems too easy to miss should we switch to a different library.
244244
defer func() { _ = resp.Body.Close() }()
245245
}
246246
if err != nil {
247-
if resp != nil {
247+
if resp != nil && resp.Body != nil {
248248
if respErr := httputils.ExtractResponseError(resp); respErr != nil {
249249
err = fmt.Errorf("%w; response error: %v", err, respErr)
250250
}

0 commit comments

Comments
 (0)