Skip to content

Commit

Permalink
Enable testing of devspaces container
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Nov 4, 2024
1 parent 66726cf commit 120d40b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
10 changes: 6 additions & 4 deletions tools/devspaces.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# cspell: ignore euxo buildx
set -euxo pipefail
ADT_CONTAINER_ENGINE=${ADT_CONTAINER_ENGINE:-docker}
CONTAINER_NAME=ansible/ansible-workspace-env-reference:test
IMAGE_NAME=ansible/ansible-workspace-env-reference:test

mkdir -p out
# Ensure that we packaged the code first
Expand All @@ -23,12 +23,14 @@ cp tools/setup-image.sh devspaces/context
# we force use of linux/amd64 platform because source image supports only this
# platform and without it, it will fail to cross-build when task runs on arm64.
# --metadata-file=out/devspaces.meta --no-cache
$ADT_CONTAINER_ENGINE buildx build --tag=$CONTAINER_NAME --platform=linux/amd64 devspaces/context -f devspaces/Containerfile
$ADT_CONTAINER_ENGINE buildx build --tag=$IMAGE_NAME --platform=linux/amd64 devspaces/context -f devspaces/Containerfile

mk containers check $CONTAINER_NAME --engine="${ADT_CONTAINER_ENGINE}" --max-size=1600 --max-layers=23
mk containers check $IMAGE_NAME --engine="${ADT_CONTAINER_ENGINE}" --max-size=1600 --max-layers=23

pytest --only-container --engine="${ADT_CONTAINER_ENGINE}" --container-name=devspaces --image-name=$IMAGE_NAME

if [[ -n "${GITHUB_SHA:-}" ]]; then
$ADT_CONTAINER_ENGINE tag $CONTAINER_NAME "ghcr.io/ansible/ansible-devspaces-tmp:${GITHUB_SHA}"
$ADT_CONTAINER_ENGINE tag $IMAGE_NAME "ghcr.io/ansible/ansible-devspaces-tmp:${GITHUB_SHA}"
# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
if [[ -n "${GITHUB_TOKEN:-}" ]]; then
echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
Expand Down
14 changes: 7 additions & 7 deletions tools/ee.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fi
REPO_DIR=$(git rev-parse --show-toplevel)

TAG_BASE=community-ansible-dev-tools-base:latest
CONTAINER_NAME=community-ansible-dev-tools:test
IMAGE_NAME=community-ansible-dev-tools:test

# BUILD_CMD="podman build --squash-all"
BUILD_CMD="${ADT_CONTAINER_ENGINE} buildx build --progress=plain"
Expand Down Expand Up @@ -62,24 +62,24 @@ python -m build --outdir "$REPO_DIR/final/dist/" --wheel "$REPO_DIR"
ansible-builder create -f execution-environment.yml --output-filename Containerfile -v3
$BUILD_CMD -f context/Containerfile context/ --tag "${TAG_BASE}"
cp tools/setup-image.sh final/
$BUILD_CMD -f final/Containerfile final/ --tag "${CONTAINER_NAME}"
$BUILD_CMD -f final/Containerfile final/ --tag "${IMAGE_NAME}"

# Check container size and layers
mk containers check $CONTAINER_NAME --engine="${ADT_CONTAINER_ENGINE}" --max-size=1430 --max-layers=22
mk containers check $IMAGE_NAME --engine="${ADT_CONTAINER_ENGINE}" --max-size=1430 --max-layers=22

pytest -v --only-container --container-engine=docker --image-name "${CONTAINER_NAME}"
pytest -v --only-container --engine="${ADT_CONTAINER_ENGINE}" --image-name "${IMAGE_NAME}"
# -k test_navigator_simple
# Test the build of example execution environment to avoid regressions
pushd docs/examples
ansible-builder build
popd

if [[ -n "${GITHUB_SHA:-}" ]]; then
FQ_CONTAINER_NAME="ghcr.io/ansible/community-ansible-dev-tools-tmp:${GITHUB_SHA}-$ARCH"
$ADT_CONTAINER_ENGINE tag $CONTAINER_NAME "${FQ_CONTAINER_NAME}"
FQ_IMAGE_NAME="ghcr.io/ansible/community-ansible-dev-tools-tmp:${GITHUB_SHA}-$ARCH"
$ADT_CONTAINER_ENGINE tag $IMAGE_NAME "${FQ_IMAGE_NAME}"
# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
if [[ -n "${GITHUB_TOKEN:-}" ]]; then
echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
fi
$ADT_CONTAINER_ENGINE push "${FQ_CONTAINER_NAME}"
$ADT_CONTAINER_ENGINE push "${FQ_IMAGE_NAME}"
fi
10 changes: 1 addition & 9 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,10 @@ allowlist_externals =
description = Build devspaces container image for current architecture
skip_install = true
deps =
-r .config/requirements-test.in
mk
commands_pre =
commands =
./tools/devspaces.sh
allowlist_externals =
./tools/devspaces.sh

[testenv:test-ee]
description =
Run tests in the ee container image
commands_pre =
commands =
pytest --only-container {posargs}
allowlist_externals =
pytest

0 comments on commit 120d40b

Please sign in to comment.