Compare commits

...

1 Commits

Author SHA256 Message Date
Andrii Nikitin
58f410befc common: add TIMELINE_CACHE_DISABLE env var
This allows bypassing the 5-second timeline cache in `GetTimeline`
by setting the `AUTOGITS_TIMELINE_CACHE_DISABLE` environment
variable.

This is particularly useful in fast-paced integration tests where
stale data could cause failures. The variable is enabled by
default for the `workflow-pr` service in the integration environment.
2026-03-09 20:37:39 +01:00
3 changed files with 7 additions and 3 deletions

View File

@@ -857,12 +857,13 @@ func (gitea *GiteaTransport) ResetTimelineCache(org, repo string, idx int64) {
func (gitea *GiteaTransport) GetTimeline(org, repo string, idx int64) ([]*models.TimelineComment, error) {
page := int64(1)
resCount := 1
disableCache := GetEnvOverrideBool(os.Getenv("AUTOGITS_TIMELINE_CACHE_DISABLE"), false)
prID := fmt.Sprintf("%s/%s!%d", org, repo, idx)
giteaTimelineCacheMutex.RLock()
TimelineCache, IsCached := giteaTimelineCache[prID]
var LastCachedTime strfmt.DateTime
if IsCached {
if IsCached && !disableCache {
l := len(TimelineCache.data)
if l > 0 {
LastCachedTime = TimelineCache.data[0].Updated
@@ -879,6 +880,10 @@ func (gitea *GiteaTransport) GetTimeline(org, repo string, idx int64) ([]*models
giteaTimelineCacheMutex.Lock()
defer giteaTimelineCacheMutex.Unlock()
if disableCache {
TimelineCache = TimelineCacheData{}
}
for resCount > 0 {
opts := issue.NewIssueGetCommentsAndTimelineParams().WithOwner(org).WithRepo(repo).WithIndex(idx).WithPage(&page)
if !LastCachedTime.IsZero() {

View File

@@ -95,6 +95,7 @@ services:
- AMQP_USERNAME=gitea
- AMQP_PASSWORD=gitea
- SSL_CERT_FILE=/usr/share/pki/trust/anchors/gitea-rabbitmq-ca.crt
- AUTOGITS_TIMELINE_CACHE_DISABLE=1
volumes:
- ./gitea-data:/var/lib/gitea:ro,z
- ./workflow-pr/workflow-pr.json:/etc/workflow-pr.json:ro,z

View File

@@ -139,7 +139,6 @@ index 00000000..473a0f4c
@pytest.mark.t005
# @pytest.mark.xfail(reason="TBD troubleshoot")
def test_005_any_maintainer_approval_sufficient(maintainer_env, ownerA_client, ownerBB_client):
"""
Test scenario:
@@ -201,7 +200,6 @@ index 00000000..473a0f4c
@pytest.mark.t006
@pytest.mark.xfail(reason="tbd flacky in ci")
def test_006_maintainer_rejection_removes_other_requests(maintainer_env, ownerA_client, ownerBB_client):
"""
Test scenario: