Skip to content

Commit c37930c

Browse files
committed
Merge branch 'make'
2 parents e14c100 + 4d4a02d commit c37930c

25 files changed

+178
-2061
lines changed

.github/CONTRIBUTING.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,18 @@ CI will ensure your code is formatted, lints and passes tests.
3131
It will collect coverage and report it to [codecov](https://codecov.io/gh/nhooyr/websocket)
3232
and also upload a html `coverage` artifact that you can download to browse coverage.
3333

34-
You can run CI locally. You only need [Go](https://golang.org), [nodejs](https://nodejs.org/en/) and [yarn](https://yarnpkg.com).
34+
You can run CI locally.
3535

36-
See the scripts in [package.json](../package.json).
37-
38-
1. `yarn fmt` performs code generation and formatting.
39-
1. `yarn lint` performs linting.
40-
1. `yarn test` runs tests.
41-
1. `yarn all` runs the above scripts in parallel.
36+
See [ci/image/Dockerfile](../ci/image/Dockerfile) for the installation of the CI dependencies on Ubuntu.
4237

43-
For coverage details locally, see `ci/out/coverage.html` after running `yarn test`.
38+
1. `make fmt` performs code generation and formatting.
39+
1. `make lint` performs linting.
40+
1. `make test` runs tests.
41+
1. `make` runs the above targets.
4442

45-
CI is written with nodejs to enable running as much as possible concurrently.
43+
For coverage details locally, see `ci/out/coverage.html` after running `make test`.
4644

47-
See [ci/image/Dockerfile](../ci/image/Dockerfile) for the installation of the CI dependencies on Ubuntu.
48-
49-
You can also run tests normally with `go test`. `yarn test` just passes a default set of flags to
45+
You can also run tests normally with `go test`. `make test` just passes a default set of flags to
5046
`go test` to collect coverage and runs the WASM tests.
5147

52-
You can pass flags to `yarn test` if you want to run a specific test or otherwise
53-
control the behaviour of `go test` but also get coverage.
54-
5548
Coverage percentage from codecov and the CI scripts will be different because they are calculated differently.

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ on: [push]
44
jobs:
55
fmt:
66
runs-on: ubuntu-latest
7-
container: nhooyr/websocket-ci@sha256:13f9b8cc2f901e98c253595c4070254ece08543f6e100b4fa6682f87de4388eb
7+
container: nhooyr/websocket-ci@sha256:54a12b52be98d2d1588a054cfce35d17705c9b45546478d8bcdbac2a89a90001
88
steps:
99
- uses: actions/checkout@v1
10-
- run: yarn --frozen-lockfile && yarn fmt
10+
- run: make fmt
1111
lint:
1212
runs-on: ubuntu-latest
13-
container: nhooyr/websocket-ci@sha256:13f9b8cc2f901e98c253595c4070254ece08543f6e100b4fa6682f87de4388eb
13+
container: nhooyr/websocket-ci@sha256:54a12b52be98d2d1588a054cfce35d17705c9b45546478d8bcdbac2a89a90001
1414
steps:
1515
- uses: actions/checkout@v1
16-
- run: yarn --frozen-lockfile && yarn lint
16+
- run: make lint
1717
test:
1818
runs-on: ubuntu-latest
19-
container: nhooyr/websocket-ci@sha256:13f9b8cc2f901e98c253595c4070254ece08543f6e100b4fa6682f87de4388eb
19+
container: nhooyr/websocket-ci@sha256:54a12b52be98d2d1588a054cfce35d17705c9b45546478d8bcdbac2a89a90001
2020
steps:
2121
- uses: actions/checkout@v1
22-
- run: yarn --frozen-lockfile && yarn test
22+
- run: make test
2323
env:
2424
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2525
- name: Upload coverage.html

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
all: fmt lint test
2+
3+
.SILENT:
4+
5+
.PHONY: *
6+
7+
include ci/fmt.mk
8+
include ci/lint.mk
9+
include ci/test.mk
10+
11+
ci-image:
12+
docker build -f ./ci/image/Dockerfile -t nhooyr/websocket-ci .
13+
docker push nhooyr/websocket-ci

ci/.eslintrc.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

ci/all.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

ci/fmt.mk

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fmt: modtidy gofmt goimports prettier
2+
ifdef CI
3+
./ci/fmtcheck.sh
4+
endif
5+
6+
modtidy: gen
7+
go mod tidy
8+
9+
gofmt: gen
10+
gofmt -w -s .
11+
12+
goimports: gen
13+
goimports -w "-local=$$(go list -m)" .
14+
15+
prettier: gen
16+
prettier --write --print-width=120 --no-semi --trailing-comma=all --loglevel=warn $$(git ls-files "*.yaml" "*.yml" "*.md" "*.ts")
17+
18+
shfmt: gen
19+
shfmt -i 2 -w -s -sr .
20+
21+
gen:
22+
go generate ./...

ci/fmt.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

ci/fmtcheck.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [[ $(git ls-files --other --modified --exclude-standard) != "" ]]; then
6+
echo "Files need generation or are formatted incorrectly."
7+
git status
8+
echo "Please run the following locally:"
9+
echo " make fmt"
10+
exit 1
11+
fi

ci/image/Dockerfile

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
FROM golang:1
22

3-
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
4-
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
5-
6-
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
7-
RUN apt-get install -y nodejs chromium yarn
8-
9-
COPY ./ci/image/gitignore /etc/git/ignore
10-
RUN git config --system color.ui always
11-
# Need to set set this explicitly for the system since github uses HOME=/home/github.
12-
RUN git config --system core.excludesfile /etc/git/ignore
3+
RUN apt-get update
4+
RUN apt-get install -y chromium
5+
RUN apt-get install -y npm
6+
RUN apt-get install -y shellcheck
137

148
ENV GOPATH=/root/gopath
159
ENV PATH=$GOPATH/bin:$PATH
1610
ENV GOFLAGS="-mod=readonly"
1711
ENV PAGER=cat
1812
ENV CI=true
13+
ENV MAKEFLAGS="-j --output-sync target"
1914

20-
# Cache go modules, build cache and yarn cache.
15+
COPY ./ci/image/gitignore /root/.config/git/ignore
16+
RUN git config --system color.ui always
17+
18+
RUN npm install -g prettier
19+
RUN go get golang.org/x/tools/cmd/stringer
20+
RUN go get golang.org/x/tools/cmd/goimports
21+
RUN go get mvdan.cc/sh/cmd/shfmt
22+
RUN go get golang.org/x/lint/golint
23+
RUN go get github.com/agnivade/wasmbrowsertest
24+
25+
# Cache go modules and build cache.
2126
COPY . /tmp/websocket
2227
RUN cd /tmp/websocket && \
23-
yarn && CI= yarn ci && \
28+
CI= make && \
2429
rm -rf /tmp/websocket
30+
31+
# GitHub actions tries to override HOME to /github/home and then
32+
# mounts a temp directory into there. We do not want this behaviour.
33+
# I assume it is so that $HOME is preserved between steps in a job.
34+
ENTRYPOINT ["env", "HOME=/root"]

ci/image/dockerignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)