Skip to content

Commit ec6c0fd

Browse files
committed
refactor: invert build tag semantics
Change build tags from opt-in to opt-out. Previously, features like persistence storage backends required explicit build tags to be included. This change simplifies the build process by enabling all features by default and requiring build tags only to disable features. For example, the `no_mysql` build tag disables MySQL support. As a result, we can now simply run `go build` to build the wfx binary. Signed-off-by: Michael Adler <michael.adler@siemens.com>
1 parent 16f613d commit ec6c0fd

23 files changed

+52
-68
lines changed

.goreleaser.yml

-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ builds:
1616
- id: wfx
1717
binary: wfx
1818
main: ./cmd/wfx
19-
tags:
20-
- sqlite
21-
- postgres
22-
- mysql
23-
- plugin
24-
- swagger
2519
flags:
2620
- -trimpath
2721
- -mod=readonly

DEVELOPMENT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ To make tools like `gopls` (the Go language server) understand build tags,
1010
set the `GOFLAGS` environment variable accordingly, e.g.
1111

1212
```sh
13-
export GOFLAGS="-tags=integration,sqlite,mysql,postgres"
13+
export GOFLAGS="-tags=integration,testing"
1414
```
1515

1616
## Persistence

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MAKEFLAGS += --jobs=$(shell nproc)
1313
DESTDIR ?=
1414
prefix ?= /usr/local
1515

16-
GO_TAGS = sqlite,postgres,mysql,plugin,swagger
16+
GO_TAGS ?=
1717

1818
export CGO_ENABLED=1
1919

@@ -31,7 +31,7 @@ default:
3131

3232
.PHONY: test
3333
test:
34-
go test -race -coverprofile=coverage.out -covermode=atomic -timeout 30s ./... "--tags=sqlite,testing,plugin"
34+
go test -race -coverprofile=coverage.out -covermode=atomic -timeout 30s ./... --tags=testing
3535

3636
.PHONY: install
3737
install:

cmd/wfx/cmd/root/plugins_disabled.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !plugin
1+
//go:build no_plugin
22

33
package root
44

cmd/wfx/cmd/root/plugins_disabled_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !plugin
1+
//go:build no_plugin
22

33
package root
44

cmd/wfx/cmd/root/plugins_enabled.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build plugin
1+
//go:build !no_plugin
22

33
package root
44

cmd/wfx/cmd/root/plugins_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build plugin
1+
//go:build !no_plugin
22

33
package root
44

cmd/wfx/cmd/root/tag_mysql.go renamed to cmd/wfx/cmd/root/tag_no_mysql.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build mysql
1+
//go:build no_mysql
22

33
/*
44
* SPDX-FileCopyrightText: 2025 Siemens AG
@@ -11,5 +11,5 @@
1111
package root
1212

1313
func init() {
14-
buildTags = append(buildTags, "mysql")
14+
buildTags = append(buildTags, "no_mysql")
1515
}

cmd/wfx/cmd/root/tag_plugin.go renamed to cmd/wfx/cmd/root/tag_no_plugin.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build plugin
1+
//go:build no_plugin
22

33
/*
44
* SPDX-FileCopyrightText: 2025 Siemens AG
@@ -11,5 +11,5 @@
1111
package root
1212

1313
func init() {
14-
buildTags = append(buildTags, "plugin")
14+
buildTags = append(buildTags, "no_plugin")
1515
}

cmd/wfx/cmd/root/tag_no_postgres.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//go:build no_postgres
2+
3+
/*
4+
* SPDX-FileCopyrightText: 2025 Siemens AG
5+
*
6+
* SPDX-License-Identifier: Apache-2.0
7+
*
8+
* Author: Michael Adler <michael.adler@siemens.com>
9+
*/
10+
11+
package root
12+
13+
func init() {
14+
buildTags = append(buildTags, "no_postgres")
15+
}

cmd/wfx/cmd/root/tag_postgres.go renamed to cmd/wfx/cmd/root/tag_no_sqlite.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build postgres
1+
//go:build no_sqlite
22

33
/*
44
* SPDX-FileCopyrightText: 2025 Siemens AG
@@ -11,5 +11,5 @@
1111
package root
1212

1313
func init() {
14-
buildTags = append(buildTags, "postgres")
14+
buildTags = append(buildTags, "no_sqlite")
1515
}

cmd/wfx/cmd/root/tag_sqlite.go renamed to cmd/wfx/cmd/root/tag_no_swagger.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build sqlite
1+
//go:build no_swagger
22

33
/*
44
* SPDX-FileCopyrightText: 2025 Siemens AG
@@ -11,5 +11,5 @@
1111
package root
1212

1313
func init() {
14-
buildTags = append(buildTags, "sqlite")
14+
buildTags = append(buildTags, "no_swagger")
1515
}

cmd/wfx/cmd/root/tag_swagger.go

-15
This file was deleted.

docs/installation.md

+9-14
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,21 @@ All binaries have extensive help texts when invoked with `--help`.
3535

3636
### Build Tags
3737

38-
Go [build tags](https://pkg.go.dev/go/build) are used to select compiled-in support for various features.
39-
The following persistent storage selection build tags are available:
38+
Go [build tags](https://pkg.go.dev/go/build) can be used to opt-out from various features at compile-time.
39+
By default, all features are enabled. The following build tags are available:
4040

4141
| Build Tag | Description |
4242
| :----------- | :--------------------------------------------------------------- |
43-
| `sqlite` | Enable built-in [SQLite](https://www.sqlite.org/) support |
43+
| `no_sqlite` | Disable built-in [SQLite](https://www.sqlite.org/) support |
4444
| `libsqlite3` | Dynamically link against `libsqlite3` |
45-
| `postgres` | Enable built-in [PostgreSQL](https://www.postgresql.org) support |
46-
| `mysql` | Enable built-in [MySQL](https://www.mysql.com/) support |
47-
| `plugin` | Enable support for [external plugins](operations.md#plugins) |
45+
| `no_postgres` | Disable built-in [PostgreSQL](https://www.postgresql.org) support |
46+
| `no_mysql` | Disable built-in [MySQL](https://www.mysql.com/) support |
47+
| `no_plugin` | Disable support for [external plugins](operations.md#plugins) |
4848

49-
By default, all built-in persistent storage options are enabled (wfx requires at least one persistent storage to save workflows and jobs).
49+
Note:
5050

51-
Note that the selection of build tags can impact the size of the `wfx` binary file and may as well have implications for the software clearing process, including obligations that must be met.
52-
53-
To build and compile-in, e.g., SQLite persistent storage support only, according `GO_TAGS` must be given:
54-
55-
```bash
56-
make GO_TAGS=sqlite
57-
```
51+
- wfx requires at least one persistent storage to save workflows and jobs
52+
- build tags can impact the size of the `wfx` binary file and may as well have implications for the software clearing process, including obligations that must be met
5853

5954
### Debian
6055

internal/persistence/entgo/mysql.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build mysql
1+
//go:build !no_mysql
22

33
package entgo
44

internal/persistence/entgo/mysql_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build integration && mysql
1+
//go:build integration && !no_mysql
22

33
package entgo
44

internal/persistence/entgo/postgres.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build postgres
1+
//go:build !no_postgres
22

33
package entgo
44

internal/persistence/entgo/postgres_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build integration && postgres
1+
//go:build integration && !no_postgres
22

33
package entgo
44

internal/persistence/entgo/sqlite.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build sqlite
1+
//go:build !no_sqlite
22

33
package entgo
44

internal/persistence/entgo/sqlite_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build sqlite
1+
//go:build !no_sqlite
22

33
package entgo
44

justfile

+5-11
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ lint:
6464
#!/usr/bin/env bash
6565
set -euo pipefail
6666
export CGO_ENABLED=0
67-
golangci-lint run -v --build-tags=sqlite,testing
68-
staticcheck -tags=sqlite,testing ./...
67+
golangci-lint run -v --build-tags=testing
68+
staticcheck -tags=testing ./...
6969
go list ./... 2>/dev/null | sed -e 's,github.com/siemens/wfx/,,' | grep -v "^generated" | sort | uniq | while read -r pkg; do
70-
if [[ "$pkg" == *tests* ]]; then
70+
if [[ "$pkg" == *tests* ]] || [[ ! -d "$pkg" ]]; then
7171
continue
7272
fi
7373
file_count=$(find "$pkg" -maxdepth 1 -type f -name "*.go" | wc -l)
@@ -161,10 +161,7 @@ postgres-stop: (_container-stop "wfx-postgres")
161161

162162
# Run PostgreSQL integration tests.
163163
postgres-integration-test:
164-
#!/usr/bin/env bash
165-
set -eux
166-
# note: sqlite is needed for in-memory tests
167-
go test -tags testing,integration,postgres,sqlite,plugin -count=1 ./...
164+
go test -tags testing,integration,no_mysql -count=1 ./...
168165

169166
# Start wfx and connect to Postgres database
170167
@postgres-wfx: postgres-start
@@ -231,10 +228,7 @@ mysql-generate-schema name:
231228

232229
# Run MySQL integration tests.
233230
mysql-integration-test:
234-
#!/usr/bin/env bash
235-
set -eux
236-
# note: sqlite is needed for in-memory tests
237-
go test -tags testing,integration,mysql,sqlite,plugin -count=1 ./...
231+
go test -tags testing,integration,no_postgres -count=1 ./...
238232

239233
# Start wfx and connect to MySQL container.
240234
mysql-wfx: mysql-start

main.go

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./cmd/wfx/main.go

spec/swagger.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build swagger
1+
//go:build !no_swagger
22

33
package spec
44

0 commit comments

Comments
 (0)