Compare commits

..

1 Commits

Author SHA256 Message Date
Andrii Nikitin
58f410befc common: add TIMELINE_CACHE_DISABLE env var
All checks were successful
go-generate-check / go-generate-check (pull_request) Successful in 43s
Integration tests / t (pull_request) Successful in 11m25s
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
5 changed files with 17 additions and 153 deletions

View File

@@ -30,167 +30,31 @@ jobs:
git fetch origin ${{ gitea.ref }}
git checkout FETCH_HEAD
working-directory: ./autogits
- name: Prepare binaries (baseline)
- name: Prepare binaries
run: make build
working-directory: ./autogits
- name: Prepare images (baseline)
- name: Prepare images
run: |
make build
podman rmi $(podman images -f "dangling=true" -q)
working-directory: ./autogits/integration
- name: Make sure the pod is down (1)
- name: Make sure the pod is down
run: make down
working-directory: ./autogits/integration
- name: Start images (baseline)
- name: Start images
run: |
make up
make wait_healthy
podman ps
sleep 5
working-directory: ./autogits/integration
- name: Run tests 30 times (baseline)
run: |
pass=0
fail=0
for i in $(seq 1 30); do
echo "Iteration $i/30..."
if podman exec -t tester pytest -v tests/workflow_pr_review_test.py::test_005_any_maintainer_approval_sufficient; then
pass=$((pass + 1))
else
fail=$((fail + 1))
fi
done
echo "Summary (baseline): $pass passes, $fail failures"
- name: Run tests
run: make pytest
working-directory: ./autogits/integration
- name: Make sure the pod is down (2)
run: |
podman ps
make down
working-directory: ./autogits/integration
- name: Cherry-pick 1
run: |
git config user.email "bot@example.com"
git config user.name "Bot"
git cherry-pick 572e33111bd72518f33ec4f7c93a7222282f43999afafac948e1e3da5c3453a0
working-directory: ./autogits
- name: Prepare binaries (after CP1)
run: make build
working-directory: ./autogits
- name: Prepare images (after CP1)
run: |
make build
podman rmi $(podman images -f "dangling=true" -q)
working-directory: ./autogits/integration
- name: Make sure the pod is down (3)
run: make down
working-directory: ./autogits/integration
- name: Start images (after CP1)
run: |
make up
make wait_healthy
podman ps
sleep 5
working-directory: ./autogits/integration
- name: Run tests 30 times (after CP1)
run: |
pass=0
fail=0
for i in $(seq 1 30); do
echo "Iteration $i/30..."
if podman exec -t tester pytest -v tests/workflow_pr_review_test.py::test_005_any_maintainer_approval_sufficient; then
pass=$((pass + 1))
else
fail=$((fail + 1))
fi
done
echo "Summary (after CP1): $pass passes, $fail failures"
working-directory: ./autogits/integration
- name: Make sure the pod is down (4)
run: |
podman ps
make down
working-directory: ./autogits/integration
- name: Cherry-pick 2
run: |
git cherry-pick 8fa732e67518769c9a962e6d12c2e70b38f7bc06e26332fb007ac666fa5e38c1
working-directory: ./autogits
- name: Prepare binaries (after CP2)
run: make build
working-directory: ./autogits
- name: Prepare images (after CP2)
run: |
make build
podman rmi $(podman images -f "dangling=true" -q)
working-directory: ./autogits/integration
- name: Make sure the pod is down (5)
run: make down
working-directory: ./autogits/integration
- name: Start images (after CP2)
run: |
make up
make wait_healthy
podman ps
sleep 5
working-directory: ./autogits/integration
- name: Run tests 30 times (after CP2)
run: |
pass=0
fail=0
for i in $(seq 1 30); do
echo "Iteration $i/30..."
if podman exec -t tester pytest -v tests/workflow_pr_review_test.py::test_005_any_maintainer_approval_sufficient; then
pass=$((pass + 1))
else
fail=$((fail + 1))
fi
done
echo "Summary (after CP2): $pass passes, $fail failures"
working-directory: ./autogits/integration
- name: Make sure the pod is down (6)
run: |
podman ps
make down
working-directory: ./autogits/integration
- name: Discard and Cherry-pick 3
run: |
git reset --hard FETCH_HEAD
git cherry-pick 58f410befce4da40f3ebc27e21ac81a55b6425dd4214e08eb59359d54322a29d
working-directory: ./autogits
- name: Prepare binaries (after CP3)
run: make build
working-directory: ./autogits
- name: Prepare images (after CP3)
run: |
make build
podman rmi $(podman images -f "dangling=true" -q)
working-directory: ./autogits/integration
- name: Make sure the pod is down (7)
run: make down
working-directory: ./autogits/integration
- name: Start images (after CP3)
run: |
make up
make wait_healthy
podman ps
sleep 5
working-directory: ./autogits/integration
- name: Run tests 30 times (after CP3)
run: |
pass=0
fail=0
for i in $(seq 1 30); do
echo "Iteration $i/30..."
if podman exec -t tester pytest -v tests/workflow_pr_review_test.py::test_005_any_maintainer_approval_sufficient; then
pass=$((pass + 1))
else
fail=$((fail + 1))
fi
done
echo "Summary (after CP3): $pass passes, $fail failures"
working-directory: ./autogits/integration
- name: Final cleanup
- name: Make sure the pod is down
if: always()
run: |
podman ps
make down
working-directory: ./autogits/integration

View File

@@ -1,8 +1,4 @@
MODULES := devel-importer utils/hujson utils/maintainer-update gitea-events-rabbitmq-publisher gitea_status_proxy group-review obs-forward-bot obs-staging-bot obs-status-service workflow-direct workflow-pr
.PHONY: build $(MODULES)
build: $(MODULES)
$(MODULES):
go build -C $@ -buildmode=pie
build:
for m in $(MODULES); do go build -C $$m -buildmode=pie || exit 1 ; done

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: