Merge pull request #11242 from shanemcd/awx-operator-ci-check

Add awx-operator CI check
This commit is contained in:
Shane McDonald 2021-10-13 10:28:23 -04:00 committed by GitHub
commit 4ab2539c8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 137 additions and 53 deletions

View File

@ -1,2 +1,3 @@
awx/ui/node_modules
Dockerfile
.git

View File

@ -175,3 +175,41 @@ jobs:
run: |
docker run -u $(id -u) --rm -v ${{ github.workspace}}:/awx_devel/:Z \
--workdir=/awx_devel ghcr.io/${{ github.repository_owner }}/awx_devel:${{ env.BRANCH }} make ui-test
awx-operator:
runs-on: ubuntu-latest
steps:
- name: Checkout awx
uses: actions/checkout@v2
with:
path: awx
- name: Checkout awx-operator
uses: actions/checkout@v2
with:
repository: ansible/awx-operator
path: awx-operator
- name: Install playbook dependencies
run: |
python3 -m pip install docker
- name: Build AWX image
working-directory: awx
run: |
ansible-playbook -v tools/ansible/build.yml \
-e headless=yes \
-e awx_image=awx \
-e awx_image_tag=ci \
-e ansible_python_interpreter=$(which python3)
- name: Run test deployment with awx-operator
working-directory: awx-operator
run: |
python3 -m pip install -r molecule/requirements.txt
ansible-galaxy collection install -r molecule/requirements.yml
sudo rm -f $(which kustomize)
make kustomize
KUSTOMIZE_PATH=$(readlink -f bin/kustomize) molecule test -s kind
env:
AWX_TEST_IMAGE: awx
AWX_TEST_VERSION: ci

View File

@ -6,8 +6,11 @@ ignore: |
# vault files
awx/main/tests/data/ansible_utils/playbooks/valid/vault.yml
awx/ui/test/e2e/tests/smoke-vars.yml
awx/ui/node_modules
tools/docker-compose/_sources
extends: default
rules:
line-length: disable
truthy: disable

View File

@ -379,7 +379,7 @@ clean-ui:
awx/ui/node_modules:
NODE_OPTIONS=--max-old-space-size=4096 $(NPM_BIN) --prefix awx/ui --loglevel warn ci
$(UI_BUILD_FLAG_FILE):
$(UI_BUILD_FLAG_FILE): awx/ui/node_modules
$(PYTHON) tools/scripts/compilemessages.py
$(NPM_BIN) --prefix awx/ui --loglevel warn run compile-strings
$(NPM_BIN) --prefix awx/ui --loglevel warn run build
@ -391,7 +391,9 @@ $(UI_BUILD_FLAG_FILE):
cp -r awx/ui/build/static/media/* awx/public/static/media
touch $@
ui-release: awx/ui/node_modules $(UI_BUILD_FLAG_FILE)
ui-release: $(UI_BUILD_FLAG_FILE)
ui-devel: awx/ui/node_modules
@$(MAKE) -B $(UI_BUILD_FLAG_FILE)
@ -420,10 +422,17 @@ dev_build:
release_build:
$(PYTHON) setup.py release_build
dist/$(SDIST_TAR_FILE): ui-release VERSION
HEADLESS ?= no
ifeq ($(HEADLESS), yes)
dist/$(SDIST_TAR_FILE):
else
dist/$(SDIST_TAR_FILE): $(UI_BUILD_FLAG_FILE)
endif
$(PYTHON) setup.py $(SDIST_COMMAND)
ln -sf $(SDIST_TAR_FILE) dist/awx.tar.gz
sdist: dist/$(SDIST_TAR_FILE)
echo $(HEADLESS)
@echo "#############################################"
@echo "Artifacts:"
@echo dist/$(SDIST_TAR_FILE)

View File

@ -5,7 +5,10 @@
To build a custom awx image to use with the awx-operator, use the `build_image` role:
```
$ ansible-playbook tools/ansible/build.yml -v -e awx_image=registry.example.com/awx -e awx_version=test
$ ansible-playbook tools/ansible/build.yml \
-e registry=registry.example.com \
-e awx_image=ansible/awx \
-e awx_version=test -v
```
> Note: The development image (`make docker-compose-build`) will not work with the awx-operator, the UI is not built in that image, among other things (see Dockerfile.j2 for more info).
@ -21,7 +24,7 @@ $ docker push registry.example.com/awx:test
## Using this image with the awx-operator
In the spec section of the `my-awx.yml` file described in the [install docs](./../INSTALL.md#deploy-awx),
specify the new custom image.
specify the new custom image.
```
spec:

View File

@ -2,7 +2,24 @@
- name: Build AWX Docker Images
hosts: localhost
gather_facts: true
roles:
- {role: dockerfile}
- {role: image_build}
- {role: image_push, when: "docker_registry is defined"}
tasks:
- name: Get version from SCM if not explicitly provided
shell: |
python setup.py --version | cut -d + -f -1
args:
chdir: '../../'
register: setup_py_version
when: awx_version is not defined
- name: Set awx_version
set_fact:
awx_version: "{{ setup_py_version.stdout }}"
when: awx_version is not defined
- include_role:
name: dockerfile
- include_role:
name: image_build
- include_role:
name: image_push
when: push | default(false) | bool

View File

@ -1,6 +1,7 @@
---
build_dev: false
kube_dev: false
headless: no
dockerfile_dest: '../..'
dockerfile_name: 'Dockerfile'
template_dest: '_build'

View File

@ -17,6 +17,4 @@ set -e
wait-for-migrations
awx-manage collectstatic --noinput --clear
supervisord -c /etc/supervisord.conf

View File

@ -11,6 +11,7 @@ ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
USER root
# Install build dependencies
@ -27,7 +28,9 @@ RUN dnf -y update && \
libffi-devel \
libtool-ltdl-devel \
make \
{% if not headless|bool %}
nodejs \
{% endif %}
nss \
openldap-devel \
patch \
@ -44,6 +47,7 @@ RUN dnf -y update && \
RUN python3.8 -m ensurepip && pip3 install "virtualenv < 20"
# Install & build requirements
ADD Makefile /tmp/Makefile
RUN mkdir /tmp/requirements
@ -54,18 +58,29 @@ ADD requirements/requirements.txt \
RUN cd /tmp && make requirements_awx
ARG VERSION
ARG SETUPTOOLS_SCM_PRETEND_VERSION
ARG HEADLESS
{% if (build_dev|bool) or (kube_dev|bool) %}
ADD requirements/requirements_dev.txt /tmp/requirements
RUN cd /tmp && make requirements_awx_dev
{% else %}
# Use the distro provided npm to bootstrap our required version of node
RUN npm install -g n && n 14.15.1 && dnf remove -y nodejs
{% if not headless|bool %}
RUN npm install -g n && n 14.15.1
{% endif %}
# Copy source into builder, build sdist, install it into awx venv
COPY . /tmp/src/
WORKDIR /tmp/src/
RUN make sdist && \
/var/lib/awx/venv/awx/bin/pip install dist/awx-$(cat VERSION).tar.gz
RUN make sdist && /var/lib/awx/venv/awx/bin/pip install dist/awx.tar.gz
{% if not headless|bool %}
RUN /var/lib/awx/venv/awx/bin/awx-manage collectstatic --noinput --clear
{% endif %}
{% endif %}
# Final container(s)

View File

@ -1,2 +1,5 @@
---
awx_image: quay.io/ansible/awx
awx_image: ansible/awx
awx_image_tag: "{{ awx_version }}"
dockerfile_name: 'Dockerfile'
headless: no

View File

@ -1,9 +1,4 @@
---
- name: Set global version if not provided
set_fact:
awx_version: "{{ lookup('file', playbook_dir + '/../../VERSION') }}"
when: awx_version is not defined
- name: Verify awx-logos directory exists for official install
stat:
path: "../../../awx-logos"
@ -17,11 +12,19 @@
dest: "../../awx/ui/public/static/media/"
when: awx_official|default(false)|bool
- set_fact:
command_to_run: |
docker build -t {{ awx_image }}:{{ awx_image_tag }} \
-f {{ dockerfile_name }} \
--build-arg VERSION={{ awx_version }} \
--build-arg SETUPTOOLS_SCM_PRETEND_VERSION={{ awx_version }} \
--build-arg HEADLESS={{ headless }} \
.
# Calling Docker directly because docker-py doesnt support BuildKit
- name: Build AWX image
command: docker build -t {{ awx_image }}:{{ awx_version }} -f ../../{{ dockerfile_name }} ../..
- name: Tag awx images as latest
command: "docker tag {{ item }}:{{ awx_version }} {{ item }}:latest"
with_items:
- "{{ awx_image }}"
shell: "{{ command_to_run }}"
environment:
DOCKER_BUILDKIT: 1
args:
chdir: "{{ playbook_dir }}/../../"

View File

@ -0,0 +1,4 @@
---
registry: quay.io
awx_image: ansible/awx
awx_image_tag: "{{ awx_version }}"

View File

@ -1,33 +1,22 @@
---
- name: Authenticate with Docker registry if registry password given
docker_login:
registry: "{{ docker_registry }}"
username: "{{ docker_registry_username }}"
password: "{{ docker_registry_password }}"
registry: "{{ registry }}"
username: "{{ registry_username }}"
password: "{{ registry_password }}"
reauthorize: true
when: docker_registry is defined and docker_registry_password is defined
- name: Remove local images to ensure proper push behavior
block:
- name: Remove awx image
docker_image:
name: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_image }}"
tag: "{{ awx_version }}"
state: absent
when:
- registry is defined
- registry_username is defined
- registry_password is defined
- name: Tag and Push Container Images
block:
- name: Tag and push awx image to registry
docker_image:
name: "{{ awx_image }}"
repository: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_image }}"
tag: "{{ item }}"
push: true
with_items:
- "latest"
- "{{ awx_version }}"
- name: Set full image path for Registry
set_fact:
awx_docker_actual_image: >-
{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_image }}:{{ awx_version }}
docker_image:
name: "{{ awx_image }}:{{ awx_version }}"
repository: "{{ registry }}/{{ awx_image }}:{{ item }}"
force_tag: yes
push: true
source: local
with_items:
- "latest"
- "{{ awx_version }}"