diff --git a/.docker/tests/conftest.py b/.docker/tests/conftest.py index 9eb79ddede..2b6915b559 100644 --- a/.docker/tests/conftest.py +++ b/.docker/tests/conftest.py @@ -3,17 +3,29 @@ import pytest +TARGETS = ('aiida-core-base', 'aiida-core-base-with-services', 'aiida-core-dev') -@pytest.fixture( - scope='session', - params=[ - 'aiida-core-base', - 'aiida-core-with-services', - 'aiida-core-dev', - ], -) -def variant(request): - return request.param + +def target_checker(value): + msg = f"Invalid image target '{value}', must be one of: {TARGETS}" + if value not in TARGETS: + raise pytest.UsageError(msg) + return value + + +def pytest_addoption(parser): + parser.addoption( + '--target', + action='store', + required=True, + help='target (image name) of the docker-compose file to use.', + type=target_checker, + ) + + +@pytest.fixture(scope='session') +def variant(pytestconfig): + return pytestconfig.getoption('target') @pytest.fixture(scope='session') diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 5e124fa625..d6f2085a5c 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -48,5 +48,5 @@ jobs: run: pip install -r requirements.txt --no-deps - name: Run tests - run: pytest -s + run: pytest -s --target ${{ inputs.target }} env: ${{ fromJSON(inputs.images) }}