DEVX-118: fix: add delay before wiki verification to avoid race condition
Gitea needs a few seconds to process pushed wiki commits before a re-clone will see them. Add a 5s sleep after a successful push before verification re-clones the wiki. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
32b9a53151
commit
c97b249935
@@ -31,6 +31,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import subprocess # nosec B404
|
import subprocess # nosec B404
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
@@ -309,6 +310,9 @@ def main(dry_run: bool, repo: str | None, verify: bool) -> None:
|
|||||||
|
|
||||||
# Verification
|
# Verification
|
||||||
if verify and not dry_run:
|
if verify and not dry_run:
|
||||||
|
if pushed:
|
||||||
|
click.echo(_("Waiting 5s for Gitea to process pushed commits..."))
|
||||||
|
time.sleep(5)
|
||||||
click.echo(_("\nVerifying wiki pages..."))
|
click.echo(_("\nVerifying wiki pages..."))
|
||||||
# Re-clone to verify
|
# Re-clone to verify
|
||||||
verify_dir = Path(tmpdir) / "verify"
|
verify_dir = Path(tmpdir) / "verify"
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ class TestMain:
|
|||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
mock_init.assert_called_once()
|
mock_init.assert_called_once()
|
||||||
|
|
||||||
|
@patch("devx.ci.sync_wiki.time.sleep")
|
||||||
@patch("devx.ci.sync_wiki.clone_wiki")
|
@patch("devx.ci.sync_wiki.clone_wiki")
|
||||||
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
||||||
@patch("devx.ci.sync_wiki.sync_files", return_value=(1, 0))
|
@patch("devx.ci.sync_wiki.sync_files", return_value=(1, 0))
|
||||||
@@ -331,6 +332,7 @@ class TestMain:
|
|||||||
mock_sync: MagicMock,
|
mock_sync: MagicMock,
|
||||||
mock_push: MagicMock,
|
mock_push: MagicMock,
|
||||||
mock_clone: MagicMock,
|
mock_clone: MagicMock,
|
||||||
|
mock_sleep: MagicMock,
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
) -> None:
|
) -> None:
|
||||||
@@ -380,6 +382,7 @@ class TestMain:
|
|||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert "No push needed" in result.output
|
assert "No push needed" in result.output
|
||||||
|
|
||||||
|
@patch("devx.ci.sync_wiki.time.sleep")
|
||||||
@patch("devx.ci.sync_wiki.clone_wiki", side_effect=[True, False])
|
@patch("devx.ci.sync_wiki.clone_wiki", side_effect=[True, False])
|
||||||
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
||||||
@patch("devx.ci.sync_wiki.sync_files", return_value=(1, 0))
|
@patch("devx.ci.sync_wiki.sync_files", return_value=(1, 0))
|
||||||
@@ -388,6 +391,7 @@ class TestMain:
|
|||||||
mock_sync: MagicMock,
|
mock_sync: MagicMock,
|
||||||
mock_push: MagicMock,
|
mock_push: MagicMock,
|
||||||
mock_clone: MagicMock,
|
mock_clone: MagicMock,
|
||||||
|
mock_sleep: MagicMock,
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
) -> None:
|
) -> None:
|
||||||
@@ -404,6 +408,7 @@ class TestMain:
|
|||||||
assert result.exit_code != 0
|
assert result.exit_code != 0
|
||||||
assert "could not clone" in result.output
|
assert "could not clone" in result.output
|
||||||
|
|
||||||
|
@patch("devx.ci.sync_wiki.time.sleep")
|
||||||
@patch("devx.ci.sync_wiki.clone_wiki")
|
@patch("devx.ci.sync_wiki.clone_wiki")
|
||||||
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
||||||
@patch("devx.ci.sync_wiki.sync_files", return_value=(1, 0))
|
@patch("devx.ci.sync_wiki.sync_files", return_value=(1, 0))
|
||||||
@@ -412,6 +417,7 @@ class TestMain:
|
|||||||
mock_sync: MagicMock,
|
mock_sync: MagicMock,
|
||||||
mock_push: MagicMock,
|
mock_push: MagicMock,
|
||||||
mock_clone: MagicMock,
|
mock_clone: MagicMock,
|
||||||
|
mock_sleep: MagicMock,
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user