Skip to content

Commit 9d20a2a

Browse files
committed
Update CI
1 parent 53231f0 commit 9d20a2a

File tree

5 files changed

+68
-60
lines changed

5 files changed

+68
-60
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @nhooyr

.github/workflows/ci.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,46 @@ on: [push, pull_request]
33

44
jobs:
55
fmt:
6-
runs-on: ubuntu-latest
7-
container: nhooyr/websocket-ci@sha256:8a8fd73fdea33585d50a33619c4936adfd016246a2ed6bbfbf06def24b518a6a
86
steps:
97
- uses: actions/checkout@v1
10-
- run: make fmt
8+
- uses: actions/cache@v1
9+
with:
10+
path: ~/go/pkg/mod
11+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
12+
restore-keys: |
13+
${{ runner.os }}-go-
14+
- name: make fmt
15+
uses: ./ci/image
16+
with:
17+
args: make fmt
18+
1119
lint:
12-
runs-on: ubuntu-latest
13-
container: nhooyr/websocket-ci@sha256:8a8fd73fdea33585d50a33619c4936adfd016246a2ed6bbfbf06def24b518a6a
1420
steps:
1521
- uses: actions/checkout@v1
16-
- run: make lint
22+
- uses: actions/cache@v1
23+
with:
24+
path: ~/go/pkg/mod
25+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
26+
restore-keys: |
27+
${{ runner.os }}-go-
28+
- name: make lint
29+
uses: ./ci/image
30+
with:
31+
args: make lint
32+
1733
test:
18-
runs-on: ubuntu-latest
19-
container: nhooyr/websocket-ci@sha256:8a8fd73fdea33585d50a33619c4936adfd016246a2ed6bbfbf06def24b518a6a
2034
steps:
2135
- uses: actions/checkout@v1
22-
- run: make test
36+
- uses: actions/cache@v1
37+
with:
38+
path: ~/go/pkg/mod
39+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
40+
restore-keys: |
41+
${{ runner.os }}-go-
42+
- name: make test
43+
uses: ./ci/image
44+
with:
45+
args: make test
2346
env:
2447
COVERALLS_TOKEN: ${{ secrets.github_token }}
2548
- name: Upload coverage.html

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,3 @@ SHELL = bash
1111
include ci/fmt.mk
1212
include ci/lint.mk
1313
include ci/test.mk
14-
15-
ci-image:
16-
docker build -f ./ci/Dockerfile -t nhooyr/websocket-ci .
17-
docker push nhooyr/websocket-ci

ci/Dockerfile renamed to ci/image/Dockerfile

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ RUN apt-get install -y chromium
55
RUN apt-get install -y npm
66
RUN apt-get install -y jq
77

8-
ENV GOPATH=/root/gopath
9-
ENV PATH=$GOPATH/bin:$PATH
108
ENV GOFLAGS="-mod=readonly"
119
ENV PAGER=cat
1210
ENV CI=true
@@ -18,14 +16,3 @@ RUN go get golang.org/x/tools/cmd/goimports
1816
RUN go get golang.org/x/lint/golint
1917
RUN go get github.com/agnivade/wasmbrowsertest
2018
RUN go get github.com/mattn/goveralls
21-
22-
# Cache go modules and build cache.
23-
COPY . /tmp/websocket
24-
RUN cd /tmp/websocket && \
25-
CI= make && \
26-
rm -rf /tmp/websocket
27-
28-
# GitHub actions tries to override HOME to /github/home and then
29-
# mounts a temp directory into there. We do not want this behaviour.
30-
# I assume it is so that $HOME is preserved between steps in a job.
31-
ENTRYPOINT ["env", "HOME=/root"]

conn_test.go

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,41 @@ import (
1717
"nhooyr.io/websocket"
1818
)
1919

20+
func TestConn(t *testing.T) {
21+
t.Parallel()
22+
23+
t.Run("json", func(t *testing.T) {
24+
s, closeFn := testServer(t, func(w http.ResponseWriter, r *http.Request) {
25+
c, err := websocket.Accept(w, r, &websocket.AcceptOptions{
26+
Subprotocols: []string{"echo"},
27+
InsecureSkipVerify: true,
28+
})
29+
assert.Success(t, err)
30+
defer c.Close(websocket.StatusInternalError, "")
31+
32+
err = echoLoop(r.Context(), c)
33+
assertCloseStatus(t, websocket.StatusNormalClosure, err)
34+
}, false)
35+
defer closeFn()
36+
37+
wsURL := strings.Replace(s.URL, "http", "ws", 1)
38+
39+
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
40+
defer cancel()
41+
42+
opts := &websocket.DialOptions{
43+
Subprotocols: []string{"echo"},
44+
}
45+
opts.HTTPClient = s.Client()
46+
47+
c, _, err := websocket.Dial(ctx, wsURL, opts)
48+
assert.Success(t, err)
49+
50+
assertJSONEcho(t, ctx, c, 2)
51+
})
52+
}
53+
54+
2055
func testServer(tb testing.TB, fn func(w http.ResponseWriter, r *http.Request), tls bool) (s *httptest.Server, closeFn func()) {
2156
h := http.HandlerFunc(fn)
2257
if tls {
@@ -108,37 +143,3 @@ func echoLoop(ctx context.Context, c *websocket.Conn) error {
108143
}
109144
}
110145
}
111-
112-
func TestConn(t *testing.T) {
113-
t.Parallel()
114-
115-
t.Run("json", func(t *testing.T) {
116-
s, closeFn := testServer(t, func(w http.ResponseWriter, r *http.Request) {
117-
c, err := websocket.Accept(w, r, &websocket.AcceptOptions{
118-
Subprotocols: []string{"echo"},
119-
InsecureSkipVerify: true,
120-
})
121-
assert.Success(t, err)
122-
defer c.Close(websocket.StatusInternalError, "")
123-
124-
err = echoLoop(r.Context(), c)
125-
assertCloseStatus(t, websocket.StatusNormalClosure, err)
126-
}, false)
127-
defer closeFn()
128-
129-
wsURL := strings.Replace(s.URL, "http", "ws", 1)
130-
131-
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
132-
defer cancel()
133-
134-
opts := &websocket.DialOptions{
135-
Subprotocols: []string{"echo"},
136-
}
137-
opts.HTTPClient = s.Client()
138-
139-
c, _, err := websocket.Dial(ctx, wsURL, opts)
140-
assert.Success(t, err)
141-
142-
assertJSONEcho(t, ctx, c, 2)
143-
})
144-
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy