Skip to content
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

Pure Go SQLite #20614

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 11 additions & 11 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ steps:
environment:
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
GOSUMDB: sum.golang.org
TAGS: bindata sqlite sqlite_unlock_notify
TAGS: bindata
depends_on: [deps-backend]
volumes:
- name: deps
Expand All @@ -60,7 +60,7 @@ steps:
environment:
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
GOSUMDB: sum.golang.org
TAGS: bindata sqlite sqlite_unlock_notify
TAGS: bindata
GOOS: windows
GOARCH: amd64
depends_on: [deps-backend]
Expand All @@ -75,7 +75,7 @@ steps:
environment:
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
GOSUMDB: sum.golang.org
TAGS: bindata gogit sqlite sqlite_unlock_notify
TAGS: bindata gogit
depends_on: [deps-backend]
volumes:
- name: deps
Expand Down Expand Up @@ -272,7 +272,7 @@ steps:
environment:
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
GOSUMDB: sum.golang.org
TAGS: bindata sqlite sqlite_unlock_notify
TAGS: bindata
depends_on: [deps-backend, prepare-test-env]
volumes:
- name: deps
Expand All @@ -285,7 +285,7 @@ steps:
- make unit-test-coverage test-check
environment:
GOPROXY: https://goproxy.io
TAGS: bindata sqlite sqlite_unlock_notify
TAGS: bindata
RACE_ENABLED: true
GITHUB_READ_TOKEN:
from_secret: github_read_token
Expand All @@ -301,7 +301,7 @@ steps:
- make unit-test-coverage test-check
environment:
GOPROXY: https://goproxy.io
TAGS: bindata gogit sqlite sqlite_unlock_notify
TAGS: bindata gogit
RACE_ENABLED: true
GITHUB_READ_TOKEN:
from_secret: github_read_token
Expand Down Expand Up @@ -459,7 +459,7 @@ steps:
environment:
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
GOSUMDB: sum.golang.org
TAGS: bindata gogit sqlite sqlite_unlock_notify
TAGS: bindata gogit
depends_on: [deps-backend, prepare-test-env]
volumes:
- name: deps
Expand All @@ -472,9 +472,9 @@ steps:
- timeout -s ABRT 50m make test-sqlite-migration test-sqlite
environment:
GOPROXY: https://goproxy.io
TAGS: bindata gogit sqlite sqlite_unlock_notify
TAGS: bindata gogit
RACE_ENABLED: true
TEST_TAGS: gogit sqlite sqlite_unlock_notify
TEST_TAGS: gogit
USE_REPO_TEST_DIR: 1
depends_on: [build]
volumes:
Expand Down Expand Up @@ -658,7 +658,7 @@ steps:
- make release
environment:
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
TAGS: bindata sqlite sqlite_unlock_notify
TAGS: bindata
volumes:
- name: deps
path: /go
Expand Down Expand Up @@ -778,7 +778,7 @@ steps:
- make release
environment:
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
TAGS: bindata sqlite sqlite_unlock_notify
TAGS: bindata
depends_on: [fetch-tags]
volumes:
- name: deps
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct}

ARG GITEA_VERSION
ARG TAGS="sqlite sqlite_unlock_notify"
ENV TAGS "bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS

Expand Down
1 change: 0 additions & 1 deletion Dockerfile.rootless
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct}

ARG GITEA_VERSION
ARG TAGS="sqlite sqlite_unlock_notify"
ENV TAGS "bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ TAGS ?=
TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS))
TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags

TEST_TAGS ?= sqlite sqlite_unlock_notify
TEST_TAGS ?=

TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR)

Expand Down Expand Up @@ -796,7 +796,7 @@ editorconfig-checker:
.PHONY: docker
docker:
docker build --disable-content-trust=false -t $(DOCKER_REF) .
# support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite sqlite_unlock_notify" .
# support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata" .

.PHONY: docker-build
docker-build:
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ 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

The `build` target is split into two sub-targets:

- `make backend` which requires [Go Stable](https://go.dev/dl/), required version is defined in [go.mod](/go.mod).
Expand Down
2 changes: 1 addition & 1 deletion contrib/fixtures/fixture_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// To generate derivative fixtures, execute the following from Gitea's repository base dir:
// go run -tags 'sqlite sqlite_unlock_notify' contrib/fixtures/fixture_generation.go [fixture...]
// go run contrib/fixtures/fixture_generation.go [fixture...]

var (
generators = []struct {
Expand Down
1 change: 0 additions & 1 deletion contrib/ide/vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"type": "go",
"request": "launch",
"mode": "debug",
"buildFlags": "-tags='sqlite sqlite_unlock_notify'",
"program": "${workspaceRoot}/main.go",
"env": {
"GITEA_WORK_DIR": "${workspaceRoot}",
Expand Down
3 changes: 1 addition & 2 deletions contrib/ide/vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"go.buildTags": "'sqlite sqlite_unlock_notify'",
"go.testFlags": ["-v"]
}
}
6 changes: 3 additions & 3 deletions contrib/ide/vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
"panel": "shared"
},
"linux": {
"args": ["build", "-tags=\"sqlite sqlite_unlock_notify\"", "-o", "gitea", "${workspaceRoot}/main.go"]
"args": ["build", "-o", "gitea", "${workspaceRoot}/main.go"]
},
"osx": {
"args": ["build", "-tags=\"sqlite sqlite_unlock_notify\"", "-o", "gitea", "${workspaceRoot}/main.go"]
"args": ["build", "-o", "gitea", "${workspaceRoot}/main.go"]
},
"windows": {
"args": ["build", "-tags=\"sqlite sqlite_unlock_notify\"", "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""]
"args": ["build", "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""]
},
"problemMatcher": ["$go"]
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/pr/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func main() {
// Force build of js, css, bin, ...
runCmd("make", "build")
// Start with integration test
runCmd("go", "run", "-mod", "vendor", "-tags", "sqlite sqlite_unlock_notify", codeFilePath, "-run")
runCmd("go", "run", "-mod", "vendor", codeFilePath, "-run")
}

func runCmd(cmd ...string) {
Expand Down
6 changes: 3 additions & 3 deletions docs/content/doc/developers/hacking-on-gitea.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ from source</a>.
The simplest recommended way to build from source is:

```bash
TAGS="bindata sqlite sqlite_unlock_notify" make build
TAGS="bindata" make build
```

The `build` target will execute both `frontend` and `backend` sub-targets. If the `bindata` tag is present, the frontend files will be compiled into the binary. It is recommended to leave out the tag when doing frontend development so that changes will be reflected.
Expand Down Expand Up @@ -293,7 +293,7 @@ Unit tests are covered by `*_test.go` in `go test` system.
You can set the environment variable `GITEA_UNIT_TESTS_LOG_SQL=1` to display all SQL statements when running the tests in verbose mode (i.e. when `GOTESTFLAGS=-v` is set).

```bash
TAGS="bindata sqlite sqlite_unlock_notify" make test # Runs the unit tests
TAGS="bindata" make test # Runs the unit tests
```

### Integration Tests
Expand All @@ -302,7 +302,7 @@ Unit tests will not and cannot completely test Gitea alone. Therefore, we
have written integration tests; however, these are database dependent.

```bash
TAGS="bindata sqlite sqlite_unlock_notify" make build test-sqlite
TAGS="bindata" make build test-sqlite
```

will run the integration tests in an SQLite environment. Integration tests
Expand Down
7 changes: 2 additions & 5 deletions docs/content/doc/installation/from-source.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ are provided to keep the build process as simple as possible.
Depending on requirements, the following build tags can be included.

- `bindata`: Build a single monolithic binary, with all assets included.
- `sqlite sqlite_unlock_notify`: Enable support for a
[SQLite3](https://sqlite.org/) database. Suggested only for tiny
installations.
- `pam`: Enable support for PAM (Linux Pluggable Authentication Modules). Can
be used to authenticate local users or extend authentication to methods
available to PAM.
Expand All @@ -118,7 +115,7 @@ tags are: `TAGS="bindata sqlite sqlite_unlock_notify"`. The simplest
recommended way to build from source is therefore:

```bash
TAGS="bindata sqlite sqlite_unlock_notify" make build
TAGS="bindata" make build
```

The `build` target is split into two sub-targets:
Expand Down Expand Up @@ -182,7 +179,7 @@ GOOS=linux GOARCH=arm64 make build
Cross-build Gitea for Linux ARM64, with recommended build tags:

```
CC=aarch64-unknown-linux-gnu-gcc GOOS=linux GOARCH=arm64 TAGS="bindata sqlite sqlite_unlock_notify" make build
CC=aarch64-unknown-linux-gnu-gcc GOOS=linux GOARCH=arm64 TAGS="bindata" make build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also good to remove any reference to CGO? Like providing C profile here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If some users want to use some C modules like pam, then CGO is still needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression the pam module didn't use CGO as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we use https://github.com/msteinert/pam which is CGO 😔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If some users want to use some C modules like pam, then CGO is still needed.

But there is a build tag for pam

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If some users want to use some C modules like pam, then CGO is still needed.

But there is a build tag for pam

But this document is showing users how to set the C compiler if the CGO is needed when cross-build

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is no CGO, so the CC env could be removed?

```

Replace `CC`, `GOOS`, and `GOARCH` as appropriate for your architecture target.
Expand Down
1 change: 0 additions & 1 deletion docs/content/doc/installation/from-source.fr-fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ git checkout pr-xyz
Comme nous regroupons déjà toutes les bibliothèques requises pour compiler Gitea, vous pouvez continuer avec le processus de compilation lui-même. Nous fournissons diverses [tâches Make](https://github.com/go-gitea/gitea/blob/master/Makefile) pour rendre le processus de construction aussi simple que possible. <a href='{{< relref "doc/advanced/make.fr-fr.md" >}}'>Voyez ici comment obtenir Make</a>. Selon vos besoins, vous pourrez éventuellement ajouter diverses options de compilation, vous pouvez choisir entre ces options :

* `bindata`: Intègre toutes les ressources nécessaires à l'exécution d'une instance de Gitea, ce qui rend un déploiement facile car il n'est pas nécessaire de se préoccuper des fichiers supplémentaires.
* `sqlite sqlite_unlock_notify`: Active la prise en charge d'une base de données [SQLite3](https://sqlite.org/), ceci n'est recommandé que pour les petites installations de Gitea.
* `pam`: Active la prise en charge de PAM (mLinux Pluggable Authentication Modules), très utile si vos utilisateurs doivent être authentifiés avec les comptes du système.

Il est temps de compiler le binaire, nous suggérons d'intégrer les ressources avec l'option de compilation `bindata`:
Expand Down
3 changes: 1 addition & 2 deletions docs/content/doc/installation/from-source.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ git checkout v{{< version >}}
按照您的编译需求,以下 tags 可以使用:

- `bindata`: 这个编译选项将会把运行Gitea所需的所有外部资源都打包到可执行文件中,这样部署将非常简单因为除了可执行程序将不再需要任何其他文件。
- `sqlite sqlite_unlock_notify`: 这个编译选项将启用SQLite3数据库的支持,建议只在少数人使用时使用这个模式。
- `pam`: 这个编译选项将会启用 PAM (Linux Pluggable Authentication Modules) 认证,如果你使用这一认证模式的话需要开启这个选项。

使用 bindata 可以打包资源文件到二进制可以使开发和测试更容易,你可以根据自己的需求决定是否打包资源文件。
Expand All @@ -69,7 +68,7 @@ TAGS="bindata" make build
默认的发布版本中的编译选项是: `TAGS="bindata sqlite sqlite_unlock_notify"`。以下为推荐的编译方式:

```bash
TAGS="bindata sqlite sqlite_unlock_notify" make build
TAGS="bindata" make build
```

## 测试
Expand Down
1 change: 0 additions & 1 deletion docs/content/doc/installation/from-source.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ git checkout v{{< version >}}
完成設定相依性套件環境等工作後,您就可以開始編譯工作了。我們提供了不同的[編譯選項](https://github.com/go-gitea/gitea/blob/master/Makefile) ,讓編譯過程更加簡單。您可以根據需求來調整編譯選項,底下是可用的編譯選項說明:

* `bindata`: 使用此標籤來嵌入所有 Gitea 相關資源,您不用擔心其他額外檔案,對於部署來說非常方便。
* `sqlite sqlite_unlock_notify`: 使用此標籤來啟用 [SQLite3](https://sqlite.org/) 資料庫,建議只有少數人時才使用此模式。
* `pam`: 使用此標籤來啟用 PAM (Linux Pluggable Authentication Modules) 認證,對於系統使用者來說,此方式最方便了。

現在您可以開始編譯執行檔了,我們建議使用 `bindata` 編譯選項:
Expand Down
16 changes: 13 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ require (
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96
github.com/markbates/goth v1.72.0
github.com/mattn/go-isatty v0.0.14
github.com/mattn/go-sqlite3 v1.14.12
github.com/mholt/archiver/v3 v3.5.1
github.com/microcosm-cc/bluemonday v1.0.19
github.com/minio/minio-go/v7 v7.0.26
Expand Down Expand Up @@ -101,9 +100,10 @@ require (
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/ini.v1 v1.66.4
gopkg.in/yaml.v2 v2.4.0
modernc.org/sqlite v1.18.0
mvdan.cc/xurls/v2 v2.4.0
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
xorm.io/builder v0.3.11
xorm.io/builder v0.3.12
xorm.io/xorm v1.3.2-0.20220714055524-c3bce556200f
)

Expand Down Expand Up @@ -179,7 +179,7 @@ require (
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-openapi/validate v0.20.3 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/goccy/go-json v0.9.7 // indirect
github.com/goccy/go-json v0.9.10 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188 // indirect
Expand Down Expand Up @@ -237,6 +237,7 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/rs/xid v1.4.0 // indirect
Expand Down Expand Up @@ -287,6 +288,15 @@ require (
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
lukechampine.com/uint128 v1.1.1 // indirect
modernc.org/cc/v3 v3.36.0 // indirect
modernc.org/ccgo/v3 v3.16.6 // indirect
modernc.org/libc v1.16.7 // indirect
modernc.org/mathutil v1.4.1 // indirect
modernc.org/memory v1.1.1 // indirect
modernc.org/opt v0.1.1 // indirect
modernc.org/strutil v1.1.1 // indirect
modernc.org/token v1.0.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

Expand Down
Loading