Skip to content

Commit

Permalink
all: remove golangci-yaml, add new linters
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Dec 8, 2020
1 parent 73c3059 commit a8f2546
Show file tree
Hide file tree
Showing 10 changed files with 395 additions and 63 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'name': 'golangci-lint'
'name': 'lint'
'on':
'push':
'tags':
Expand All @@ -7,16 +7,13 @@
- '*'
'pull_request':
'jobs':
'golangci':
'go-lint':
'runs-on': 'ubuntu-latest'
'steps':
- 'uses': 'actions/checkout@v2'
- 'name': 'golangci-lint'
'uses': 'golangci/golangci-lint-action@v2.3.0'
'with':
# This field is required. Don't set the patch version to always use
# the latest patch version.
'version': 'v1.32'
- 'name': 'run-lint'
'run': >
make go-install-tools go-lint
'eslint':
'runs-on': 'ubuntu-latest'
'steps':
Expand All @@ -27,7 +24,7 @@
'run': 'npm --prefix client run lint'
'notify':
'needs':
- 'golangci'
- 'go-lint'
- 'eslint'
# Secrets are not passed to workflows that are triggered by a pull request
# from a fork.
Expand Down
47 changes: 19 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
.DS_Store
/.vscode
.idea
/AdGuardHome
/AdGuardHome.exe
/AdGuardHome.yaml
/AdGuardHome.log
/data/
# Please, DO NOT put your text editors' temporary files here. The more are
# added, the harder it gets to maintain and manage projects' gitignores. Put
# them into your global gitignore file instead.
#
# See https://stackoverflow.com/a/7335487/1892060.
#
# Only build, run, and test outputs here. Sorted.
*-packr.go
*.db
*.snap
/bin/
/build/
/data/
/dist/
/client/node_modules/
/querylog.json
/querylog.json.1
/dnsfilter/tests/dnsfilter.TestLotsOfRules*.pprof
/dnsfilter/tests/top-1m.csv
/launchpad_credentials
/querylog.json*
/snapcraft_login
AdGuardHome*
coverage.txt
leases.db

# Test output
dnsfilter/tests/top-1m.csv
dnsfilter/tests/dnsfilter.TestLotsOfRules*.pprof

# Snapcraft build temporary files
*.snap
launchpad_credentials
snapcraft_login
snapcraft.yaml.bak

# IntelliJ IDEA project files
*.iml

# Packr
*-packr.go
node_modules/
26 changes: 22 additions & 4 deletions HACKING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# *AdGuardHome* Developer Guidelines

As of **2020-11-27**, this document is a work-in-progress, but should still be
followed. Some of the rules aren't enforced as thoroughly or remain broken in
old code, but this is still the place to find out about what we **want** our
code to look like.
As of **December 2020**, this document is partially a work-in-progress, but
should still be followed. Some of the rules aren't enforced as thoroughly or
remain broken in old code, but this is still the place to find out about what we
**want** our code to look like.

The rules are mostly sorted in the alphabetical order.

Expand Down Expand Up @@ -32,6 +32,11 @@ The rules are mostly sorted in the alphabetical order.
## *Go*
> Not Golang, not GO, not GOLANG, not GoLang. It is Go in natural language,
> golang for others.
— [@rakyll](https://twitter.com/rakyll/status/1229850223184269312)
### Code And Naming
* Avoid `goto`.
Expand Down Expand Up @@ -141,6 +146,19 @@ The rules are mostly sorted in the alphabetical order.
* **TODO(a.garipov):** Define our *Markdown* conventions.
## Shell Scripting
* Avoid bashisms, prefer *POSIX* features only.
* Prefer `'raw strings'` to `"double quoted strings"` whenever possible.
* Put spaces within `$( cmd )`, `$(( expr ))`, and `{ cmd; }`.
* Use `set -e -f -u` and also `set -x` in verbose mode.
* Use the `"$var"` form instead of the `$var` form, unless word splitting is
required.
## Text, Including Comments
* End sentences with appropriate punctuation.
Expand Down
37 changes: 20 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true

GOPATH := $(shell go env GOPATH)
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
Expand Down Expand Up @@ -122,9 +123,9 @@ init:
git config core.hooksPath .githooks

build: client_with_deps
go mod download
PATH=$(GOPATH)/bin:$(PATH) go generate ./...
CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean

client:
Expand All @@ -151,38 +152,40 @@ docker:
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)

lint: lint-js lint-go
lint: js-lint go-lint

lint-js: dependencies
@echo Running js linter
js-lint: dependencies
npm --prefix client run lint

lint-go:
@echo Running go linter
golangci-lint run
go-install-tools:
env GO=$(GO) sh ./scripts/go-install-tools.sh

go-lint:
env GO=$(GO) PATH="$$PWD/bin:$$PATH" sh ./scripts/go-lint.sh

test: test-js test-go

test-js:
js-test:
npm run test --prefix client

test-go:
go test $(TEST_FLAGS) --coverprofile coverage.txt ./...
go-test:
$(GO) test $(TEST_FLAGS) --coverprofile coverage.txt ./...

ci: client_with_deps
go mod download
$(GO) mod download
$(MAKE) test

dependencies:
npm --prefix client ci
go mod download
$(GO) mod download

clean:
rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
rm -f -r ./build/ ./client/node_modules/ ./data/ $(DIST_DIR)
rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
# Set the GOPATH explicitly in case make clean is called from under sudo
# after a Docker build.
env PATH="$(GOPATH)/bin:$$PATH" packr clean
rm -f -r ./bin/

docker-multi-arch:
DOCKER_CLI_EXPERIMENTAL=enabled \
Expand All @@ -200,7 +203,7 @@ docker-multi-arch:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)

release: client_with_deps
go mod download
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ You will need this to build AdGuard Home:
* [node.js](https://nodejs.org/en/download/) v10.16.2 or later.
* [npm](https://www.npmjs.com/) v6.14 or later.

Optionally, for Go devs:
* [golangci-lint](https://github.com/golangci/golangci-lint)

### Building

Open Terminal and execute these commands:
Expand All @@ -186,7 +183,7 @@ make

Check the [`Makefile`](https://github.com/AdguardTeam/AdGuardHome/blob/master/Makefile) to learn about other commands.

**Building for a different platform.** You can build AdGuard for any OS/ARCH just like any other Golang project.
**Building for a different platform.** You can build AdGuard for any OS/ARCH just like any other Go project.
In order to do this, specify `GOOS` and `GOARCH` env variables before running make.

For example:
Expand Down Expand Up @@ -331,4 +328,4 @@ For a full list of all node.js packages in use, please take a look at [client/pa
<a id="privacy"></a>
## Privacy

Our main idea is that you are the one, who should be in control of your data. So it is only natural, that AdGuard Home does not collect any usage statistics, and does not use any web services unless you configure it to do so. Full policy with every bit that _could in theory be_ sent by AdGuard Home is available [here](https://adguard.com/en/privacy/home.html).
Our main idea is that you are the one, who should be in control of your data. So it is only natural, that AdGuard Home does not collect any usage statistics, and does not use any web services unless you configure it to do so. Full policy with every bit that _could in theory be_ sent by AdGuard Home is available [here](https://adguard.com/en/privacy/home.html).
24 changes: 24 additions & 0 deletions internal/tools/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module github.com/AdguardTeam/AdGuardHome/internal/tools

go 1.15

require (
dmitri.shuralyov.com/go/generated v0.0.0-20170818220700-b1254a446363 // indirect
github.com/client9/misspell v0.3.4 // indirect
github.com/fzipp/gocyclo v0.3.1
github.com/golangci/misspell v0.3.5
github.com/google/go-cmp v0.5.4 // indirect
github.com/gookit/color v1.3.3 // indirect
github.com/gordonklaus/ineffassign v0.0.0-20201107091007-3b93a8888063
github.com/kisielk/errcheck v1.4.0
github.com/kyoh86/looppointer v0.1.7
github.com/kyoh86/nolint v0.0.1 // indirect
github.com/securego/gosec/v2 v2.5.0
golang.org/x/lint v0.0.0-20200302205851-738671d3881b
golang.org/x/mod v0.4.0 // indirect
golang.org/x/tools v0.0.0-20201208062317-e652b2f42cc7
gopkg.in/yaml.v2 v2.4.0 // indirect
honnef.co/go/tools v0.0.1-2020.1.6
mvdan.cc/gofumpt v0.0.0-20201129102820-5c11c50e9475
mvdan.cc/unparam v0.0.0-20200501210554-b37ab49443f7
)
Loading

0 comments on commit a8f2546

Please sign in to comment.