Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: run go test with release tag (#1450)

qsliue1f05d0db476
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 9214127e20..502fde8ecd 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -35,6 +35,11 @@ jobs:
git diff --exit-code
go-tests:
+ strategy:
+ matrix:
+ release-tags:
+ - "release,"
+ - ""
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -51,10 +56,16 @@ jobs:
./resources/mysql/*.tar.gz
./resources/mysql/*.tar.xz
key: ${{ runner.OS }}-build-mysql-cache
+ # Release mode needs to embed fronetend dist
+ - name: Touch garbage dist/index.html
+ if: ${{ matrix.release-tags }}
+ run: |
+ mkdir -p server/dist
+ touch server/dist/index.html
- name: Install dependencies and run all tests
run: |
- go generate -tags mysql ./...
- go test -v ./... -tags=mysql
+ go generate -tags ${{ matrix.release-tags }}mysql ./...
+ go test -v ./... -tags=${{ matrix.release-tags }}mysql
# tests if scripts/install_bb.sh is working correctly.
install-bb:
diff --git a/bin/server/cmd/profile.go b/bin/server/cmd/profile.go
new file mode 100644
index 0000000000..783bcbec8c
--- /dev/null
+++ b/bin/server/cmd/profile.go
@@ -0,0 +1,42 @@
+package cmd
+
+import (
+ "fmt"
+ "time"
+
+ "github.com/bytebase/bytebase/common"
+ "github.com/bytebase/bytebase/server"
+)
+
+// GetTestProfile will return a profile for testing.
+// We require port as an argument of GetTestProfile so that test can run in parallel in different ports.
+func GetTestProfile(dataDir string, port int) server.Profile {
+ // Using flags.port + 1 as our datastore port
+ datastorePort := port + 1
+ return server.Profile{
+ Mode: common.ReleaseModeDev,
+ BackendHost: flags.host,
+ BackendPort: port,
+ DatastorePort: datastorePort,
+ PgUser: "bbtest",
+ DataDir: dataDir,
+ DemoDataDir: fmt.Sprintf("demo/%s", common.ReleaseModeDev),
+ BackupRunnerInterval: 10 * time.Second,
+ }
+}
+
+// GetTestProfileWithExternalPg will return a profile for testing with external Postgres.
+// We require port as an argument of GetTestProfile so that test can run in parallel in different ports,
+// pgURL for connect to Postgres.
+func GetTestProfileWithExternalPg(dataDir string, port int, pgUser string, pgURL string) server.Profile {
+ return server.Profile{
+ Mode: common.ReleaseModeDev,
+ BackendHost: flags.host,
+ BackendPort: port,
+ PgUser: pgUser,
+ DataDir: dataDir,
+ DemoDataDir: fmt.Sprintf("demo/%s", common.ReleaseModeDev),
+ BackupRunnerInterval: 10 * time.Second,
+ PgURL: pgURL,
+ }
+}
diff --git a/bin/server/cmd/profile_dev.go b/bin/server/cmd/profile_dev.go
index 3d0fe8763b..b24b0d0a61 100644
--- a/bin/server/cmd/profile_dev.go
+++ b/bin/server/cmd/profile_dev.go
@@ -33,36 +33,3 @@ func activeProfile(dataDir string) server.Profile {
MetricConnectionKey: "3zcZLeX3ahvlueEJqNyJysGfVAErsjjT",
}
}
-
-// GetTestProfile will return a profile for testing.
-// We require port as an argument of GetTestProfile so that test can run in parallel in different ports.
-func GetTestProfile(dataDir string, port int) server.Profile {
- // Using flags.port + 1 as our datastore port
- datastorePort := port + 1
- return server.Profile{
- Mode: common.ReleaseModeDev,
- BackendHost: flags.host,
- BackendPort: port,
- DatastorePort: datastorePort,
- PgUser: "bbtest",
- DataDir: dataDir,
- DemoDataDir: fmt.Sprintf("demo/%s", common.ReleaseModeDev),
- BackupRunnerInterval: 10 * time.Second,
- }
-}
-
-// GetTestProfileWithExternalPg will return a profile for testing with external Postgres.
-// We require port as an argument of GetTestProfile so that test can run in parallel in different ports,
-// pgURL for connect to Postgres.
-func GetTestProfileWithExternalPg(dataDir string, port int, pgUser string, pgURL string) server.Profile {
- return server.Profile{
- Mode: common.ReleaseModeDev,
- BackendHost: flags.host,
- BackendPort: port,
- PgUser: pgUser,
- DataDir: dataDir,
- DemoDataDir: fmt.Sprintf("demo/%s", common.ReleaseModeDev),
- BackupRunnerInterval: 10 * time.Second,
- PgURL: pgURL,
- }
-}