From dfb5ee37b6765c5ae8f468e86c71749f9342e48e Mon Sep 17 00:00:00 2001 From: Sean Sullivan Date: Fri, 13 Jan 2023 05:16:15 -0500 Subject: [PATCH] Updates release and adds an integration test. (#61) * update workflows * fix readme * update release and testing * update release and testing --- .github/tests/build_ee.yml | 53 ++++++++++++++++++++++++++ .github/workflows/ci_testing.yaml | 31 +++++++++++++++ .github/workflows/release.yml | 2 + ansible.cfg | 3 ++ roles/ee_builder/tasks/00_build_ee.yml | 2 +- 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 .github/tests/build_ee.yml create mode 100644 .github/workflows/ci_testing.yaml create mode 100644 ansible.cfg diff --git a/.github/tests/build_ee.yml b/.github/tests/build_ee.yml new file mode 100644 index 0000000..1e6b414 --- /dev/null +++ b/.github/tests/build_ee.yml @@ -0,0 +1,53 @@ +--- +- name: Playbook to configure execution environments + hosts: localhost + connection: local + gather_facts: false + pre_tasks: + - name: Validate that ansible-builder is installed on target system + block: + - name: Try command + ansible.builtin.shell: ansible-builder --version + register: r_builder + changed_when: false + rescue: + - name: Try to install with rpms + block: + - name: Install ansible-builder from rpm + ansible.builtin.dnf: + name: + - ansible-builder + - ansible-core + enablerepo: ansible-automation-platform-2.2-for-rhel-8-x86_64-rpms + state: present + become: true + rescue: + - name: Install ansible-builder from pip + ansible.builtin.pip: + name: + - ansible-builder + - ansible-core + state: latest + + tasks: + - name: Include ee_builder role + ansible.builtin.include_role: + name: ee_builder + vars: + ee_pull_collections_from_hub: false + ee_list: + - name: config_as_code_ee + bindep: + - unzip + python: + - ansible-lint + - netaddr + collections: + - name: infra.controller_configuration + - name: infra.ah_configuration + - name: infra.ee_utilities + - name: infra.aap_utilities + - name: awx.awx + append: + - RUN dnf update -y +... diff --git a/.github/workflows/ci_testing.yaml b/.github/workflows/ci_testing.yaml new file mode 100644 index 0000000..1f178e9 --- /dev/null +++ b/.github/workflows/ci_testing.yaml @@ -0,0 +1,31 @@ +--- +name: Run Test of EE utilities +on: [push, pull_request] + +jobs: + Integration-test: + name: Run Test of EE utilities + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install Ansible and Ansible Builder + run: pip install --upgrade ansible-core ansible-builder + + - name: Install Dependencies + run: ansible-galaxy collection install containers.podman -f + + - name: Docker login + run: docker login -u="redhat_cop+github_action" -p="${{ secrets.quay_token }}" quay.io + + - name: Build EE + run: ansible-playbook .github/tests/build_ee.yml -e "ee_registry_username=redhat_cop+github_action" -e "ee_registry_password=${{ secrets.quay_token }}" --connection=local -e "ee_registry_dest=quay.io/redhat_cop/config_as_code_ee" -vvv + env: + ANSIBLE_HOST_KEY_CHECKING: False +... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index afb89ba..fb40ad6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,8 +17,10 @@ jobs: collection_name: ee_utilities collection_version: ${{ github.ref_name }} collection_repo: https://github.com/redhat-cop/ee_utilities/ + quay_username: redhat_cop secrets: galaxy_api_key: ${{ secrets.ANSIBLE_GALAXY_APIKEY }} infra_api_key: ${{ secrets.GALAXY_INFRA_KEY }} token: ${{ secrets.GITHUB_TOKEN }} + quay_token: ${{ secrets.quay_token }} ... diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..ab50d8b --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,3 @@ +[defaults] +collections_paths=collections +roles_path=roles/ diff --git a/roles/ee_builder/tasks/00_build_ee.yml b/roles/ee_builder/tasks/00_build_ee.yml index d5bd6c2..56d89be 100644 --- a/roles/ee_builder/tasks/00_build_ee.yml +++ b/roles/ee_builder/tasks/00_build_ee.yml @@ -57,7 +57,7 @@ ansible.builtin.command: > ansible-builder build -f {{ builder_dir | default(build_dir.path) }}/execution_environment.yml - -t {{ __execution_environment_definition.name }}{% if __execution_environment_definition.tag is defined %}:{{ __execution_environment_definition.tag }}{% endif %} --container-runtime={{ ee_container_runtime }} + -t {{ __execution_environment_definition.name | default( __execution_environment_definition.ee_name )}}{% if __execution_environment_definition.tag is defined %}:{{ __execution_environment_definition.tag }}{% endif %} --container-runtime={{ ee_container_runtime }} {% if ee_prune_images %} --prune-images{% endif %} {% if ee_galaxy_keyring is defined %} --galaxy-keyring={{ ee_galaxy_keyring }}{% endif %} {% if ee_galaxy_ignore_signature_status_code is defined %}{% for status_code in ee_galaxy_ignore_signature_status_code %} --galaxy-ignore-signature-status-code={{ status_code }}{% endfor %}{% endif %}