Skip to content

Commit

Permalink
tests: Add jsonschema2md test
Browse files Browse the repository at this point in the history
  • Loading branch information
aarnq committed Jan 29, 2025
1 parent d6e0d0e commit 1854cd5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions scripts/run-from-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ if command -v git &>/dev/null; then
fi

# Prepare container repo
args+=("--env" "APPS_PATH=${root}")
args+=("--mount" "type=bind,src=${root},dst=${root}${relabel:-}")

"${runtime}" run "${args[@]}" "${@}"
27 changes: 16 additions & 11 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ ARG TZ="Etc/UTC"

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y apache2-utils bats curl dnsutils gettext-base git gpg iputils-ping jq locales make net-tools pwgen s3cmd ssh unzip && \
apt-get install -y apache2-utils bats curl dnsutils gettext-base git gpg iputils-ping jq locales make net-tools npm pwgen s3cmd ssh unzip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

ENV NODE_PATH="/usr/local/lib/node_modules"

ARG GOMPLATE_VERSION="3.11.7"
RUN curl -LOs "https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64" && \
install -Tm 755 gomplate_linux-amd64 /usr/local/bin/gomplate && \
Expand All @@ -38,6 +40,9 @@ RUN curl -LOs "https://github.com/helmfile/helmfile/releases/download/v${HELMFIL
install -Tm 755 helmfile /usr/local/bin/helmfile && \
rm helmfile "helmfile_${HELMFILE_VERSION}_linux_amd64.tar.gz"

ENV JSONSCHEMA2MD_VERSION="8.0.2"
RUN npm install --global "@adobe/jsonschema2md@${JSONSCHEMA2MD_VERSION}"

ARG KUBECTL_VERSION="1.29.7"
RUN curl -LOs "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" && \
install -Tm 755 kubectl /usr/local/bin/kubectl && \
Expand Down Expand Up @@ -82,20 +87,23 @@ RUN git clone --depth 1 https://github.com/bats-core/bats-file.git /usr/local/li
RUN git clone --depth 1 https://github.com/grayhemp/bats-mock.git /usr/local/lib/bats/mock
RUN git clone --depth 1 https://github.com/bats-core/bats-support.git /usr/local/lib/bats/support

ENV DOCS_PATH="/usr/local/share/docs"
RUN git clone --depth 1 https://github.com/elastisys/welkin.git "${DOCS_PATH}" && \
chmod --recursive a+w "${DOCS_PATH}"

# Container to run integration and end-to-end tests
FROM unit AS main

RUN apt-get update && \
apt-get install -y buildah docker.io libasound2t64 libatk1.0-0 libatk-bridge2.0-0 libcanberra-gtk-module libcanberra-gtk3-module libcups2 libgbm-dev libgbm1 libglib2.0-0 libgtk2.0-0 libgtk2.0-0t64 libgtk-3-0 libgtk-3-0t64 libnotify-dev libnss3 libxss1 libxtst6 npm podman-remote skopeo xauth xvfb && \
apt-get install -y buildah docker.io libasound2t64 libatk1.0-0 libatk-bridge2.0-0 libcanberra-gtk-module libcanberra-gtk3-module libcups2 libgbm-dev libgbm1 libglib2.0-0 libgtk2.0-0 libgtk2.0-0t64 libgtk-3-0 libgtk-3-0t64 libnotify-dev libnss3 libxss1 libxtst6 podman-remote skopeo xauth xvfb && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
ln -s /usr/bin/podman-remote /usr/bin/podman

ARG CYPRESS_VERSION="13.14.1"
ENV CYPRESS_CACHE_FOLDER="/usr/local/lib/cypress"
ENV NODE_PATH="/usr/local/lib/node_modules"
RUN npm install --global "cypress@${CYPRESS_VERSION}"
RUN chmod --recursive a+w "${CYPRESS_CACHE_FOLDER}"
RUN npm install --global "cypress@${CYPRESS_VERSION}" && \
chmod --recursive a+w "${CYPRESS_CACHE_FOLDER}"

ARG KIND_VERSION="0.23.0"
RUN curl -LOs "https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-linux-amd64" && \
Expand All @@ -104,9 +112,6 @@ RUN curl -LOs "https://github.com/kubernetes-sigs/kind/releases/download/v${KIND

ARG VELERO_VERSION="1.13.0"
RUN curl -LOs "https://github.com/vmware-tanzu/velero/releases/download/v${VELERO_VERSION}/velero-v${VELERO_VERSION}-linux-amd64.tar.gz" && \
tar -zxvf "velero-v${VELERO_VERSION}-linux-amd64.tar.gz" "velero-v${VELERO_VERSION}-linux-amd64" && \
install -Tm 755 "velero-v${VELERO_VERSION}-linux-amd64/velero" /usr/local/bin/velero && \
rm -r "velero-v${VELERO_VERSION}-linux-amd64.tar.gz" "velero-v${VELERO_VERSION}-linux-amd64"

ENV DOCS_PATH="/usr/local/share/docs"
RUN git clone --depth 1 https://github.com/elastisys/compliantkubernetes.git "${DOCS_PATH}"
tar -zxvf "velero-v${VELERO_VERSION}-linux-amd64.tar.gz" "velero-v${VELERO_VERSION}-linux-amd64" && \
install -Tm 755 "velero-v${VELERO_VERSION}-linux-amd64/velero" /usr/local/bin/velero && \
rm -r "velero-v${VELERO_VERSION}-linux-amd64.tar.gz" "velero-v${VELERO_VERSION}-linux-amd64"
10 changes: 10 additions & 0 deletions tests/unit/general/schema.bats
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,13 @@ find_schemas() {

refute_output
}

@test "documentation should be generated" {
pushd "${DOCS_PATH}" || exit 1

run "./scripts/jsonschema2md.sh" --path "${APPS_PATH}"

popd || exit 1

assert_success
}

0 comments on commit 1854cd5

Please sign in to comment.