-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
103 additions
and
172 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: ci | ||
on: [push, pull_request] | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
fmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: ./go.mod | ||
- run: ./ci/fmt.sh | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: go version | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: ./go.mod | ||
- run: ./ci/lint.sh | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: ./go.mod | ||
- run: ./ci/test.sh | ||
- uses: actions/upload-artifact@v2 | ||
if: always() | ||
with: | ||
name: coverage.html | ||
path: ./ci/out/coverage.html |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
#!/bin/sh | ||
set -eu | ||
cd -- "$(dirname "$0")/.." | ||
|
||
main() { | ||
cd "$(dirname "$0")/.." | ||
go mod tidy | ||
gofmt -w -s . | ||
go run golang.org/x/tools/cmd/goimports@latest -w "-local=$(go list -m)" . | ||
|
||
go mod tidy | ||
gofmt -w -s . | ||
goimports -w "-local=$(go list -m)" . | ||
npx [email protected] \ | ||
--write \ | ||
--log-level=warn \ | ||
--print-width=90 \ | ||
--no-semi \ | ||
--single-quote \ | ||
--arrow-parens=avoid \ | ||
$(git ls-files "*.yml" "*.md" "*.js" "*.css" "*.html") | ||
|
||
prettier \ | ||
--write \ | ||
--print-width=120 \ | ||
--no-semi \ | ||
--trailing-comma=all \ | ||
--loglevel=warn \ | ||
--arrow-parens=avoid \ | ||
$(git ls-files "*.yml" "*.md" "*.js" "*.css" "*.html") | ||
shfmt -i 2 -w -s -sr $(git ls-files "*.sh") | ||
|
||
stringer -type=opcode,MessageType,StatusCode -output=stringer.go | ||
|
||
if [[ ${CI-} ]]; then | ||
assert_no_changes | ||
fi | ||
} | ||
|
||
assert_no_changes() { | ||
if [[ $(git ls-files --other --modified --exclude-standard) ]]; then | ||
git -c color.ui=always --no-pager diff | ||
echo | ||
echo "Please run the following locally:" | ||
echo " ./ci/fmt.sh" | ||
exit 1 | ||
fi | ||
} | ||
|
||
main "$@" | ||
go run golang.org/x/tools/cmd/stringer@latest -type=opcode,MessageType,StatusCode -output=stringer.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
#!/bin/sh | ||
set -eu | ||
cd -- "$(dirname "$0")/.." | ||
|
||
main() { | ||
cd "$(dirname "$0")/.." | ||
go vet ./... | ||
GOOS=js GOARCH=wasm go vet ./... | ||
|
||
go vet ./... | ||
GOOS=js GOARCH=wasm go vet ./... | ||
go install golang.org/x/lint/golint@latest | ||
golint -set_exit_status ./... | ||
GOOS=js GOARCH=wasm golint -set_exit_status ./... | ||
|
||
golint -set_exit_status ./... | ||
GOOS=js GOARCH=wasm golint -set_exit_status ./... | ||
|
||
shellcheck --exclude=SC2046 $(git ls-files "*.sh") | ||
} | ||
|
||
main "$@" | ||
go install honnef.co/go/tools/cmd/staticcheck@latest | ||
staticcheck ./... | ||
GOOS=js GOARCH=wasm staticcheck ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,14 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
#!/bin/sh | ||
set -eu | ||
cd -- "$(dirname "$0")/.." | ||
|
||
main() { | ||
cd "$(dirname "$0")/.." | ||
go install github.com/agnivade/wasmbrowsertest@latest | ||
go test --race --timeout=1h --covermode=atomic --coverprofile=ci/out/coverage.prof --coverpkg=./... "$@" ./... | ||
sed -i.bak '/stringer\.go/d' ci/out/coverage.prof | ||
sed -i.bak '/nhooyr.io\/websocket\/internal\/test/d' ci/out/coverage.prof | ||
sed -i.bak '/examples/d' ci/out/coverage.prof | ||
|
||
go test -timeout=30m -covermode=atomic -coverprofile=ci/out/coverage.prof -coverpkg=./... "$@" ./... | ||
sed -i.bak '/stringer\.go/d' ci/out/coverage.prof | ||
sed -i.bak '/nhooyr.io\/websocket\/internal\/test/d' ci/out/coverage.prof | ||
sed -i.bak '/examples/d' ci/out/coverage.prof | ||
# Last line is the total coverage. | ||
go tool cover -func ci/out/coverage.prof | tail -n1 | ||
|
||
# Last line is the total coverage. | ||
go tool cover -func ci/out/coverage.prof | tail -n1 | ||
|
||
go tool cover -html=ci/out/coverage.prof -o=ci/out/coverage.html | ||
|
||
if [[ ${CI-} && ${GITHUB_REF-} == *master ]]; then | ||
local deployDir | ||
deployDir="$(mktemp -d)" | ||
cp ci/out/coverage.html "$deployDir/index.html" | ||
netlify deploy --prod "--dir=$deployDir" | ||
fi | ||
} | ||
|
||
main "$@" | ||
go tool cover -html=ci/out/coverage.prof -o=ci/out/coverage.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html lang="en-CA"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
#!/bin/sh | ||
set -eu | ||
cd -- "$(dirname "$0")" | ||
|
||
cd "$(dirname "$0")" | ||
|
||
fmt() { | ||
go mod tidy | ||
gofmt -s -w . | ||
goimports -w "-local=$(go list -m)" . | ||
} | ||
|
||
if ! command -v wasmbrowsertest >/dev/null; then | ||
go install github.com/agnivade/wasmbrowsertest@latest | ||
fi | ||
|
||
fmt | ||
go test -race --timeout=1h ./... "$@" | ||
./ci/fmt.sh | ||
./ci/lint.sh | ||
./ci/test.sh |