Skip to content

Commit

Permalink
Add CI workflow (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
misberner authored Nov 20, 2020
1 parent 77f0d86 commit b6ae787
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize]

jobs:
test:
name: Test
runs-on: ubuntu-latest

steps:
- uses: actions/setup-go@v2
with:
go-version: 1.14.12
- uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Style checks
run: |
make style
if ! git diff --exit-code HEAD; then
echo
echo "*** Files are not formatted properly. See the above diff for more info."
exit 1
fi
- name: Unit tests
run: |
make unit-tests
- name: Integration tests
run: |
make integration-tests
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ generate-go-srcs: dev
@echo "+ $@"
@go generate ./...

### UNIT TESTS
### TESTS

.PHONY: unit-tests
unit-tests: deps
@echo "+ $@"
@go test $(TESTFLAGS) ./...

.PHONY: integration-tests
integration-tests: deps
@echo "+ $@"
@cd _integration-tests ; go test -count=1 -p 4 .
4 changes: 2 additions & 2 deletions client/ws_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ func (h *http2WebSocketProxy) ServeHTTP(w http.ResponseWriter, req *http.Request
// gRPC already performs compression, so no need for WebSocket to add compression as well.
CompressionMode: websocket.CompressionDisabled,
})
if resp != nil {
if resp != nil && resp.Body != nil {
// Not strictly necessary because the library already replaces resp.Body with a NopCloser,
// but seems too easy to miss should we switch to a different library.
defer func() { _ = resp.Body.Close() }()
}
if err != nil {
if resp != nil {
if resp != nil && resp.Body != nil {
if respErr := httputils.ExtractResponseError(resp); respErr != nil {
err = fmt.Errorf("%w; response error: %v", err, respErr)
}
Expand Down

0 comments on commit b6ae787

Please sign in to comment.