Skip to content

Commit ad40264

Browse files
authored
Add 'make lint', restructure 'compliance' pipeline (#10861)
- Added 'lint', 'lint-frontend', 'lint-backend' targets - Added 'lint-frontend', 'lint-backend' ci steps and restructure the 'compliance' pipeline to have a clear separation between frontend and backend and use parallelism where possible. Also, the main build pipelines now depend on 'compliance' so they will skip if it fails. - Added dependencies on ci steps so they skip when 'compliance' fails - Moved JS linters to devDependencies - Removed deprecated 'js' and 'css' targets
1 parent 3f0cb8b commit ad40264

File tree

4 files changed

+419
-159
lines changed

4 files changed

+419
-159
lines changed

.drone.yml

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,47 @@ workspace:
1111
path: src/code.gitea.io/gitea
1212

1313
steps:
14-
- name: pre-build
14+
- name: deps-frontend
15+
pull: always
16+
image: node:12
17+
commands:
18+
- make node_modules
19+
20+
- name: lint-frontend
21+
pull: always
22+
image: node:12
23+
commands:
24+
- make lint-frontend
25+
depends_on: [deps-frontend]
26+
27+
- name: lint-backend
28+
pull: always
29+
image: golang:1.14
30+
commands:
31+
- make lint-backend
32+
environment:
33+
GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not
34+
GOSUMDB: sum.golang.org
35+
TAGS: bindata sqlite sqlite_unlock_notify
36+
37+
- name: build-frontend
1538
pull: always
1639
image: node:10 # this step is kept at the lowest version of node that we support
1740
commands:
18-
- make webpack
41+
- make frontend
42+
depends_on: [lint-frontend]
1943

20-
- name: build-without-gcc
44+
- name: build-backend-no-gcc
2145
pull: always
2246
image: golang:1.12 # this step is kept as the lowest version of golang that we support
2347
environment:
2448
GO111MODULE: on
2549
GOPROXY: off
2650
commands:
2751
- go build -mod=vendor -o gitea_no_gcc # test if build succeeds without the sqlite tag
52+
depends_on: [lint-backend]
2853

29-
- name: build-linux-386
54+
- name: build-backend-386
3055
pull: always
3156
image: golang:1.14
3257
environment:
@@ -36,16 +61,7 @@ steps:
3661
GOARCH: 386
3762
commands:
3863
- go build -mod=vendor -o gitea_linux_386 # test if compatible with 32 bit
39-
40-
- name: check
41-
pull: always
42-
image: golang:1.14
43-
commands:
44-
- make clean golangci-lint revive swagger-check swagger-validate test-vendor
45-
environment:
46-
GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not
47-
GOSUMDB: sum.golang.org
48-
TAGS: bindata sqlite sqlite_unlock_notify
64+
depends_on: [lint-backend]
4965

5066
---
5167
kind: pipeline
@@ -55,6 +71,9 @@ platform:
5571
os: linux
5672
arch: amd64
5773

74+
depends_on:
75+
- compliance
76+
5877
workspace:
5978
base: /go
6079
path: src/code.gitea.io/gitea
@@ -209,8 +228,6 @@ steps:
209228
- push
210229
- pull_request
211230

212-
213-
214231
---
215232
kind: pipeline
216233
name: testing-arm64
@@ -219,6 +236,9 @@ platform:
219236
os: linux
220237
arch: arm64
221238

239+
depends_on:
240+
- compliance
241+
222242
workspace:
223243
base: /go
224244
path: src/code.gitea.io/gitea
@@ -537,6 +557,9 @@ platform:
537557
os: linux
538558
arch: arm64
539559

560+
depends_on:
561+
- compliance
562+
540563
steps:
541564
- name: build-docs
542565
pull: always

Makefile

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(G
6969
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell GO111MODULE=on $(GO) list -mod=vendor ./... | grep -v /vendor/)))
7070

7171
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
72-
WEBPACK_CONFIGS := webpack.config.js .eslintrc .stylelintrc
72+
WEBPACK_CONFIGS := webpack.config.js
7373
WEBPACK_DEST := public/js/index.js public/css/index.css
7474
WEBPACK_DEST_DIRS := public/js public/css
7575

@@ -133,14 +133,18 @@ help:
133133
@echo " - backend build backend files"
134134
@echo " - clean delete backend and integration files"
135135
@echo " - clean-all delete backend, frontend and integration files"
136+
@echo " - lint lint everything"
137+
@echo " - lint-frontend lint frontend files"
138+
@echo " - lint-backend lint backend files"
136139
@echo " - webpack build webpack files"
137140
@echo " - fomantic build fomantic files"
138141
@echo " - generate run \"go generate\""
139142
@echo " - fmt format the Go code"
140143
@echo " - generate-swagger generate the swagger spec from code comments"
141144
@echo " - swagger-validate check if the swagger spec is valid"
142-
@echo " - revive run code linter revive"
143-
@echo " - misspell check if a word is written wrong"
145+
@echo " - golangci-lint run golangci-lint linter"
146+
@echo " - revive run revive linter"
147+
@echo " - misspell check for misspellings"
144148
@echo " - vet examines Go source code and reports suspicious constructs"
145149
@echo " - test run unit test"
146150
@echo " - test-sqlite run integration test for sqlite"
@@ -259,6 +263,17 @@ fmt-check:
259263
exit 1; \
260264
fi;
261265

266+
.PHONY: lint
267+
lint: lint-backend lint-frontend
268+
269+
.PHONY: lint-backend
270+
lint-backend: golangci-lint revive swagger-check swagger-validate test-vendor
271+
272+
.PHONY: lint-frontend
273+
lint-frontend: node_modules
274+
npx eslint web_src/js webpack.config.js
275+
npx stylelint web_src/less
276+
262277
.PHONY: test
263278
test:
264279
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' $(GO_PACKAGES)
@@ -540,16 +555,6 @@ npm-update: node-check | node_modules
540555
rm -rf node_modules package-lock.json
541556
npm install --package-lock
542557

543-
.PHONY: js
544-
js:
545-
@echo "'make js' is deprecated, please use 'make webpack'"
546-
$(MAKE) webpack
547-
548-
.PHONY: css
549-
css:
550-
@echo "'make css' is deprecated, please use 'make webpack'"
551-
$(MAKE) webpack
552-
553558
.PHONY: fomantic
554559
fomantic: $(FOMANTIC_DEST)
555560

@@ -564,8 +569,6 @@ $(FOMANTIC_DEST): $(FOMANTIC_CONFIGS) package-lock.json | node_modules
564569
webpack: $(WEBPACK_DEST)
565570

566571
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_modules
567-
npx eslint web_src/js webpack.config.js
568-
npx stylelint web_src/less
569572
npx webpack --hide-modules --display-entrypoints=false
570573
@touch $(WEBPACK_DEST)
571574

0 commit comments

Comments
 (0)