Skip to content

Commit bb4a2dc

Browse files
authored
Add local image build environment for tox (#261)
This should allow testing the image building locally
1 parent 3139ba9 commit bb4a2dc

File tree

5 files changed

+33
-13
lines changed

5 files changed

+33
-13
lines changed

.github/actions/build-test/action.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,8 @@ runs:
3535
shell: bash
3636
id: ansible-builder-install
3737
run: |
38-
python3 -m pip install ansible-builder
39-
40-
- name: Verify ansible-builder installed
41-
shell: bash
42-
id: ansible-builder-verify
43-
run: |
44-
ansible-builder --version
38+
python3 -m pip install ansible-builder ansible-navigator build
39+
python3 -m build --outdir final/dist/ --wheel
4540
4641
- name: Create a build context and Containerfile for base EE
4742
shell: bash
@@ -86,8 +81,6 @@ runs:
8681
- name: Validate if the final image is a valid EE
8782
shell: bash
8883
run: |
89-
python3 -m pip install --upgrade ansible-navigator
90-
ansible-navigator --version
9184
ansible-navigator run ${{ github.workspace }}/site.yml --ce docker --mode stdout --eei ${{ inputs.namespace }}/${{ inputs.final_image }}:test
9285
9386
- name: Run tests on the image before pushing with docker

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,6 @@ cython_debug/
173173

174174
.DS_Store
175175
_readthedocs
176+
177+
# ansible-builder
178+
context

final/Containerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ ENV ANSIBLE_DEV_TOOLS_CONTAINER=1
9595
# In OpenShift, container will run as a random uid number and gid 0. Make sure things
9696
# are writeable by the root group.
9797
RUN for dir in \
98+
/tmp/dist \
9899
/home/runner \
99100
/home/runner/.ansible \
100101
/home/runner/.ansible/tmp \
@@ -113,8 +114,8 @@ RUN for dir in \
113114

114115
# base ansible-dev-tools setup
115116

116-
COPY ./requirements.txt requirements.txt
117-
RUN python3 -m pip install --no-cache-dir -r requirements.txt
117+
COPY dist/*.whl /tmp/dist
118+
RUN sh -ec -o pipefail "ls -1 /tmp/dist/*.whl | xargs -I '{}' python3 -m pip install --no-cache-dir '{}[server,lock]' && rm -rf /tmp/dist"
118119

119120
RUN \
120121
mkdir -p ~/.ansible/roles /usr/share/ansible/roles /etc/ansible/roles && \

final/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

tox.ini

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ env_list =
88
lint
99
milestone
1010
pkg
11+
image
1112
skip_missing_interpreters = true
1213

1314
[testenv]
@@ -107,3 +108,27 @@ commands =
107108
rm -rfv {toxinidir}/dist/
108109
python -m build --outdir {toxinidir}/dist/ {toxinidir}
109110
sh -c "python -m twine check --strict {toxinidir}/dist/*"
111+
112+
[testenv:image]
113+
description =
114+
Build the container image
115+
skip_install = true
116+
deps =
117+
ansible-builder
118+
ansible-navigator
119+
build
120+
setuptools # https://github.com/ansible/ansible-builder/issues/644
121+
commands_pre =
122+
commands =
123+
python -m build --outdir {toxinidir}/final/dist/ --wheel {toxinidir}
124+
ansible-builder create -f execution-environment.yml --output-filename Containerfile -v3
125+
podman build context/ --tag community-ansible-dev-tools-base:latest
126+
podman build final/ --tag community-ansible-dev-tools:test
127+
ansible-navigator run site.yml --ce podman --mode stdout --eei community-ansible-dev-tools:test
128+
podman run --rm -v ./tests:/home/podman/tests \
129+
--security-opt seccomp=unconfined --security-opt label=disable --security-opt apparmor=unconfined \
130+
--cap-add=SYS_ADMIN --cap-add=SYS_RESOURCE \
131+
--device /dev/fuse community-ansible-dev-tools:test \
132+
-c "/home/podman/tests/test.sh"
133+
allowlist_externals =
134+
podman

0 commit comments

Comments
 (0)