diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 6555ec3fa..2dd665994 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -23,4 +23,4 @@ COPY scripts/60-pseudo-code-setup.sh /etc/init/run-before-daemon-start/ RUN mkdir -p /opt/examples COPY _static/ /opt/examples -USER ${SYSTEM_UID} \ No newline at end of file +USER ${SYSTEM_UID} diff --git a/.docker/docker-bake.hcl b/.docker/docker-bake.hcl index 5a992dd6a..89a2fe946 100644 --- a/.docker/docker-bake.hcl +++ b/.docker/docker-bake.hcl @@ -35,4 +35,4 @@ target "aiida-quantumespresso" { args = { "QE_VERSION" = "${QE_VERSION}" } -} \ No newline at end of file +} diff --git a/.docker/scripts/60-pseudo-code-setup.sh b/.docker/scripts/60-pseudo-code-setup.sh index 1e48acd70..6189df238 100755 --- a/.docker/scripts/60-pseudo-code-setup.sh +++ b/.docker/scripts/60-pseudo-code-setup.sh @@ -28,4 +28,4 @@ for code_name in pw ph; do done # Import example structures -verdi data core.structure import ase /opt/examples/Si.cif \ No newline at end of file +verdi data core.structure import ase /opt/examples/Si.cif diff --git a/.docker/tests/conftest.py b/.docker/tests/conftest.py index 266d2be96..738709f06 100644 --- a/.docker/tests/conftest.py +++ b/.docker/tests/conftest.py @@ -16,18 +16,19 @@ def docker_compose(docker_services): # pylint: disable=protected-access return docker_services._docker_compose + def is_container_ready(dodkec_compose): output = dodkec_compose.execute('exec -T aiida verdi status').decode().strip() return 'Connected to RabbitMQ' in output and 'Daemon is running' in output + @pytest.fixture(scope='session', autouse=True) def _docker_service_wait(docker_services): """Container startup wait.""" docker_compose = docker_services._docker_compose - - docker_services.wait_until_responsive( - timeout=120.0, pause=0.1, check=lambda: is_container_ready(docker_compose) - ) + + docker_services.wait_until_responsive(timeout=120.0, pause=0.1, check=lambda: is_container_ready(docker_compose)) + @pytest.fixture def container_user(): @@ -46,16 +47,14 @@ def execute(command, user=None, **kwargs): return execute + @pytest.fixture def qe_version(aiida_exec): - info = json.loads( - aiida_exec( - "mamba list -n base --json --full-name qe" - ).decode() - )[0] + info = json.loads(aiida_exec('mamba list -n base --json --full-name qe').decode())[0] return info['version'] + @pytest.fixture def sssp_version(aiida_exec): - output = aiida_exec("aiida-pseudo list").decode().strip() - return re.search(r"SSSP/(\d+\.\d+)/PBE/efficiency", output).group(1) + output = aiida_exec('aiida-pseudo list').decode().strip() + return re.search(r'SSSP/(\d+\.\d+)/PBE/efficiency', output).group(1) diff --git a/.docker/tests/test_aiida.py b/.docker/tests/test_aiida.py index c4cbc6acd..c0293c049 100644 --- a/.docker/tests/test_aiida.py +++ b/.docker/tests/test_aiida.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # pylint: disable=missing-docstring + def test_verdi_status(aiida_exec, container_user): output = aiida_exec('verdi status', user=container_user).decode().strip() assert 'Connected to RabbitMQ' in output @@ -13,18 +14,20 @@ def test_verdi_status(aiida_exec, container_user): def test_computer_setup_success(aiida_exec, container_user): output = aiida_exec('verdi computer test localhost', user=container_user).decode().strip() - assert "Success" in output - assert "Failed" not in output + assert 'Success' in output + assert 'Failed' not in output + def test_run_real_pw_computation(aiida_exec, container_user, qe_version, sssp_version): import re - output = aiida_exec("verdi data core.structure import ase /opt/examples/Si.cif", user=container_user).decode().strip() - - # Find pk - pk = re.search(r"PK = (\d+)", output).group(1) - - cmd = f"aiida-quantumespresso calculation launch pw -X pw-{qe_version}@localhost -F SSSP/{sssp_version}/PBE/efficiency -S {pk} -k 1 1 1" + output = aiida_exec('verdi data core.structure import ase /opt/examples/Si.cif', + user=container_user).decode().strip() + + # Find pk + pk = re.search(r'PK = (\d+)', output).group(1) + + cmd = f'aiida-quantumespresso calculation launch pw -X pw-{qe_version}@localhost -F SSSP/{sssp_version}/PBE/efficiency -S {pk} -k 1 1 1' output = aiida_exec(cmd, user=container_user).decode().strip() - assert "terminated with state: finished [0]" in output \ No newline at end of file + assert 'terminated with state: finished [0]' in output diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 379fb7fa3..e3151c395 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -7,10 +7,10 @@ on: - "docs/**" - "tests/**" push: - #branches: - # - main - #tags: - # - "v*" + branches: + - main + tags: + - "v*" paths-ignore: - "docs/**" - "tests/**" @@ -43,7 +43,7 @@ jobs: pip install --upgrade pip pip install --upgrade -r requirements.txt - - name: Build image + - name: Build image run: docker buildx bake -f docker-bake.hcl --set *.platform=linux/amd64 --load env: # Full logs for CI build