Skip to content

Commit 97cb675

Browse files
committed
Fix bug hidden on CI and make ci failed if tests failure (go-gitea#29254)
The tests on migration tests failed but CI reports successfully https://github.com/go-gitea/gitea/actions/runs/7364373807/job/20044685969#step:8:141 This PR will fix the bug on migration v283 and also the CI hidden behaviour. The reason is on the Makefile `GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' $(MIGRATE_TEST_PACKAGES)` will return the error exit code. But `for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \ GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \ done` will not work. This also fix go-gitea#29602
1 parent 76b6754 commit 97cb675

File tree

16 files changed

+87
-28
lines changed

16 files changed

+87
-28
lines changed

.github/workflows/pull-db-tests.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ jobs:
4949
- run: make backend
5050
env:
5151
TAGS: bindata
52-
- run: make test-pgsql-migration test-pgsql
52+
- name: run migration tests
53+
run: make test-pgsql-migration
54+
- name: run tests
55+
run: make test-pgsql
5356
timeout-minutes: 50
5457
env:
5558
TAGS: bindata gogit
@@ -72,7 +75,10 @@ jobs:
7275
- run: make backend
7376
env:
7477
TAGS: bindata gogit sqlite sqlite_unlock_notify
75-
- run: make test-sqlite-migration test-sqlite
78+
- name: run migration tests
79+
run: make test-sqlite-migration
80+
- name: run tests
81+
run: make test-sqlite
7682
timeout-minutes: 50
7783
env:
7884
TAGS: bindata gogit sqlite sqlite_unlock_notify
@@ -189,8 +195,10 @@ jobs:
189195
- run: make backend
190196
env:
191197
TAGS: bindata
198+
- name: run migration tests
199+
run: make test-mysql-migration
192200
- name: run tests
193-
run: make test-mysql-migration integration-test-coverage
201+
run: make integration-test-coverage
194202
env:
195203
TAGS: bindata
196204
RACE_ENABLED: true
@@ -252,7 +260,9 @@ jobs:
252260
- run: make backend
253261
env:
254262
TAGS: bindata
255-
- run: make test-mssql-migration test-mssql
263+
- run: make test-mssql-migration
264+
- name: run tests
265+
run: make test-mssql
256266
timeout-minutes: 50
257267
env:
258268
TAGS: bindata

Makefile

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
111111

112112
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
113113
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
114+
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
114115

115116
FOMANTIC_WORK_DIR := web_src/fomantic
116117

@@ -748,9 +749,7 @@ migrations.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
748749

749750
.PHONY: migrations.individual.mysql.test
750751
migrations.individual.mysql.test: $(GO_SOURCES)
751-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
752-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
753-
done
752+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
754753

755754
.PHONY: migrations.individual.mysql8.test
756755
migrations.individual.mysql8.test: $(GO_SOURCES)
@@ -764,30 +763,23 @@ migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
764763

765764
.PHONY: migrations.individual.pgsql.test
766765
migrations.individual.pgsql.test: $(GO_SOURCES)
767-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
768-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
769-
done
766+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
770767

771768
.PHONY: migrations.individual.pgsql.test\#%
772769
migrations.individual.pgsql.test\#%: $(GO_SOURCES) generate-ini-pgsql
773770
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
774771

775-
776772
.PHONY: migrations.individual.mssql.test
777773
migrations.individual.mssql.test: $(GO_SOURCES) generate-ini-mssql
778-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
779-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg -test.failfast; \
780-
done
774+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
781775

782776
.PHONY: migrations.individual.mssql.test\#%
783777
migrations.individual.mssql.test\#%: $(GO_SOURCES) generate-ini-mssql
784778
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
785779

786780
.PHONY: migrations.individual.sqlite.test
787781
migrations.individual.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
788-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
789-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
790-
done
782+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
791783

792784
.PHONY: migrations.individual.sqlite.test\#%
793785
migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite

models/migrations/base/db_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ func Test_DropTableColumns(t *testing.T) {
3636
"updated_unix",
3737
}
3838

39+
x.SetMapper(names.GonicMapper{})
40+
3941
for i := range columns {
40-
x.SetMapper(names.GonicMapper{})
4142
if err := x.Sync(new(DropTest)); err != nil {
4243
t.Errorf("unable to create DropTest table: %v", err)
4344
return
4445
}
46+
4547
sess := x.NewSession()
4648
if err := sess.Begin(); err != nil {
4749
sess.Close()
@@ -64,7 +66,6 @@ func Test_DropTableColumns(t *testing.T) {
6466
return
6567
}
6668
for j := range columns[i+1:] {
67-
x.SetMapper(names.GonicMapper{})
6869
if err := x.Sync(new(DropTest)); err != nil {
6970
t.Errorf("unable to create DropTest table: %v", err)
7071
return
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-
2+
id: 1
3+
repo_id: 1
4+
index: 1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-
2+
id: 1
3+
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11
4+
issue_id: 1
5+
release_id: 0
6+
7+
-
8+
id: 2
9+
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12
10+
issue_id: 0
11+
release_id: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
repo_id: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
repo_id: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
commit_sha: 19fe5caf872476db265596eaac1dc35ad1c6422d
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
context_hash: 19fe5caf872476db265596eaac1dc35ad1c6422d
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-
2+
id: 1
3+
commit_sha: 19fe5caf872476db265596eaac1dc35ad1c6422d
4+
merge_base: 19fe5caf872476db265596eaac1dc35ad1c6422d
5+
merged_commit_id: 19fe5caf872476db265596eaac1dc35ad1c6422d

0 commit comments

Comments
 (0)