diff --git a/.devcontainer/docs-test/devcontainer.json b/.devcontainer/docs-test/devcontainer.json new file mode 100644 index 00000000..80efc7c3 --- /dev/null +++ b/.devcontainer/docs-test/devcontainer.json @@ -0,0 +1,4 @@ +{ + "image": "ghcr.io/philips-software/amp-devcontainer-docs:${localEnv:IMAGE_VERSION}", + "workspaceFolder": "/workspaces/amp-devcontainer/test/docs/workspace" +} diff --git a/.devcontainer/docs/Dockerfile b/.devcontainer/docs/Dockerfile new file mode 100644 index 00000000..a44fab8f --- /dev/null +++ b/.devcontainer/docs/Dockerfile @@ -0,0 +1,34 @@ +# syntax=docker/dockerfile:1 + +ARG BASE_IMAGE=ghcr.io/philips-software/amp-devcontainer-base:edge +FROM ${BASE_IMAGE} + +ARG DEBIAN_FRONTEND=noninteractive + +HEALTHCHECK NONE + +SHELL ["/bin/bash", "-Eeuo", "pipefail", "-c"] + +# Set default environment options +ENV PYTHONPYCACHEPREFIX=/cache/.python + +# Install the base system with all tool dependencies +RUN --mount=type=bind,source=.devcontainer/docs/apt-requirements.json,target=/tmp/apt-requirements.json \ + --mount=type=bind,source=.devcontainer/docs/requirements.txt,target=/tmp/requirements.txt \ + --mount=type=cache,target=/cache,sharing=locked \ + --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + --mount=type=cache,target=/var/log,sharing=locked <&1 | to_semver) + + assert_equal "$INSTALLED_VERSION" "$EXPECTED_VERSION" +} + +# bats test_tags=Version,Pip +@test "pip version should be aligned with the expected version" { + EXPECTED_VERSION=$(get_expected_semver_for python3-pip) + INSTALLED_VERSION=$(pip --version | to_semver) + + assert_equal "$INSTALLED_VERSION" "$EXPECTED_VERSION" +} + +# bats test_tags=Version,Sbdl +@test "sbdl version should be aligned with the expected version" { + EXPECTED_VERSION=$(grep sbdl ${BATS_TEST_DIRNAME}/../../.devcontainer/docs/requirements.in | to_semver) + INSTALLED_VERSION=$(sbdl --version | to_semver) + + assert_equal "$INSTALLED_VERSION" "$EXPECTED_VERSION" +} + +## This section contains tests for the functional correctness of the installed tools. + +# bats test_tags=Functional,Plantuml +@test "plantuml should render a diagram to a png image" { + run plantuml -o build -tpng diagram.puml + + assert_success + assert [ -f build/diagram.png ] +} + +# bats test_tags=Functional,Graphviz +@test "graphviz should render a graph to an svg image" { + run dot -Tsvg graph.dot + + assert_success + assert_output --partial " Bob: Authentication Request +Bob --> Alice: Authentication Response +@enduml diff --git a/test/docs/workspace/graph.dot b/test/docs/workspace/graph.dot new file mode 100644 index 00000000..3f08981a --- /dev/null +++ b/test/docs/workspace/graph.dot @@ -0,0 +1,4 @@ +digraph { + a -> b; + b -> c; +} diff --git a/test/docs/workspace/sample.sbdl b/test/docs/workspace/sample.sbdl new file mode 100644 index 00000000..d6c1957d --- /dev/null +++ b/test/docs/workspace/sample.sbdl @@ -0,0 +1,5 @@ +#!sbdl +req-doc-0001 is requirement { + custom:title is "Sample requirement" + description is "A sample requirement used to validate the sbdl toolchain" +}