8000 chore: use Task as main build tool by unknwon · Pull Request #6297 · gogs/gogs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: use Task as main build tool #6297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to Gogs are documented in this file.

- The default branch has been changed to `main`. [#6285](https://github.com/gogs/gogs/pull/6285)
- MSSQL as database backend is deprecated, installation page no longer shows it as an option. Existing installations and manually craft configuration file continue to work. [#6295](https://github.com/gogs/gogs/pull/6295)
- Use [Task](https://github.com/go-task/task) as the default build tool for development. [#6297](https://github.com/gogs/gogs/pull/6297)

### Fixed

Expand Down
68 changes: 68 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: '3'

tasks:
web:
deps: [build]
cmds:
- ./gogs web
sources:
- gogs.go
- internal/**/*.go

build:
cmds:
- go build -v
-ldflags '
-X "{{.PKG_PATH}}.BuildTime={{.BUILD_TIME}}"
-X "{{.PKG_PATH}}.BuildCommit={{.BUILD_COMMIT}}"
'
-tags '{{.TAGS}}'
-trimpath -o gogs
vars:
PKG_PATH: gogs.io/gogs/internal/conf
BUILD_TIME:
sh: date -u '+%Y-%m-%d %I:%M:%S %Z'
BUILD_COMMIT:
sh: git rev-parse HEAD

generate:
deps: [clean]
cmds:
- go generate internal/assets/conf/conf.go
- go generate internal/assets/templates/templates.go
- go generate internal/assets/public/public.go

test:
cmds:
- go test -cover -race ./...

clean:
cmds:
- find . -name "*.DS_Store" -type f -delete

release:
deps: [build]
cmds:
- rm -rf {{.RELEASE_GOGS}}
- mkdir -p {{.RELEASE_GOGS}}
- cp -r gogs LICENSE README.md README_ZH.md scripts {{.RELEASE_GOGS}}
- cd {{.RELEASE_ROOT}} && zip -r gogs.$(NOW).zip "gogs"
vars:
RELEASE_ROOT: release
RELEASE_GOGS: release/gogs

less:
cmds:
- lessc --clean-css --source-map "public/less/gogs.less" public/css/gogs.min.css

fixme:
cmds:
- grep -rnw "FIXME" internal

todo:
cmds:
- grep -rnw "TODO" internal

legacy:
cmds:
- grep -rnw "\(LEGACY\|Deprecated\)" internal
15 changes: 9 additions & 6 deletions docs/dev/local_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gogs has the following dependencies:
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) (v1.8.3 or higher)
- [Go](https://golang.org/doc/install) (v1.14 or higher)
- [Less.js](http://lesscss.org/usage/#command-line-usage-installing)
- [GNU Make](https://www.gnu.org/software/make/)
- [Task](https://github.com/go-task/task)
- Database upon your choice (pick one, we choose PostgreSQL in this document):
- [PostgreSQL](https://wiki.postgresql.org/wiki/Detailed_installation_guides) (v9.6 or higher)
- [MySQL](https://dev.mysql.com/downloads/mysql/) with `ENGINE=InnoDB` (v5.7 or higher)
Expand All @@ -38,7 +38,7 @@ Gogs has the following dependencies:
1. Install dependencies:

```bash
brew install go postgresql git go-bindata npm
brew install go postgresql git go-bindata npm go-task/tap/go-task
npm install -g less
npm install -g less-plugin-clean-css
```
Expand Down Expand Up @@ -78,6 +78,7 @@ Gogs has the following dependencies:
npm install -g less
# Watch out, it is NOT github.com/go-bindata/go-bindata!
go get -u github.com/kevinburke/go-bindata/...
go get go-task/task/cmd/task
```

1. Configure startup services:
Expand Down Expand Up @@ -130,21 +131,23 @@ Create a `custom/conf/app.ini` file inside the repository and put the following

```ini
[database]
DB_TYPE = postgres
TYPE = postgres
HOST = 127.0.0.1:5432
NAME = gogs
USER = gogs
PASSWD = <YOUR PASSWORD HERE>
PASSWORD = <YOUR PASSWORD HERE>
SSL_MODE = disable
```

## Step 5: Start the server

The following command will start the web server and automatically recompile and restart the server if any Go files changed:

```bash
make web
task web --watch
```

You would have to re-run this command after changing Go files, or any file under `conf/`, `template/` and `public/` directories.
**NOTE** If you changed any file under `conf/`, `template/` or `public/` directory, be sure to run `task generate` afterwards!

## Other nice things

Expand Down
0