-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
70 lines (53 loc) · 3.08 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
SHELL = /bin/bash -o pipefail
.PHONY: test test-ci lint lint-ci fmt fmt-ci upgrade clean release lint-docs lint-docs-ci audit update-testdata encrypt decrypt sops
test:
gotestsum --format pkgname --packages ./... -- -race -timeout 10m -cover -covermode atomic
test-ci:
gotestsum --format pkgname --packages ./... --junitfile tests.xml -- -race -timeout 10m -coverprofile=coverage.txt -covermode atomic
gocover-cobertura < coverage.txt > coverage.xml
go tool cover -html=coverage.txt -o coverage.html
lint:
golangci-lint run --timeout 4m --color always --allow-parallel-runners --fix --max-issues-per-linter 0 --max-same-issues 0
find testdata -name '*.go' -print0 | xargs -0 -n1 -I % golangci-lint run --timeout 4m --color always --allow-parallel-runners --fix --max-issues-per-linter 0 --max-same-issues 0 %
lint-ci:
golangci-lint run --timeout 4m --max-issues-per-linter 0 --max-same-issues 0 --out-format colored-line-number,code-climate:codeclimate.json --issues-exit-code 0
find testdata -name '*.go' -print0 | xargs -0 -n1 -I % golangci-lint run --timeout 4m --max-issues-per-linter 0 --max-same-issues 0 --out-format colored-line-number,code-climate:%_codeclimate.json --issues-exit-code 0 %
jq -s 'add' codeclimate.json testdata/*_codeclimate.json > /tmp/codeclimate.json
mv /tmp/codeclimate.json codeclimate.json
rm -f testdata/*_codeclimate.json
jq -e '. == []' codeclimate.json
fmt:
go mod tidy
git ls-files --cached --modified --other --exclude-standard -z | grep -z -Z '.go$$' | xargs -0 gofumpt -w
git ls-files --cached --modified --other --exclude-standard -z | grep -z -Z '.go$$' | xargs -0 goimports -w -local gitlab.com/tozd/go/mediawiki
fmt-ci: fmt
git diff --exit-code --color=always
upgrade:
go run github.com/icholy/[email protected] get all
go mod tidy
clean:
rm -rf coverage.* codeclimate.json testdata/*_codeclimate.json tests.xml coverage
release:
npx --yes --package '[email protected]' --package '@release-it/[email protected]' -- release-it
lint-docs:
npx --yes --package 'markdownlint-cli@~0.41.0' -- markdownlint --ignore-path .gitignore --ignore testdata/ --fix '**/*.md'
lint-docs-ci: lint-docs
git diff --exit-code --color=always
audit:
go list -json -deps ./... | nancy sleuth --skip-update-check
update-testdata:
go -C testdata run update.go
gzip --keep --force testdata/commons-testdata-mediainfo.json
bzip2 --keep --force testdata/commons-testdata-mediainfo.json
gzip --keep --force testdata/wikidata-testdata-all.json
bzip2 --keep --force testdata/wikidata-testdata-all.json
tar -C testdata --create --file testdata/enwiki-NS0-testdata-ENTERPRISE-HTML.json.tar enwiki_namespace_0_0.ndjson
rm -f testdata/enwiki_namespace_0_0.ndjson
gzip --keep --force testdata/enwiki-NS0-testdata-ENTERPRISE-HTML.json.tar
bzip2 --keep --force testdata/enwiki-NS0-testdata-ENTERPRISE-HTML.json.tar
encrypt:
gitlab-config sops --encrypt --mac-only-encrypted --in-place --encrypted-comment-regex sops:enc .gitlab-conf.yml
decrypt:
SOPS_AGE_KEY_FILE=keys.txt gitlab-config sops --decrypt --in-place .gitlab-conf.yml
sops:
SOPS_AGE_KEY_FILE=keys.txt gitlab-config sops .gitlab-conf.yml