Skip to content

Commit

Permalink
Merge branch 'master' into embedded
Browse files Browse the repository at this point in the history
  • Loading branch information
guillep2k committed Jan 30, 2020
2 parents 7d8ee85 + 35ada59 commit 5f730b8
Show file tree
Hide file tree
Showing 129 changed files with 4,083 additions and 2,099 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ steps:
pull: always
image: node:10 # this step is kept at the lowest version of node that we support
commands:
- make css js
- make webpack

- name: build-without-gcc
pull: always
Expand Down Expand Up @@ -118,7 +118,7 @@ steps:
pull: always
image: golang:1.13
commands:
- make unit-test-coverage
- make unit-test-coverage test-check
environment:
GOPROXY: off
TAGS: bindata sqlite sqlite_unlock_notify
Expand Down
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf

[*.md]
trim_trailing_whitespace = false

[*.go]
indent_style = tab
indent_size = 8
Expand Down
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ globals:
CodeMirror: false
Dropzone: false
emojify: false
hljs: false
SimpleMDE: false
u2fApi: false
Vue: false
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ _testmain.go
coverage.all

/modules/options/bindata.go
/modules/options/bindata.go.hash
/modules/public/bindata.go
/modules/public/bindata.go.hash
/modules/templates/bindata.go
/modules/templates/bindata.go.hash

*.db
*.log
Expand Down
10 changes: 1 addition & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,7 @@ included in the next released version.

## Building Gitea

Generally, the go build tools are installed as-needed in the `Makefile`.
An exception are the tools to build the CSS, JS and images.

- To build CSS and JS: Install [Node.js](https://nodejs.org/en/download/package-manager) at version 10.0 or above
with `npm` and then run `npm install`, `make css` and `make js`.
- To build Images: ImageMagick, inkscape and zopflipng binaries must be
available in your `PATH` to run `make generate-images`.

For more details on how to generate files, build and test Gitea, see the [hacking instructions](https://docs.gitea.io/en-us/hacking-on-gitea/)
See the [hacking instructions](https://docs.gitea.io/en-us/hacking-on-gitea/).

## Code review

Expand Down
98 changes: 58 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export GO111MODULE=off
GO ?= go
SED_INPLACE := sed -i
SHASUM ?= shasum -a 256
GOPATH ?= $(shell $(GO) env GOPATH)

export PATH := $($(GO) env GOPATH)/bin:$(PATH)
export PATH := $(GOPATH)/bin:$(PATH)

ifeq ($(OS), Windows_NT)
EXECUTABLE ?= gitea.exe
Expand All @@ -29,6 +30,10 @@ EXTRA_GOFLAGS ?=

MAKE_VERSION := $(shell $(MAKE) -v | head -n 1)

ifneq ($(RACE_ENABLED),)
GOTESTFLAGS ?= -race
endif

ifneq ($(DRONE_TAG),)
VERSION ?= $(subst v,,$(DRONE_TAG))
GITEA_VERSION ?= $(VERSION)
Expand All @@ -46,15 +51,13 @@ LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(G
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/)))

GO_SOURCES ?= $(shell find . -name "*.go" -type f)
JS_SOURCES ?= $(shell find web_src/js web_src/css -type f)
CSS_SOURCES ?= $(shell find web_src/less -type f)
WEBPACK_SOURCES ?= $(shell find web_src/js web_src/css web_src/less -type f)

JS_DEST := public/js/index.js
CSS_DEST := public/css/index.css
WEBPACK_DEST := public/js/index.js public/css/index.css
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))

JS_DEST_DIR := public/js
CSS_DEST_DIR := public/css
WEBPACK_DEST_DIRS := public/js public/css
FOMANTIC_DEST_DIR := public/fomantic

TAGS ?=
Expand Down Expand Up @@ -86,9 +89,6 @@ TEST_MSSQL_DBNAME ?= gitea
TEST_MSSQL_USERNAME ?= sa
TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1

# $(call strip-suffix,filename)
strip-suffix = $(firstword $(subst ., ,$(1)))

.PHONY: all
all: build

Expand All @@ -101,10 +101,9 @@ help:
@echo " - build creates the entire project"
@echo " - clean delete integration files and build files but not css and js files"
@echo " - clean-all delete all generated files (integration test, build, css and js files)"
@echo " - css rebuild only css files"
@echo " - js rebuild only js files"
@echo " - webpack rebuild only js and css files"
@echo " - fomantic rebuild fomantic-ui files"
@echo " - generate run \"make fomantic css js\" and \"go generate\""
@echo " - generate run \"make fomantic webpack\" and \"go generate\""
@echo " - fmt format the code"
@echo " - generate-swagger generate the swagger spec from code comments"
@echo " - swagger-validate check if the swagger spec is valid"
Expand Down Expand Up @@ -140,12 +139,12 @@ node-check:

.PHONY: clean-all
clean-all: clean
rm -rf $(JS_DEST_DIR) $(CSS_DEST_DIR) $(FOMANTIC_DEST_DIR)
rm -rf $(WEBPACK_DEST_DIRS) $(FOMANTIC_DEST_DIR)

.PHONY: clean
clean:
$(GO) clean -i ./...
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) \
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \
integrations*.test \
integrations/gitea-integration-pgsql/ integrations/gitea-integration-mysql/ integrations/gitea-integration-mysql8/ integrations/gitea-integration-sqlite/ \
integrations/gitea-integration-mssql/ integrations/indexers-mysql/ integrations/indexers-mysql8/ integrations/indexers-pgsql integrations/indexers-sqlite \
Expand All @@ -160,8 +159,8 @@ vet:
$(GO) vet $(PACKAGES)

.PHONY: generate
generate: fomantic js css
GO111MODULE=on $(GO) generate -mod=vendor $(PACKAGES)
generate: fomantic webpack
GO111MODULE=on $(GO) generate -mod=vendor -tags '$(TAGS)' $(PACKAGES)

.PHONY: generate-swagger
generate-swagger:
Expand Down Expand Up @@ -224,7 +223,19 @@ fmt-check:

.PHONY: test
test:
GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES)

PHONY: test-check
test-check:
@echo "Checking if tests have changed the source tree...";
@diff=$$(git status -s); \
if [ -n "$$diff" ]; then \
echo "make test has changed files in the source tree:"; \
echo "$${diff}"; \
echo "You should change the tests to create these files in a temporary directory."; \
echo "Do not simply add these files to .gitignore"; \
exit 1; \
fi;

.PHONY: test\#%
test\#%:
Expand All @@ -239,7 +250,7 @@ coverage:

.PHONY: unit-test-coverage
unit-test-coverage:
GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1

.PHONY: vendor
vendor:
Expand Down Expand Up @@ -364,42 +375,42 @@ integration-test-coverage: integrations.cover.test generate-ini-mysql
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out

integrations.mysql.test: git-check $(GO_SOURCES)
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql.test
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql.test

integrations.mysql8.test: git-check $(GO_SOURCES)
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql8.test
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql8.test

integrations.pgsql.test: git-check $(GO_SOURCES)
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.pgsql.test
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.pgsql.test

integrations.mssql.test: git-check $(GO_SOURCES)
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mssql.test
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mssql.test

integrations.sqlite.test: git-check $(GO_SOURCES)
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'

integrations.cover.test: git-check $(GO_SOURCES)
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES) | tr ' ' ',') -o integrations.cover.test
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES) | tr ' ' ',') -o integrations.cover.test

.PHONY: migrations.mysql.test
migrations.mysql.test: $(GO_SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql.test
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql.test

.PHONY: migrations.mysql8.test
migrations.mysql8.test: $(GO_SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql8.test
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql8.test

.PHONY: migrations.pgsql.test
migrations.pgsql.test: $(GO_SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.pgsql.test
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.pgsql.test

.PHONY: migrations.mssql.test
migrations.mssql.test: $(GO_SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mssql.test
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.mssql.test

.PHONY: migrations.sqlite.test
migrations.sqlite.test: $(GO_SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'

.PHONY: check
check: test
Expand Down Expand Up @@ -468,6 +479,7 @@ release-compress:

node_modules: package-lock.json
npm install --no-save
@touch node_modules

.PHONY: npm-update
npm-update: node-check | node_modules
Expand All @@ -476,11 +488,14 @@ npm-update: node-check | node_modules
npm install --package-lock

.PHONY: js
js: node-check $(JS_DEST)
js:
@echo "'make js' is deprecated, please use 'make webpack'"
$(MAKE) webpack

$(JS_DEST): $(JS_SOURCES) | node_modules
npx eslint web_src/js webpack.config.js
npx webpack --hide-modules --display-entrypoints=false
.PHONY: css
css:
@echo "'make css' is deprecated, please use 'make webpack'"
$(MAKE) webpack

.PHONY: fomantic
fomantic: node-check $(FOMANTIC_DEST_DIR)
Expand All @@ -489,15 +504,16 @@ $(FOMANTIC_DEST_DIR): semantic.json web_src/fomantic/theme.config.less | node_mo
cp web_src/fomantic/theme.config.less node_modules/fomantic-ui/src/theme.config
cp web_src/fomantic/_site/globals/* node_modules/fomantic-ui/src/_site/globals/
npx gulp -f node_modules/fomantic-ui/gulpfile.js build
@touch $(FOMANTIC_DEST_DIR)

.PHONY: css
css: node-check $(CSS_DEST)
.PHONY: webpack
webpack: node-check $(WEBPACK_DEST)

$(CSS_DEST): $(CSS_SOURCES) | node_modules
$(WEBPACK_DEST): $(WEBPACK_SOURCES) | node_modules
npx eslint web_src/js webpack.config.js
npx stylelint web_src/less
npx lessc web_src/less/index.less public/css/index.css
$(foreach file, $(filter-out web_src/less/themes/_base.less, $(wildcard web_src/less/themes/*)),npx lessc web_src/less/themes/$(notdir $(file)) > public/css/theme-$(notdir $(call strip-suffix,$(file))).css;)
npx postcss --use autoprefixer --use cssnano --no-map --replace public/css/*
npx webpack --hide-modules --display-entrypoints=false
@touch $(WEBPACK_DEST)

.PHONY: update-translations
update-translations:
Expand Down Expand Up @@ -534,6 +550,8 @@ generate-images:
convert $(TMPDIR)/images/16.png $(TMPDIR)/images/32.png \
$(TMPDIR)/images/64.png $(TMPDIR)/images/128.png \
$(PWD)/public/img/favicon.ico
convert $(PWD)/public/img/favicon.png -fill white -opaque none $(PWD)/public/img/apple-touch-icon.png

rm -rf $(TMPDIR)/images
$(foreach file, $(shell find public/img -type f -name '*.png'),zopflipng -m -y $(file) $(file);)

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ From the root of the source tree, run:

TAGS="bindata" make build

or if sqlite support is required:

TAGS="bindata sqlite sqlite_unlock_notify" make build

More info: https://docs.gitea.io/en-us/install-from-source/

## Using
Expand Down
Loading

0 comments on commit 5f730b8

Please sign in to comment.