-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix doit tests #458
Merged
Merged
Fix doit tests #458
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
850a2c3
WIP: Fix doit tests
danielhollas 780620c
Fixes
danielhollas 288ed69
Fixes for podman
danielhollas 2a29e72
up/down working, custom docker-compose command
danielhollas d9f8cfc
Use doit in GHA
danielhollas 0e49766
Update README
danielhollas 7c7d114
Revert "Use doit in GHA"
danielhollas f955ac1
registry must include slash
danielhollas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,23 +15,25 @@ | |
|
||
_ARCH_MAPPING = { | ||
"x86_64": "amd64", | ||
"amd64": "amd64", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what podman returns on Fedora 39 at least. |
||
"aarch64": "arm64", | ||
} | ||
|
||
ARCH = _ARCH_MAPPING.get(_DOCKER_ARCHITECTURE) | ||
|
||
if ARCH is None: | ||
raise RuntimeError( | ||
f"Unsupported architecture {ARCH} on platform {platform.system()}." | ||
print( | ||
f"Unsupported architecture {_DOCKER_ARCHITECTURE} on platform {platform.system()}." | ||
) | ||
exit(1) | ||
|
||
_REGISTRY_PARAM = { | ||
"name": "registry", | ||
"short": "r", | ||
"long": "registry", | ||
"type": str, | ||
"default": "", | ||
"help": "Specify the docker image registry.", | ||
"help": "Specify the docker image registry (including the trailing slash).", | ||
} | ||
|
||
_ORGANIZATION_PARAM = { | ||
|
@@ -63,14 +65,45 @@ | |
} | ||
|
||
_TARGET_PARAM = { | ||
"name": "targets", | ||
"long": "targets", | ||
"name": "target", | ||
"long": "target", | ||
"short": "t", | ||
"type": list, | ||
"default": [], | ||
"type": str, | ||
"choices": ( | ||
("base", ""), | ||
("base-with-services", ""), | ||
("lab", ""), | ||
("full-stack", ""), | ||
), | ||
# If the target is not provided, all images will be build | ||
"default": "", | ||
"help": "Specify the target to build.", | ||
} | ||
|
||
_AIIDALAB_PORT_PARAM = { | ||
"name": "port", | ||
"short": "p", | ||
"long": "port", | ||
"type": int, | ||
"default": 8888, | ||
"help": "Specify the AiiDAlab host port.", | ||
} | ||
|
||
_COMPOSE_CMD_PARAM = { | ||
"name": "compose-command", | ||
"long": "compose-cmd", | ||
"type": str, | ||
"default": "docker compose", | ||
"help": "Specify alternative docker compose command (e.g. podman-compose).", | ||
} | ||
|
||
|
||
def target_required(target: str) -> bool: | ||
if not target: | ||
print("ERROR: Target image must be provided with '-t/--target' option") | ||
return False | ||
return True | ||
|
||
|
||
def task_build(): | ||
"""Build all docker images.""" | ||
|
@@ -114,38 +147,60 @@ def generate_version_override( | |
def task_tests(): | ||
"""Run tests with pytest.""" | ||
|
||
# TODO: This currently does not work! | ||
# https://github.com/aiidalab/aiidalab-docker-stack/issues/451 | ||
return { | ||
"actions": ["REGISTRY=%(registry)s VERSION=:%(version)s pytest -v"], | ||
"params": [_REGISTRY_PARAM, _VERSION_PARAM, _TARGET_PARAM], | ||
"actions": [ | ||
target_required, | ||
"AIIDALAB_PORT=%(port)i REGISTRY=%(registry)s VERSION=:%(version)s " | ||
"pytest -s --target %(target)s --compose-cmd='%(compose-command)s' %(pytest-opts)s", | ||
], | ||
"params": [ | ||
_TARGET_PARAM, | ||
_AIIDALAB_PORT_PARAM, | ||
_REGISTRY_PARAM, | ||
_VERSION_PARAM, | ||
{ | ||
"name": "pytest-opts", | ||
"long": "pytest-opts", | ||
"type": str, | ||
"default": "", | ||
"help": "Extra options to pytest command.", | ||
}, | ||
_COMPOSE_CMD_PARAM, | ||
], | ||
"verbosity": 2, | ||
} | ||
|
||
|
||
def task_up(): | ||
"""Start AiiDAlab server for testing.""" | ||
"""Start AiiDAlab server.""" | ||
|
||
return { | ||
"actions": [ | ||
target_required, | ||
"AIIDALAB_PORT=%(port)i REGISTRY=%(registry)s VERSION=:%(version)s " | ||
"docker-compose up --detach" | ||
"%(compose-command)s -f stack/docker-compose.%(target)s.yml up --detach", | ||
], | ||
"params": [ | ||
{ | ||
"name": "port", | ||
"short": "p", | ||
"long": "port", | ||
"type": int, | ||
"default": 8888, | ||
"help": "Specify the AiiDAlab host port.", | ||
}, | ||
_TARGET_PARAM, | ||
_AIIDALAB_PORT_PARAM, | ||
_REGISTRY_PARAM, | ||
_VERSION_PARAM, | ||
_COMPOSE_CMD_PARAM, | ||
], | ||
"verbosity": 2, | ||
} | ||
|
||
|
||
def task_down(): | ||
"""Stop AiiDAlab server.""" | ||
return {"actions": ["docker-compose down"], "verbosity": 2} | ||
return { | ||
"actions": [ | ||
target_required, | ||
"%(compose-command)s -f stack/docker-compose.%(target)s.yml down", | ||
], | ||
"params": [ | ||
_TARGET_PARAM, | ||
_COMPOSE_CMD_PARAM, | ||
], | ||
"verbosity": 2, | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To simplify the code, you can now only provide a single
--target
argument (and we now automatically validate that you choose one of the four valid images. If no target is specified, then all images are built by default.