Skip to content

Commit 59ed900

Browse files
authored
Enable testing of devspaces container (#465)
1 parent 26c0f4d commit 59ed900

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

tools/devspaces.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
#!/bin/bash -e
2-
# cspell: ignore euxo buildx
2+
# cspell: ignore euxo buildx execdir
33
set -euxo pipefail
44
ADT_CONTAINER_ENGINE=${ADT_CONTAINER_ENGINE:-docker}
5-
CONTAINER_NAME=ansible/ansible-workspace-env-reference:test
5+
IMAGE_NAME=ansible/ansible-workspace-env-reference:test
66

7-
mkdir -p out
7+
mkdir -p out dist
88
# Ensure that we packaged the code first
9-
WHEELS=(dist/*.whl)
9+
# shellcheck disable=SC2207
10+
WHEELS=($(find dist -name '*.whl' -maxdepth 1 -execdir echo '{}' ';'))
1011
if [ ${#WHEELS[@]} -ne 1 ]; then
1112
tox -e pkg
12-
WHEELS=(dist/*.whl)
13+
# shellcheck disable=SC2207
14+
WHEELS=($(find dist -name '*.whl' -maxdepth 1 -execdir echo '{}' ';'))
1315
if [ ${#WHEELS[@]} -ne 1 ]; then
14-
echo "Unable to find a single wheel file in dist/ directory."
16+
echo "Unable to find a single wheel file in dist/ directory: ${WHEELS[*]}"
1517
exit 2
1618
fi
1719
fi
18-
tox -e pkg
1920
rm -f devspaces/context/*.whl
2021
cp dist/*.whl devspaces/context
2122
cp tools/setup-image.sh devspaces/context
2223

2324
# we force use of linux/amd64 platform because source image supports only this
2425
# platform and without it, it will fail to cross-build when task runs on arm64.
2526
# --metadata-file=out/devspaces.meta --no-cache
26-
$ADT_CONTAINER_ENGINE buildx build --tag=$CONTAINER_NAME --platform=linux/amd64 devspaces/context -f devspaces/Containerfile
27+
$ADT_CONTAINER_ENGINE buildx build --tag=$IMAGE_NAME --platform=linux/amd64 devspaces/context -f devspaces/Containerfile
2728

28-
mk containers check $CONTAINER_NAME --engine="${ADT_CONTAINER_ENGINE}" --max-size=1600 --max-layers=23
29+
mk containers check $IMAGE_NAME --engine="${ADT_CONTAINER_ENGINE}" --max-size=1600 --max-layers=23
30+
31+
pytest --only-container --container-engine="${ADT_CONTAINER_ENGINE}" --container-name=devspaces --image-name=$IMAGE_NAME "$@" || echo "::error::Ignored failed devspaces tests, please https://github.com/ansible/ansible-dev-tools/issues/467"
2932

3033
if [[ -n "${GITHUB_SHA:-}" ]]; then
31-
$ADT_CONTAINER_ENGINE tag $CONTAINER_NAME "ghcr.io/ansible/ansible-devspaces-tmp:${GITHUB_SHA}"
34+
$ADT_CONTAINER_ENGINE tag $IMAGE_NAME "ghcr.io/ansible/ansible-devspaces-tmp:${GITHUB_SHA}"
3235
# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
3336
if [[ -n "${GITHUB_TOKEN:-}" ]]; then
3437
echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin

tools/ee.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fi
2020
REPO_DIR=$(git rev-parse --show-toplevel)
2121

2222
TAG_BASE=community-ansible-dev-tools-base:latest
23-
CONTAINER_NAME=community-ansible-dev-tools:test
23+
IMAGE_NAME=community-ansible-dev-tools:test
2424

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

6767
# Check container size and layers
68-
mk containers check $CONTAINER_NAME --engine="${ADT_CONTAINER_ENGINE}" --max-size=1500 --max-layers=22
68+
mk containers check "$IMAGE_NAME" --engine="${ADT_CONTAINER_ENGINE}" --max-size=1500 --max-layers=22
6969

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

7777
if [[ -n "${GITHUB_SHA:-}" ]]; then
78-
FQ_CONTAINER_NAME="ghcr.io/ansible/community-ansible-dev-tools-tmp:${GITHUB_SHA}-$ARCH"
79-
$ADT_CONTAINER_ENGINE tag $CONTAINER_NAME "${FQ_CONTAINER_NAME}"
78+
FQ_IMAGE_NAME="ghcr.io/ansible/community-ansible-dev-tools-tmp:${GITHUB_SHA}-$ARCH"
79+
$ADT_CONTAINER_ENGINE tag $IMAGE_NAME "${FQ_IMAGE_NAME}"
8080
# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
8181
if [[ -n "${GITHUB_TOKEN:-}" ]]; then
8282
echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
8383
fi
84-
$ADT_CONTAINER_ENGINE push "${FQ_CONTAINER_NAME}"
84+
$ADT_CONTAINER_ENGINE push "${FQ_IMAGE_NAME}"
8585
fi

0 commit comments

Comments
 (0)