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

Fix bug hidden on CI and make ci failed if tests failure #29254

Merged
merged 35 commits into from
Mar 7, 2024

Conversation

lunny
Copy link
Member

@lunny lunny commented Feb 19, 2024

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 #29602

@lunny lunny added type/bug skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. labels Feb 19, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 19, 2024
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 19, 2024
@lunny lunny requested a review from wxiaoguang February 19, 2024 10:13
@silverwind
Copy link
Member

Interesting, does make foo bar trigger the bar target and succeed even when foo fails? I would have expected it to exit on first failed target.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Feb 19, 2024

Interesting +1. Is the root problem really fixed?

make failure success should NOT succeed:

bash-3.2$ cat Makefile
a:
	false

b:
	true


bash-3.2$ make a
false
make: *** [a] Error 1
bash-3.2$ echo $?
2


bash-3.2$ make b
true
bash-3.2$ echo $?
0


bash-3.2$ make a b
false
make: *** [a] Error 1
bash-3.2$ echo $?
2

@lunny
Copy link
Member Author

lunny commented Feb 19, 2024

Interesting, does make foo bar trigger the bar target and succeed even when foo fails? I would have expected it to exit on first failed target.

I guess that but unfortunately, it's not right. It must be affected by others.

@lunny lunny marked this pull request as draft March 4, 2024 08:05
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 5, 2024
@lunny lunny marked this pull request as ready for review March 5, 2024 15:36
@KN4CK3R
Copy link
Member

KN4CK3R commented Mar 7, 2024

@lunny Could you fix the v96 too I mentioned at Discord?

diff --git a/models/migrations/v1_10/v96.go b/models/migrations/v1_10/v96.go
index 34c8240031..2847be57b1 100644
--- a/models/migrations/v1_10/v96.go
+++ b/models/migrations/v1_10/v96.go
@@ -38,7 +38,7 @@ func DeleteOrphanedAttachments(x *xorm.Engine) error {
 			return err
 		}
 		if len(attachments) == 0 {
-			return nil
+			break
 		}
 
 		ids := make([]int64, 0, limit)
@@ -58,7 +58,9 @@ func DeleteOrphanedAttachments(x *xorm.Engine) error {
 			}
 		}
 		if len(attachments) < limit {
-			return nil
+			break
 		}
 	}
+
+	return sess.Commit()
 }

@lunny
Copy link
Member Author

lunny commented Mar 7, 2024

@lunny Could you fix the v96 too I mentioned at Discord?

diff --git a/models/migrations/v1_10/v96.go b/models/migrations/v1_10/v96.go
index 34c8240031..2847be57b1 100644
--- a/models/migrations/v1_10/v96.go
+++ b/models/migrations/v1_10/v96.go
@@ -38,7 +38,7 @@ func DeleteOrphanedAttachments(x *xorm.Engine) error {
 			return err
 		}
 		if len(attachments) == 0 {
-			return nil
+			break
 		}
 
 		ids := make([]int64, 0, limit)
@@ -58,7 +58,9 @@ func DeleteOrphanedAttachments(x *xorm.Engine) error {
 			}
 		}
 		if len(attachments) < limit {
-			return nil
+			break
 		}
 	}
+
+	return sess.Commit()
 }

Looks like there is no sess.Begin, why we need to add sess.Commit()?

@KN4CK3R
Copy link
Member

KN4CK3R commented Mar 7, 2024

Line 24?

sess := x.NewSession()
defer sess.Close()

Edit: Nvm, yes, no transaction here.

@lunny
Copy link
Member Author

lunny commented Mar 7, 2024

Finally fixed all migration tests. It's ready to re-review now.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 7, 2024
@6543 6543 merged commit 4527748 into go-gitea:main Mar 7, 2024
26 checks passed
@GiteaBot GiteaBot added this to the 1.23.0 milestone Mar 7, 2024
@GiteaBot
Copy link
Collaborator

GiteaBot commented Mar 7, 2024

I was unable to create a backport for 1.21. @lunny, please send one manually. 🍵

go run ./contrib/backport 29254
...  // fix git conflicts if any
go run ./contrib/backport --continue

@GiteaBot GiteaBot added the backport/manual No power to the bots! Create your backport yourself! label Mar 7, 2024
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 8, 2024
* giteaofficial/main:
  Store webhook event in database (go-gitea#29145)
  Fix bug hidden on CI and make ci failed if tests failure (go-gitea#29254)
@lunny lunny modified the milestones: 1.23.0, 1.22.0 Mar 8, 2024
@lunny lunny deleted the lunny/fix_tests branch March 8, 2024 08:22
lunny added a commit to lunny/gitea that referenced this pull request Mar 8, 2024
)

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
@lunny lunny added the backport/done All backports for this PR have been created label Mar 8, 2024
lunny added a commit that referenced this pull request Mar 9, 2024
…9662)

Backport #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 migrations 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.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! backport/v1.21 This PR should be backported to Gitea 1.21 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/internal modifies/migrations size/L Denotes a PR that changes 100-499 lines, ignoring generated files. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/bug type/testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Badges API test failure
7 participants