:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add 4 missing tables to the Gitea source (#118313)
Tom Owers2e06b145c66c
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex 92c43e87a63e..d680c14071af 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -5227,10 +5227,10 @@ Diffed against: <https://demo.gitea.com/swagger.v1.json>- [x] `/repos/{owner}/{repo}/pulls/{index}/reviews` — PR review verdicts and reviewers, required for any review-throughput analysis (high)- [x] `/repos/{owner}/{repo}/actions/runs` — Gitea Actions CI runs — no CI data is synced at all today (high)- [x] `/repos/{owner}/{repo}/issues/{index}/timeline` — state and assignment transition history behind issue cycle time (high)-- [ ] `/repos/{owner}/{repo}/actions/jobs` — job-level CI granularity for duration and failure attribution (medium)-- [ ] `/repos/{owner}/{repo}/branches` — branch inventory with protection and last-commit metadata (medium)-- [ ] `/repos/{owner}/{repo}/tags` — git tags — releases are synced but the underlying tags are not (medium)-- [ ] `/repos/{owner}/{repo}/collaborators` — lookup resolving the user IDs appearing as authors, assignees, and reviewers (medium)+- [x] `/repos/{owner}/{repo}/actions/jobs` — job-level CI granularity for duration and failure attribution (medium)+- [x] `/repos/{owner}/{repo}/branches` — branch inventory with protection and last-commit metadata (medium)+- [x] `/repos/{owner}/{repo}/tags` — git tags — releases are synced but the underlying tags are not (medium)+- [x] `/repos/{owner}/{repo}/collaborators` — lookup resolving the user IDs appearing as authors, assignees, and reviewers (medium)- [ ] `/repos/{owner}/{repo}/times` — tracked time entries per issue, a first-class analytical object in Gitea (medium)- [ ] `/repos/{owner}/{repo}/pulls/{index}/files` — per-file diff stats for PR size and code churn (medium)- [ ] `/repos/{owner}/{repo}/commits/{ref}/statuses` — commit status checks linking CI outcomes to commits (low)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/canonical_descriptions.pyindex b87e5af518b6..61e8f825200c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/canonical_descriptions.py@@ -197,4 +197,66 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"html_url": "Web URL of the run on the Gitea instance.",},},+ "workflow_jobs": {+ "description": "Jobs of every Gitea Actions workflow run in the repository. Needs Gitea 1.25 or later.",+ "docs_url": "https://docs.gitea.com/api/1.25/#tag/repository/operation/listWorkflowJobs",+ "columns": {+ "id": "Unique identifier of the job.",+ "run_id": "Identifier of the workflow run the job belongs to.",+ "run_attempt": "Attempt number of the job, incremented on each re-run.",+ "name": "Name of the job.",+ "labels": "Runner labels the job asked for (`runs-on`).",+ "status": "Job status: queued, waiting, in_progress, or completed.",+ "conclusion": "Job result once completed: success, failure, cancelled, or skipped.",+ "head_branch": "Branch the workflow run was triggered on.",+ "head_sha": "SHA of the commit the workflow run was triggered on.",+ "runner_id": "Identifier of the runner that ran the job.",+ "runner_name": "Name of the runner that ran the job.",+ "steps": "Steps of the job, with the status and timing of each.",+ "created_at": "When the job was created.",+ "started_at": "When the current attempt of the job started.",+ "completed_at": "When the current attempt of the job completed.",+ "html_url": "Web URL of the job on the Gitea instance.",+ },+ },+ "branches": {+ "description": "Branches of the repository, with protection settings and the last commit.",+ "docs_url": "https://docs.gitea.com/api/1.25/#tag/repository/operation/repoListBranches",+ "columns": {+ "name": "Name of the branch.",+ "commit": "Last commit on the branch.",+ "protected": "Whether the branch is protected.",+ "required_approvals": "Number of approvals a pull request into the branch needs.",+ "enable_status_check": "Whether status checks must pass before a merge into the branch.",+ "status_check_contexts": "Status check contexts that must pass before a merge into the branch.",+ "effective_branch_protection_name": "Name of the branch protection rule that applies to the branch.",+ "user_can_push": "Whether the token's user can push to the branch.",+ "user_can_merge": "Whether the token's user can merge into the branch.",+ },+ },+ "tags": {+ "description": "Git tags in the repository.",+ "docs_url": "https://docs.gitea.com/api/1.25/#tag/repository/operation/repoListTags",+ "columns": {+ "name": "Name of the tag.",+ "id": "SHA of the tag object.",+ "message": "Message of the tag.",+ "commit": "Commit the tag points to, with its SHA and creation time.",+ "zipball_url": "URL to download the tagged source as a zip archive.",+ "tarball_url": "URL to download the tagged source as a tar.gz archive.",+ },+ },+ "collaborators": {+ "description": "Users with direct collaborator access to the repository.",+ "docs_url": "https://docs.gitea.com/api/1.25/#tag/repository/operation/repoListCollaborators",+ "columns": {+ "id": "Unique identifier of the user on the Gitea instance.",+ "login": "Username of the user.",+ "full_name": "Full name of the user.",+ "email": "Email address of the user, when visible to the token.",+ "avatar_url": "URL of the user's avatar.",+ "html_url": "Web URL of the user's profile on the Gitea instance.",+ "created": "When the user account was created.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/settings.pyindex ced94a7bb6ba..25ced33e2908 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/settings.py@@ -194,6 +194,43 @@ GITEA_ENDPOINTS: dict[str, GiteaEndpointConfig] = {"Syncing workflow runs needs Gitea 1.25 or later with Actions enabled on the repository."),),+ "workflow_jobs": GiteaEndpointConfig(+ name="workflow_jobs",+ # Gitea Actions jobs across all runs. No time filter: full refresh only. A re-run+ # resets the job in place, so `created_at` stays stable while `started_at` moves.+ path="/repos/{repository}/actions/jobs",+ pagination="total_count",+ data_selector="jobs",+ partition_key="created_at",+ incremental_fields=[],+ not_found_error=(+ "Gitea Actions jobs are unavailable for this repository. "+ "Syncing workflow jobs needs Gitea 1.25 or later with Actions enabled on the repository."+ ),+ ),+ "branches": GiteaEndpointConfig(+ name="branches",+ # Branch names are unique within the single synced repository. No stable timestamp.+ path="/repos/{repository}/branches",+ primary_key="name",+ incremental_fields=[],+ ),+ "tags": GiteaEndpointConfig(+ name="tags",+ # No Link header, only X-Total-Count. Tags arrive newest first by creation date.+ path="/repos/{repository}/tags",+ primary_key="name",+ pagination="total_count",+ sort_mode="desc",+ incremental_fields=[],+ ),+ "collaborators": GiteaEndpointConfig(+ name="collaborators",+ # No Link header, only X-Total-Count. Rows are user objects keyed by user id.+ path="/repos/{repository}/collaborators",+ pagination="total_count",+ incremental_fields=[],+ ),}ENDPOINTS = tuple(GITEA_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/source.pyindex 0e460db14fce..0b9cb48e7dc7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/source.py@@ -169,6 +169,7 @@ If automatic creation failed, your token needs admin access to the repository"404 Client Error": "Repository not found. Please verify the instance URL, repository name, and token access.","Invalid Gitea instance URL": "The Gitea instance URL is invalid. Please enter the instance's canonical https URL.","Gitea Actions runs are unavailable": "Gitea Actions runs are unavailable for this repository. Upgrade the instance to Gitea 1.25 or later and enable Actions on the repository, or turn off the workflow_runs table.",+ "Gitea Actions jobs are unavailable": "Gitea Actions jobs are unavailable for this repository. Upgrade the instance to Gitea 1.25 or later and enable Actions on the repository, or turn off the workflow_jobs table.",}def get_schemas(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/tests/test_gitea.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/tests/test_gitea.pyindex 9fe462f355f3..ac1aefdb65cc 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/tests/test_gitea.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/tests/test_gitea.py@@ -255,6 +255,14 @@ class TestGetRows:{"total_count": 3, "workflow_runs": [{"id": 1}]},{},),+ (+ "workflow_jobs",+ {"total_count": 3, "jobs": [{"id": 1}, {"id": 2}]},+ {"total_count": 3, "jobs": [{"id": 3}]},+ {},+ ),+ ("tags", [{"id": 3}, {"id": 2}], [{"id": 1}], {"X-Total-Count": "3"}),+ ("collaborators", [{"id": 1}, {"id": 2}], [{"id": 3}], {"X-Total-Count": "3"}),],)@mock.patch(f"{_MODULE}.PAGE_SIZE", 2)@@ -274,11 +282,18 @@ class TestGetRows:assert "page=2" in urls[1]assert result.saved_states == [GiteaResumeConfig(next_url=urls[1])]- def test_workflow_runs_not_found_raises_actions_unavailable(self) -> None:- result = _driver().run("workflow_runs", [ScriptedResponse(status=404, json={"message": "Not Found"})])+ @pytest.mark.parametrize(+ "endpoint, expected_error",+ [+ ("workflow_runs", "Gitea Actions runs are unavailable"),+ ("workflow_jobs", "Gitea Actions jobs are unavailable"),+ ],+ )+ def test_actions_endpoint_not_found_raises_actions_unavailable(self, endpoint: str, expected_error: str) -> None:+ result = _driver().run(endpoint, [ScriptedResponse(status=404, json={"message": "Not Found"})])assert isinstance(result.raised, ValueError)- assert "Gitea Actions runs are unavailable" in str(result.raised)+ assert expected_error in str(result.raised)class TestFanOut: