Skip to content

Commit 04b7d0d

Browse files
committed
Initial commit
0 parents  commit 04b7d0d

File tree

12 files changed

+179
-0
lines changed

12 files changed

+179
-0
lines changed

.github/fmt/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM golang:1.12
2+
3+
LABEL "com.github.actions.name"="fmt"
4+
LABEL "com.github.actions.description"="Ensure formatted files"
5+
LABEL "com.github.actions.icon"="code"
6+
LABEL "com.github.actions.color"="purple"
7+
8+
COPY entrypoint.sh /entrypoint.sh
9+
10+
CMD ["/entrypoint.sh"]

.github/fmt/entrypoint.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
source .github/lib.sh
4+
5+
if [[ $(gofmt -l -s .) != "" ]]; then
6+
echo "files are not formatted correctly"
7+
echo "please run:"
8+
echo "gofmt -w -s ."
9+
exit 1
10+
fi
11+
12+
out=$(go run golang.org/x/tools/cmd/goimports -l -local=nhooyr.io/ws .)
13+
if [[ $out != "" ]]; then
14+
echo "imports are not formatted correctly"
15+
echo "please run:"
16+
echo "goimports -w -local=nhooyr.io/ws ."
17+
exit 1
18+
fi
19+
20+
out=$(go run mvdan.cc/sh/cmd/shfmt -l -s -sr .)
21+
if [[ $out != "" ]]; then
22+
echo "shell scripts are not formatted correctly"
23+
echo "please run:"
24+
echo "shfmt -w -s -sr ."
25+
exit 1
26+
fi

.github/lib.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
export GO111MODULE=on
6+
export GOFLAGS=-mod=readonly

.github/main.workflow

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
workflow "main" {
2+
on = "push"
3+
resolves = ["fmt", "test"]
4+
}
5+
6+
action "fmt" {
7+
uses = "./.github/fmt"
8+
}
9+
10+
action "test" {
11+
uses = "./.github/test"
12+
secrets = ["CODECOV_TOKEN"]
13+
}

.github/test/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM golang:1.12
2+
3+
LABEL "com.github.actions.name"="test"
4+
LABEL "com.github.actions.description"="Run go test"
5+
LABEL "com.github.actions.icon"="code"
6+
LABEL "com.github.actions.color"="purple"
7+
8+
RUN apt update && apt install -y shellcheck
9+
10+
COPY entrypoint.sh /entrypoint.sh
11+
12+
CMD ["/entrypoint.sh"]

.github/test/entrypoint.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
source .github/lib.sh
4+
5+
function gomod_help() {
6+
echo
7+
echo "you may need to update go.mod/go.sum via:"
8+
echo "go list all > /dev/null"
9+
echo "go mod tidy"
10+
echo
11+
echo "or git add files to staging"
12+
exit 1
13+
}
14+
15+
go list ./... > /dev/null || gomod_help
16+
go mod tidy
17+
18+
# Until https://github.com/golang/go/issues/27005 the previous command can actually modify go.sum so we need to ensure its not changed.
19+
if [[ $(git diff --name-only) != "" ]]; then
20+
git diff
21+
gomod_help
22+
fi
23+
24+
mapfile -t scripts <<< "$(find . -type f -name "*.sh")"
25+
shellcheck "${scripts[@]}"
26+
27+
go vet -composites=false ./...
28+
29+
go test -race -v -coverprofile=coverage.out -vet=off ./...
30+
31+
if [[ -z ${GITHUB_ACTION-} ]]; then
32+
go tool cover -html=coverage.out
33+
else
34+
bash <(curl -s https://codecov.io/bash)
35+
fi
36+
37+
rm coverage.out

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Anmol Sethi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ws
2+
3+
[![GoDoc](https://godoc.org/nhooyr.io/ws?status.svg)](https://godoc.org/nhooyr.io/ws)
4+
[![Codecov](https://img.shields.io/codecov/c/github/nhooyr/ws.svg)](https://codecov.io/gh/nhooyr/ws)
5+
[![GitHub release](https://img.shields.io/github/release/nhooyr/ws.svg)](https://github.com/nhooyr/ws/releases)
6+
7+
ws is a clean and idiomatic WebSocket library for Go.
8+
9+
This library is in heavy development.
10+
11+
## Install
12+
13+
```bash
14+
go get nhooyr.io/ws
15+
```

go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module nhooyr.io/ws
2+
3+
go 1.12
4+
5+
require (
6+
github.com/kr/pretty v0.1.0 // indirect
7+
golang.org/x/tools v0.0.0-20190315191501-e6df0c1bb376
8+
mvdan.cc/sh v2.6.4+incompatible
9+
)

go.sum

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
2+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
3+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
4+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
5+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
6+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
7+
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
8+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
9+
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
10+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
11+
golang.org/x/tools v0.0.0-20190315191501-e6df0c1bb376 h1:GfNg/J4IAJguoN+DWPTZ54ElycoBxtQkpxhrbA5edVA=
12+
golang.org/x/tools v0.0.0-20190315191501-e6df0c1bb376/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
13+
mvdan.cc/sh v2.6.4+incompatible h1:eD6tDeh0pw+/TOTI1BBEryZ02rD2nMcFsgcvde7jffM=
14+
mvdan.cc/sh v2.6.4+incompatible/go.mod h1:IeeQbZq+x2SUGBensq/jge5lLQbS3XT2ktyp3wrt4x8=

test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# This is for local testing. See .github for CI.
3+
4+
source ./.github/lib.sh
5+
6+
./.github/fmt/entrypoint.sh
7+
./.github/test/entrypoint.sh

tools.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// +build tools
2+
3+
package tools
4+
5+
// See https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md
6+
import (
7+
_ "golang.org/x/tools/cmd/goimports"
8+
_ "mvdan.cc/sh/cmd/shfmt"
9+
)

0 commit comments

Comments
 (0)