Add local Wikibase CI and configurable tests#971
Open
LeMyst wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an endpoint-configurable test setup and introduces a GitHub Actions lane for running a small integration suite against a locally started Wikibase, instead of relying on public Wikidata/Commons.
Changes:
- Make Wikibase endpoints configurable via environment variables (library + tests).
- Add pytest markers + a conftest gate to skip external-network/Wikibase-integration tests by default.
- Add a workflow_dispatch-only GitHub Actions job that starts a local Wikibase (docker-compose), waits for the API, seeds deterministic entities, and runs a subset of integration tests.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
wikibaseintegrator/wbi_config.py |
Read endpoint URLs from WBI_* env vars with Wikidata defaults. |
test/wikibase_test_config.py |
Centralizes test entity IDs and provides env-driven endpoint override for tests. |
test/conftest.py |
Defines pytest markers + default skip behavior (gated by WBI_RUN_EXTERNAL_NETWORK_TESTS). |
pyproject.toml |
Registers new pytest markers in project config. |
test/test_wbi_login.py |
Tags login tests as external/Wikibase integration tests. |
test/test_wbi_helpers.py |
Uses centralized IDs, configures endpoints, and adds requires_sparql marking. |
test/test_wbi_fastrun.py |
Configures endpoints and marks as external/Wikibase integration + SPARQL-required. |
test/test_wbi_core.py |
Configures endpoints and marks as external/Wikibase integration. |
test/test_all.py |
Configures endpoints and marks as external/Wikibase integration. |
test/test_entity_item.py |
Uses centralized item ID and endpoint-derived base URL in assertions. |
test/test_entity_property.py |
Uses centralized property ID and endpoint-derived base URL in assertions. |
test/test_entity_lexeme.py |
Uses centralized lexeme ID and endpoint-derived base URL in assertions. |
test/test_entity_mediainfo.py |
Marks MediaInfo tests as external/Wikibase integration + Commons-required; uses centralized MediaInfo ID. |
.github/workflows/python-pytest.yaml |
Splits unit tests vs workflow-dispatch local Wikibase integration lane. |
.github/wikibase-ci/docker-compose.yml |
Defines local Wikibase service for CI. |
.github/wikibase-ci/wait_for_api.py |
Polling script to wait for MediaWiki API readiness. |
.github/wikibase-ci/seed_local_wikibase.py |
Seeds deterministic items/properties/lexeme for local integration tests. |
.github/wikibase-ci/README.md |
Documentation for the local Wikibase CI setup. |
Comment on lines
49
to
51
| def test_get_json(self): | ||
| assert wbi.item.get('Q582').get_json()['labels']['fr']['value'] == 'Villeurbanne' | ||
| assert wbi.item.get(ITEM_CITY_ID).get_json()['labels']['fr']['value'] | ||
|
|
Comment on lines
+120
to
+121
| item = wbi.item.get(ITEM_CITY_ID, props=['labels']) | ||
| assert item.labels.get('fr').value |
Comment on lines
41
to
43
| def test_get_json(self): | ||
| assert wbi.lexeme.get('L5').get_json()['forms'][0]['representations']['es']['value'] == 'pinos' | ||
| assert wbi.lexeme.get(LEXEME_MAIN_ID).get_json()['forms'][0]['representations']['es']['value'] | ||
|
|
Comment on lines
40
to
42
| def test_get_json(self): | ||
| assert wbi.property.get('P50', mediawiki_api_url='https://commons.wikimedia.org/w/api.php').get_json()['labels']['fr']['value'] == 'auteur ou autrice' | ||
| assert wbi.property.get(PROPERTY_AUTHOR_ID).get_json()['labels']['fr']['value'] | ||
|
|
Introduce a local Wikibase integration test lane and make tests endpoint-configurable. Adds .github/wikibase-ci (docker-compose, API wait and seed scripts), updates GitHub Actions to include a unit job and a workflow_dispatch "wikibase-local" job that starts a local Wikibase, seeds deterministic entities and runs a subset of integration tests. Add pytest markers and a conftest to skip external-network/wikibase integration tests by default, and centralize test IDs/endpoints in test/wikibase_test_config.py. Update pyproject.toml with new markers and modify many tests to use the centralized IDs. Make wbi_config read endpoint-related env vars so tests can target either Wikidata or a local Wikibase instance. # Conflicts: # .github/workflows/python-pytest.yaml
Make API readiness check more robust by catching ValueError from response.json() and returning False when the API briefly returns non-JSON (e.g. HTML) while starting. Update CI: add a local httpbin service (kennethreitz/httpbin) exposed on port 8080 for tests, and set HTTPSTATUS_SERVICE env for the pytest step so tests can use the local HTTP endpoint. Also remove the restrictive workflow_dispatch condition from the wikibase-local job so it runs more broadly.
Move imports from test.wikibase_test_config up with other standard imports across multiple test files (conftest.py, test_all.py, test_entity_*.py, test_wbi_*.py) to make import ordering consistent and satisfy linters. No functional changes to tests.
Remove the explicit ports mapping (80:80) for the kennethreitz/httpbin service in the python-pytest GitHub Actions workflow. This avoids exposing a host port from the service container and prevents potential port conflicts when running the workflow in a containerized runner.
Delete the explicit `python -m pip install poetry` step from the python-pytest GitHub Actions workflow. The step was for cache discovery but is unnecessary, so removing it simplifies the workflow while leaving the Python setup step intact.
Add steps to bootstrap python3 (apt-get python3 and python3-pip) and to install Poetry for cache discovery in the python-pytest workflow. These steps are inserted in both relevant jobs before the setup-python action to ensure Python and Poetry are available in container runners.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce a local Wikibase integration test lane and make tests endpoint-configurable. Adds .github/wikibase-ci (docker-compose, API wait and seed scripts), updates GitHub Actions to include a unit job and a workflow_dispatch "wikibase-local" job that starts a local Wikibase, seeds deterministic entities and runs a subset of integration tests. Add pytest markers and a conftest to skip external-network/wikibase integration tests by default, and centralize test IDs/endpoints in test/wikibase_test_config.py. Update pyproject.toml with new markers and modify many tests to use the centralized IDs. Make wbi_config read endpoint-related env vars so tests can target either Wikidata or a local Wikibase instance.