Skip to content

Commit b833510

Browse files
committed
CI test for containerized code
test docker run
1 parent c6ee523 commit b833510

8 files changed

Lines changed: 47 additions & 3 deletions

File tree

.github/config/add-docker.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
label: add-docker
3+
description: add docker
4+
default_calc_job_plugin: core.arithmetic.add
5+
on_computer: true
6+
computer: localhost
7+
filepath_executable: /bin/bash
8+
image: ubuntu
9+
engine_command: docker run -v $PWD:/workdir:rw -w /workdir {image} sh -c
10+
escape_exec_line: true
11+
prepend_text: ' '
12+
append_text: ' '

.github/config/localhost.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ transport: core.local
66
scheduler: core.direct
77
shebang: '#!/usr/bin/env bash'
88
work_dir: PLACEHOLDER_WORK_DIR
9+
use_double_quotes: true
910
mpirun_command: ' '
1011
mpiprocs_per_machine: 1
1112
prepend_text: ' '
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
from aiida import orm
3+
from aiida.engine import run_get_node
4+
from aiida.plugins import CalculationFactory
5+
6+
ArithmeticAddCalculation = CalculationFactory('core.arithmetic.add')
7+
8+
inputs = {
9+
'code': orm.load_code('add-docker@localhost'),
10+
'x': orm.Int(4),
11+
'y': orm.Int(6),
12+
'metadata': {
13+
'options': {
14+
'resources': {
15+
'num_machines': 1,
16+
'num_mpiprocs_per_machine': 1
17+
}
18+
}
19+
}
20+
}
21+
22+
res, node = run_get_node(ArithmeticAddCalculation, **inputs)
23+
assert 'sum' in res
24+
assert 'remote_folder' in res
25+
assert 'retrieved' in res
26+
assert res['sum'].value == 10

.github/workflows/nightly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: nightly
22

33
on:
4+
workflow_dispatch: # To manually trigger nightly
45
schedule:
56
- cron: '0 0 * * *' # Run every day at midnight
67
pull_request:

.github/workflows/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ verdi computer configure core.local localhost --config "${CONFIG}/localhost-conf
2323
verdi computer test localhost
2424
verdi code create core.code.installed --non-interactive --config "${CONFIG}/doubler.yaml"
2525
verdi code create core.code.installed --non-interactive --config "${CONFIG}/add.yaml"
26+
verdi code create core.code.installed.containerized --non-interactive --config "${CONFIG}/add-docker.yaml"
2627

2728
# set up slurm-ssh computer
2829
verdi computer setup --non-interactive --config "${CONFIG}/slurm-ssh.yaml"

.github/workflows/tests_nightly.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export PYTHONPATH="${PYTHONPATH}:${SYSTEM_TESTS}:${MODULE_POLISH}"
99

1010
verdi daemon start 4
1111
verdi -p test_aiida run ${SYSTEM_TESTS}/test_daemon.py
12+
docker version | echo
13+
verdi -p test_aiida run ${SYSTEM_TESTS}/test_containerized_code.py
1214
bash ${SYSTEM_TESTS}/test_polish_workchains.sh
1315
verdi daemon stop
1416

tests/cmdline/commands/test_code.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# pylint: disable=unused-argument,redefined-outer-name
1111
"""Tests for the 'verdi code' command."""
1212
import io
13+
from ipaddress import ip_address
1314
import os
1415
import pathlib
1516
import tempfile
@@ -424,7 +425,7 @@ def command_options(request, aiida_localhost, tmp_path):
424425
if 'containerized' in request.param:
425426
engine_command = 'docker run -it -v $PWD:/workdir:rw -w /workdir {image} sh -c'
426427
image = 'ubuntu'
427-
options.extend(['--engine-command', engine_command, '--image', image, '--escape-exec-line', True])
428+
options.extend(['--engine-command', engine_command, '--image', image, '--escape-exec-line'])
428429

429430
return options, request.param
430431

tests/engine/processes/calcjobs/test_calc_job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_containerized_installed_code(file_regression, aiida_localhost):
259259
_, node = launch.run_get_node(DummyCalcJob, **inputs)
260260
folder_name = node.dry_run_info['folder']
261261
submit_script_filename = node.get_option('submit_script_filename')
262-
content = (pathlib.Path(folder_name) / submit_script_filename).read_bytes()
262+
content = (pathlib.Path(folder_name) / submit_script_filename).read_bytes().decode('utf-8')
263263

264264
file_regression.check(content, extension='.sh')
265265

@@ -300,7 +300,7 @@ def test_containerized_portable_code(file_regression, tmp_path, aiida_localhost)
300300
assert filename in uploaded_files
301301

302302
submit_script_filename = node.get_option('submit_script_filename')
303-
content = (pathlib.Path(folder_name) / submit_script_filename).read_bytes()
303+
content = (pathlib.Path(folder_name) / submit_script_filename).read_bytes().decode('utf-8')
304304

305305
file_regression.check(content, extension='.sh')
306306

0 commit comments

Comments
 (0)