-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also adds the possibility to use the new docker compose subcommand instead of the standalone command.
- Loading branch information
Showing
2 changed files
with
89 additions
and
60 deletions.
There are no files selected for viewing
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,77 +1,102 @@ | ||
default: build | ||
GO ?= $(shell which go || echo go) | ||
DOCKER ?= $(shell which docker || echo docker) | ||
DOCKER_COMPOSE ?= $(shell docker compose &> /dev/null && echo "$(which docker)" compose || echo docker-compose) | ||
|
||
build: | ||
# build early to catch syntax errors | ||
CGO_ENABLED=0 go build | ||
CGO_ENABLED=0 go vet ./... | ||
CGO_ENABLED=0 go vet -tags integration | ||
gosrc = $(shell find * -type f -name '*.go') | ||
gomod = go.mod go.sum | ||
GOFLAGS = -trimpath | ||
|
||
mox: $(gosrc) $(gomod) config/doc.go webmail/api.ts webadmin webaccount webmail | ||
CGO_ENABLED=0 go build $(GOFLAGS) -o $@ | ||
|
||
webmail/api.ts: webmail/api.json $(gomod) | ||
$(GO) run github.com/mjl-/sherpats/cmd/sherpats -bytes-to-string -slices-nullable -maps-nullable -nullable-optional -namespace api api <$< >$@ | ||
|
||
.mox.tmp: main.go | ||
CGO_ENABLED=0 go build $(GOFLAGS) -o $@ | ||
|
||
config/doc.go: ./gendoc.sh | ||
$(MAKE) .mox.tmp | ||
./gendoc.sh | ||
(cd webadmin && CGO_ENABLED=0 go run ../vendor/github.com/mjl-/sherpadoc/cmd/sherpadoc/*.go -adjust-function-names none Admin) >webadmin/adminapi.json | ||
(cd webaccount && CGO_ENABLED=0 go run ../vendor/github.com/mjl-/sherpadoc/cmd/sherpadoc/*.go -adjust-function-names none Account) >webaccount/accountapi.json | ||
(cd webmail && CGO_ENABLED=0 go run ../vendor/github.com/mjl-/sherpadoc/cmd/sherpadoc/*.go -adjust-function-names none Webmail) >webmail/api.json | ||
go run vendor/github.com/mjl-/sherpats/cmd/sherpats/main.go -bytes-to-string -slices-nullable -maps-nullable -nullable-optional -namespace api api <webmail/api.json >webmail/api.ts | ||
# build again, api json files above are embedded | ||
CGO_ENABLED=0 go build | ||
rm .mox.tmp | ||
|
||
webadmin/adminapi.json: $(wildcard webadmin/*.go) $(gomod) | ||
cd webadmin && CGO_ENABLED=0 $(GO) run github.com/mjl-/sherpadoc/cmd/sherpadoc -adjust-function-names none Admin >$@ | ||
|
||
webaccount/accountapi.json: $(wildcard webaccount/*.go) $(gomod) | ||
cd webaccount && CGO_ENABLED=0 $(GO) run github.com/mjl-/sherpadoc/cmd/sherpadoc -adjust-function-names none Account >$@ | ||
|
||
webmail/api.json: $(wildcard webmail/*.go) $(gomod) | ||
cd webmail && CGO_ENABLED=0 $(GO) run github.com/mjl-/sherpadoc/cmd/sherpadoc -adjust-function-names none Webmail >$@ | ||
|
||
.PHONY: lint | ||
lint: | ||
CGO_ENABLED=0 $(GO) vet ./... | ||
CGO_ENABLED=0 $(GO) vet -tags integration | ||
staticcheck ./... | ||
staticcheck -tags integration | ||
GOARCH=386 CGO_ENABLED=0 $(GO) vet ./... | ||
|
||
.PHONY: test | ||
test: | ||
CGO_ENABLED=0 go test -shuffle=on -coverprofile cover.out ./... | ||
go tool cover -html=cover.out -o cover.html | ||
CGO_ENABLED=0 $(GO) test -shuffle=on -coverprofile cover.out ./... | ||
$(GO) tool cover -html=cover.out -o cover.html | ||
|
||
.PHONY: test-race | ||
test-race: | ||
CGO_ENABLED=1 go test -race -shuffle=on -covermode atomic -coverprofile cover.out ./... | ||
go tool cover -html=cover.out -o cover.html | ||
CGO_ENABLED=1 $(GO) test -race -shuffle=on -covermode atomic -coverprofile cover.out ./... | ||
$(GO) tool cover -html=cover.out -o cover.html | ||
|
||
# note: if testdata/upgradetest.mbox.gz exists, its messages will be imported | ||
# during tests. helpful for performance/resource consumption tests. | ||
.PHONY: test-upgrade | ||
test-upgrade: | ||
nice ./test-upgrade.sh | ||
|
||
check: | ||
staticcheck ./... | ||
staticcheck -tags integration | ||
GOARCH=386 CGO_ENABLED=0 go vet ./... | ||
|
||
# having "err" shadowed is common, best to not have others | ||
.PHONY: check-shadow | ||
check-shadow: | ||
go vet -vettool=$$(which shadow) ./... 2>&1 | grep -v '"err"' | ||
$(GO) vet -vettool=$$(which shadow) ./... 2>&1 | grep -v '"err"' | ||
|
||
.PHONY: fuzz | ||
fuzz: | ||
go test -fuzz FuzzParseSignature -fuzztime 5m ./dkim | ||
go test -fuzz FuzzParseRecord -fuzztime 5m ./dkim | ||
go test -fuzz . -fuzztime 5m ./dmarc | ||
go test -fuzz . -fuzztime 5m ./dmarcrpt | ||
go test -fuzz . -parallel 1 -fuzztime 5m ./imapserver | ||
go test -fuzz . -parallel 1 -fuzztime 5m ./junk | ||
go test -fuzz FuzzParseRecord -fuzztime 5m ./mtasts | ||
go test -fuzz FuzzParsePolicy -fuzztime 5m ./mtasts | ||
go test -fuzz . -parallel 1 -fuzztime 5m ./smtpserver | ||
go test -fuzz . -fuzztime 5m ./spf | ||
go test -fuzz FuzzParseRecord -fuzztime 5m ./tlsrpt | ||
go test -fuzz FuzzParseMessage -fuzztime 5m ./tlsrpt | ||
|
||
|
||
$(GO) test -fuzz FuzzParseSignature -fuzztime 5m ./dkim | ||
$(GO) test -fuzz FuzzParseRecord -fuzztime 5m ./dkim | ||
$(GO) test -fuzz . -fuzztime 5m ./dmarc | ||
$(GO) test -fuzz . -fuzztime 5m ./dmarcrpt | ||
$(GO) test -fuzz . -parallel 1 -fuzztime 5m ./imapserver | ||
$(GO) test -fuzz . -parallel 1 -fuzztime 5m ./junk | ||
$(GO) test -fuzz FuzzParseRecord -fuzztime 5m ./mtasts | ||
$(GO) test -fuzz FuzzParsePolicy -fuzztime 5m ./mtasts | ||
$(GO) test -fuzz . -parallel 1 -fuzztime 5m ./smtpserver | ||
$(GO) test -fuzz . -fuzztime 5m ./spf | ||
$(GO) test -fuzz FuzzParseRecord -fuzztime 5m ./tlsrpt | ||
$(GO) test -fuzz FuzzParseMessage -fuzztime 5m ./tlsrpt | ||
|
||
.PHONY: test-integration | ||
test-integration: | ||
docker image build --pull --no-cache -f Dockerfile -t mox_integration_moxmail . | ||
docker image build --pull --no-cache -f testdata/integration/Dockerfile.test -t mox_integration_test testdata/integration | ||
$(DOCKER) image build --pull --no-cache -f Dockerfile -t mox_integration_moxmail . | ||
$(DOCKER) image build --pull --no-cache -f testdata/integration/Dockerfile.test -t mox_integration_test testdata/integration | ||
-rm -rf testdata/integration/moxacmepebble/data | ||
-rm -rf testdata/integration/moxmail2/data | ||
-rm -f testdata/integration/tmp-pebble-ca.pem | ||
MOX_UID=$$(id -u) docker-compose -f docker-compose-integration.yml run test | ||
docker-compose -f docker-compose-integration.yml down --timeout 1 | ||
|
||
MOX_UID=$$(id -u) $(DOCKER_COMPOSE) -f docker-compose-integration.yml run test | ||
$(DOCKER_COMPOSE) -f docker-compose-integration.yml down --timeout 1 | ||
|
||
.PHONY: imaptest-build | ||
imaptest-build: | ||
-docker-compose -f docker-compose-imaptest.yml build --no-cache --pull mox | ||
-$(DOCKER_COMPOSE) -f docker-compose-imaptest.yml build --no-cache --pull mox | ||
|
||
.PHONY: imaptest-run | ||
imaptest-run: | ||
-rm -r testdata/imaptest/data | ||
mkdir testdata/imaptest/data | ||
docker-compose -f docker-compose-imaptest.yml run --entrypoint /usr/local/bin/imaptest imaptest host=mox port=1143 [email protected] pass=testtest mbox=imaptest.mbox | ||
docker-compose -f docker-compose-imaptest.yml down | ||
$(DOCKER_COMPOSE) -f docker-compose-imaptest.yml run --entrypoint /usr/local/bin/imaptest imaptest host=mox port=1143 [email protected] pass=testtest mbox=imaptest.mbox | ||
$(DOCKER_COMPOSE) -f docker-compose-imaptest.yml down | ||
|
||
|
||
fmt: | ||
go fmt ./... | ||
$(GO) fmt ./... | ||
gofmt -w -s *.go */*.go | ||
|
||
jswatch: | ||
|
@@ -100,26 +125,30 @@ webadmin/admin.htmlx: | |
webaccount/account.htmlx: | ||
./node_modules/.bin/jshint --extract always webaccount/account.html | ./fixjshintlines.sh | ||
|
||
.PHONY: frontend | ||
frontend: webadmin/admin.htmlx webaccount/account.htmlx webmail/webmail.js webmail/msg.js webmail/text.js | ||
|
||
.PHONY: docker | ||
docker: | ||
docker build -t mox:dev . | ||
$(DOCKER) build -t mox:dev . | ||
|
||
.PHONY: docker-release | ||
docker-release: | ||
./docker-release.sh | ||
|
||
.PHONY: buildall | ||
buildall: | ||
GOOS=linux GOARCH=arm go build | ||
GOOS=linux GOARCH=arm64 go build | ||
GOOS=linux GOARCH=amd64 go build | ||
GOOS=linux GOARCH=386 go build | ||
GOOS=openbsd GOARCH=amd64 go build | ||
GOOS=freebsd GOARCH=amd64 go build | ||
GOOS=netbsd GOARCH=amd64 go build | ||
GOOS=darwin GOARCH=amd64 go build | ||
GOOS=dragonfly GOARCH=amd64 go build | ||
GOOS=illumos GOARCH=amd64 go build | ||
GOOS=solaris GOARCH=amd64 go build | ||
GOOS=aix GOARCH=ppc64 go build | ||
GOOS=windows GOARCH=amd64 go build | ||
GOOS=linux GOARCH=arm $(GO) $(GOFLAGS) build | ||
GOOS=linux GOARCH=arm64 $(GO) $(GOFLAGS) build | ||
GOOS=linux GOARCH=amd64 $(GO) $(GOFLAGS) build | ||
GOOS=linux GOARCH=386 $(GO) $(GOFLAGS) build | ||
GOOS=openbsd GOARCH=amd64 $(GO) $(GOFLAGS) build | ||
GOOS=freebsd GOARCH=amd64 $(GO) $(GOFLAGS) build | ||
GOOS=netbsd GOARCH=amd64 $(GO) $(GOFLAGS) build | ||
GOOS=darwin GOARCH=amd64 $(GO) $(GOFLAGS) build | ||
GOOS=dragonfly GOARCH=amd64 $(GO) $(GOFLAGS) build | ||
GOOS=illumos GOARCH=amd64 $(GO) $(GOFLAGS) build | ||
GOOS=solaris GOARCH=amd64 $(GO) $(GOFLAGS) build | ||
GOOS=aix GOARCH=ppc64 $(GO) $(GOFLAGS) build | ||
GOOS=windows GOARCH=amd64 $(GO) $(GOFLAGS) build | ||
# no plan9 for now |