Skip to content

Add local Wikibase CI and configurable tests#971

Open
LeMyst wants to merge 6 commits into
masterfrom
docker-test
Open

Add local Wikibase CI and configurable tests#971
LeMyst wants to merge 6 commits into
masterfrom
docker-test

Conversation

@LeMyst
Copy link
Copy Markdown
Owner

@LeMyst LeMyst commented May 6, 2026

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.

Copilot AI review requested due to automatic review settings May 6, 2026 22:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread .github/workflows/python-pytest.yaml
Comment thread .github/workflows/python-pytest.yaml
Comment thread .github/workflows/python-pytest.yaml
Comment thread .github/wikibase-ci/wait_for_api.py Outdated
Comment thread test/test_entity_item.py
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 thread test/test_entity_item.py
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']

LeMyst added 2 commits May 9, 2026 11:52
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.
LeMyst added 4 commits May 9, 2026 11:59
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants