Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of Ci #375

Merged
merged 21 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/files/ci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import action_lib

env = action_lib.OCIEnvIntegrationTest(
envs=[
{
"env_file": "standalone.compose.env",
"run_tests": False,
"db_restore": None,
}
]
)
6 changes: 2 additions & 4 deletions .github/workflows/ci_standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ jobs:
fail-fast: false
matrix:
galaxy_ng_version:
- stable-4.4
- stable-4.5
- stable-4.6
- stable-4.7
- stable-4.8
- stable-4.9
- master
uses: "./.github/workflows/ci_standalone_versioned.yml"
with:
Expand Down
113 changes: 33 additions & 80 deletions .github/workflows/ci_standalone_versioned.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,110 +30,63 @@ jobs:
with:
ref: ${{ inputs.gh_ref }}

- name: Move ansible.cfg to root
run: mv .github/files/ansible.cfg .

- name: Build and install the collection
id: build
uses: redhat-cop/ansible_collections_tooling/actions/build_ansible_collection@main
with:
collection_namespace: galaxy
collection_name: galaxy
collection_version: 1.0.0
collection_repo: https://github.com/ansible/galaxy_collection

- name: "Checkout galaxy_ng"
uses: actions/checkout@v2
with:
repository: ansible/galaxy_ng
path: galaxy_ng
ref: ${{ inputs.galaxy_ng_version }}

- name: "Checkout ansible-hub-ui"
uses: actions/checkout@v2
with:
repository: ansible/ansible-hub-ui
path: ansible-hub-ui
ref: ${{ inputs.galaxy_ng_version }}

- uses: actions/setup-python@v2
with:
python-version: "3.8"
# Note: COMPOSE_INTERACTIVE_NO_CLI=1 is required for oci-env to work correctly when there's no interactive terminal
- name: Set environment variables
working-directory: galaxy_ng
run: |
echo "OCI_ENV_PATH=${HOME}/work/ah_configuration/ah_configuration/oci_env" >> $GITHUB_ENV
echo "COMPOSE_INTERACTIVE_NO_CLI=1" >> $GITHUB_ENV
echo "OCI_VERBOSE=1" >> $GITHUB_ENV
echo "GH_DUMP_LOGS=1" >> $GITHUB_ENV
echo "GH_TEARDOWN=0" >> $GITHUB_ENV

- name: Update apt
run: sudo apt -y update

- name: Install LDAP requirements
run: sudo apt-get install -y libsasl2-dev python3-dev libldap2-dev libssl-dev build-essential

- name: Install docker-compose
run: pip3 install --upgrade docker-compose

- name: Downgrade docker
run: pip3 install docker==6.1.3

- name: collect system info
run: whoami; id; pwd; ls -al; uname -a ; df -h .; mount ; cat /etc/issue; docker --version ; ps aux | fgrep -i docker; ls -al /var/run/containerd/containerd.sock

- name: create the .compose.env file
run: rm -f galaxy_ng/.compose.env; cp galaxy_ng/.compose.env.example galaxy_ng/.compose.env

- name: workaround github worker permissions issues
run: sed -i.bak 's/PIP_EDITABLE_INSTALL=1/PIP_EDITABLE_INSTALL=0/' galaxy_ng/.compose.env

- name: workaround to enable collection approval for 4.4/4.5
run: sed -i.bak 's/PULP_GALAXY_REQUIRE_CONTENT_APPROVAL=false/PULP_GALAXY_REQUIRE_CONTENT_APPROVAL=true/' galaxy_ng/dev/standalone/galaxy_ng.env

- name: workaround github worker permissions issues
run: sed -i.bak 's/WITH_DEV_INSTALL=1/WITH_DEV_INSTALL=0/' galaxy_ng/.compose.env

- name: set the hub ui path in .compose.env
run: echo "ANSIBLE_HUB_UI_PATH='/home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/ansible-hub-ui'" >> galaxy_ng/.compose.env
run: sudo apt-get install -y libsasl2-dev python3 libldap2-dev libssl-dev build-essential

- name: cat
run: cat galaxy_ng/.compose.env

- name: build stack
working-directory: galaxy_ng
run: make docker/build

- name: run migrations
- name: setup oci-env
working-directory: galaxy_ng
run: make docker/migrate
run: |
git clone https://github.com/pulp/oci_env.git $OCI_ENV_PATH
pip install -e $OCI_ENV_PATH/client/
mkdir $OCI_ENV_PATH/db_backup/

- name: load translations
working-directory: galaxy_ng
run: make docker/translations
- name: Move ci cfg to oci
run: mv .github/files/ci.py ./galaxy_ng/dev/oci_env_integration/actions/ci.py

- name: load loaddata
- name: Stand up galaxy_ng
working-directory: galaxy_ng
run: make docker/loaddata

- name: start the compose stack
working-directory: galaxy_ng
run: ./compose up -d

- name: give stack some time to spin up
run: sleep 240
run: python3 dev/oci_env_integration/actions/ci.py

- name: Move ansible.cfg to root
run: mv .github/files/ansible.cfg .

- name: Build and install the collection
id: build
uses: redhat-cop/ansible_collections_tooling/actions/build_ansible_collection@main
with:
collection_namespace: galaxy
collection_name: galaxy
collection_version: 1.0.0
collection_repo: https://github.com/ansible/galaxy_collection
- name: "Perform playbook user and group management tests"
run: ansible-playbook tests/playbooks/testing_playbook_user.yml -v -e galaxy_ng_version=${{ inputs.galaxy_ng_version }}

- name: "Perform playbook collection tests"
run: ansible-playbook tests/playbooks/testing_collections_playbook.yml -v -e galaxy_ng_version=${{ inputs.galaxy_ng_version }} -e git_repo_name=${{ github.event.repository.name }}
if: |
inputs.galaxy_ng_version == 'stable-4.4' ||
inputs.galaxy_ng_version == 'stable-4.5' ||
inputs.galaxy_ng_version == 'stable-4.6' ||
inputs.galaxy_ng_version == 'stable-4.7'


- name: "Perform collection repository tests"
run: ansible-playbook tests/playbooks/testing_collections_repos.yml -v -e galaxy_ng_version=${{ inputs.galaxy_ng_version }}

- name: "Perform playbook namespace tests"
run: ansible-playbook tests/playbooks/testing_playbook_ee_namespace.yml -v -e galaxy_ng_version=${{ inputs.galaxy_ng_version }}
if: ${{ inputs.galaxy_ng_version == 'stable-4.4' || inputs.galaxy_ng_version == 'stable-4.5' }} # ee_namespace APIs were removed in 4.6 (see #183)

- name: "Perform playbook repository tests"
run: ansible-playbook tests/playbooks/testing_playbook_ee_repository.yml -vv -e galaxy_ng_version=${{ inputs.galaxy_ng_version }} -e redhat_catalog_username=${{ secrets.redhat_catalog_username }} -e redhat_catalog_password=${{ secrets.redhat_catalog_password }}

- name: "Perform playbook user and group management tests"
run: ansible-playbook tests/playbooks/testing_playbook_user.yml -v -e galaxy_ng_version=${{ inputs.galaxy_ng_version }}
1 change: 1 addition & 0 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ build_ignore:
- template_galaxy.yml
- '*.tar.gz'
- test
- galaxy_ng
...
2 changes: 1 addition & 1 deletion tests/playbooks/ah_configs/ah_ansible_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
automation_hub_list:
- name: automation_hub
url: "{{ ah_hostname }}"
auth_url: "{{ ah_hostname }}api/automation-hub/" # {{ah_hostname}}api/galaxy/ for AH {{ah_hostname}}api/automation-hub/ for Galaxy
auth_url: "{{ ah_hostname }}api/galaxy/" # {{ah_hostname}}api/galaxy/ for AH {{ah_hostname}}api/automation-hub/ for Galaxy

ansible_config_list:
- header: galaxy
Expand Down
10 changes: 6 additions & 4 deletions tests/playbooks/ah_configs/ah_auth.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# User may add tower auth creds to this file and encrypt it using `ansible-vault`
---
ah_hostname: http://localhost:8002/ # http://192.168.122.47:8002/ http://localhost:8002/ https://192.168.122.200/
ah_username: "{% if galaxy_ng_version == 'stable-4.4' or galaxy_ng_version == 'stable-4.5' or galaxy_ng_version == 'stable-4.6' %}admin{% else %}iqe_admin{% endif %}"
ah_password: "{% if galaxy_ng_version == 'stable-4.4' or galaxy_ng_version == 'stable-4.5' or galaxy_ng_version == 'stable-4.6' %}admin{% else %}redhat{% endif %}"
ah_hostname: http://localhost:55001/ # http://192.168.122.47:55001/ http://localhost:55001/ https://192.168.122.200/
# ah_username: "{% if galaxy_ng_version == 'stable-4.4' or galaxy_ng_version == 'stable-4.5' or galaxy_ng_version == 'stable-4.6' %}admin{% else %}iqe_admin{% endif %}"
# ah_password: "{% if galaxy_ng_version == 'stable-4.4' or galaxy_ng_version == 'stable-4.5' or galaxy_ng_version == 'stable-4.6' %}admin{% else %}redhat{% endif %}"
ah_username: admin
ah_password: admin
ah_validate_certs: false
ah_path_prefix: 'automation-hub' # AH: galaxy Galaxy: automation-hub
ah_path_prefix: 'galaxy' # AH: galaxy Galaxy: automation-hub
ah_configuration_namespace_secure_logging: false
...
2 changes: 2 additions & 0 deletions tests/playbooks/ah_configs/ah_ee_repositories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ ah_ee_repositories:
# Adding a description and a README file to the repository
- name: test-namespace/ee-minimal-rhel8
# Testing with UTF-8 characters
registry: quay
upstream_name: "{{ fake_image }}"
description: To jest jakiś opis
readme: |
# Min avrättningsmiljö
Expand Down
83 changes: 66 additions & 17 deletions tests/playbooks/testing_collections_repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,26 @@
mode: '0755'

tasks:
- name: Perform pre-4.7 tasks for collection repositories
when: galaxy_ng_version == "stable-4.4" or galaxy_ng_version == "stable-4.5" or galaxy_ng_version == "stable-4.6"
block:
- name: Repository creation
ansible.builtin.include_role:
name: repository
# - name: Perform pre-4.7 tasks for collection repositories
# when: galaxy_ng_version == "stable-4.4" or galaxy_ng_version == "stable-4.5" or galaxy_ng_version == "stable-4.6"
# block:
# - name: Repository creation
# ansible.builtin.include_role:
# name: repository

- name: Repository creation with file
ansible.builtin.include_role:
name: repository
vars:
ah_repository_community:
url: https://galaxy.ansible.com/api/
requirements_file: files/collection_requirement_file.yml
# - name: Repository creation with file
# ansible.builtin.include_role:
# name: repository
# vars:
# ah_repository_community:
# url: https://galaxy.ansible.com/api/
# requirements_file: files/collection_requirement_file.yml

- name: Repository sync
ansible.builtin.include_role:
name: repository_sync
# - name: Repository sync
# ansible.builtin.include_role:
# name: repository_sync

- name: Perform tasks for collection repositories
when: galaxy_ng_version == "stable-4.7" or galaxy_ng_version == "stable-4.8" or galaxy_ng_version == "master"
block:
- name: Collection Remote creation
ansible.builtin.include_role:
Expand All @@ -64,4 +63,54 @@
vars:
ah_collection_repositories:
- name: community-infra-repo

- name: Test group role creation
ansible.builtin.include_role:
name: group_roles
vars:
ah_group_roles:
- groups:
- administrators
- managers
role_list:
- roles:
- galaxy.user_admin
- galaxy.group_admin
- groups:
- operators
- managers
role_list:
- roles:
- galaxy.ansible_repository_owner
targets:
collection_repositories:
- community-infra-repo
- roles:
- galaxy.collection_remote_owner
targets:
collection_remotes:
- community-infra
- groups:
- administrators
- managers
state: absent
role_list:
- roles:
- galaxy.user_admin
- galaxy.group_admin
- groups:
- operators
- managers
state: absent
role_list:
- roles:
- galaxy.ansible_repository_owner
targets:
collection_repositories:
- community-infra-repo
- roles:
- galaxy.collection_remote_owner
targets:
collection_remotes:
- community-infra
...
4 changes: 2 additions & 2 deletions tests/playbooks/testing_playbook_ee_namespace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
collections:
- galaxy.galaxy
vars:
ah_hostname: http://localhost:8002/
ah_hostname: http://localhost:55001/
ah_username: admin
ah_password: admin
ah_path_prefix: 'automation-hub'
ah_path_prefix: 'galaxy'
ah_validate_certs: false

tasks:
Expand Down
32 changes: 4 additions & 28 deletions tests/playbooks/testing_playbook_ee_repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
collections:
- galaxy.galaxy
vars:
hub_host: localhost:5001
ah_hostname: http://localhost:8002/
hub_host: localhost:55001
ah_hostname: http://localhost:55001/
ah_username: admin
ah_password: admin
ah_path_prefix: 'automation-hub'
ah_path_prefix: 'galaxy'
ah_validate_certs: false
repository: test-namespace/ee-minimal-rhel8
tag: latest
Expand All @@ -24,30 +24,6 @@
tags:
- always
tasks:
# Preparing an image:
# - Pulling a small image from Quay (does not matter what image it is)
# - Tagging it so that it can be pushed to private automation hub
# - Pushing the image
# - Deleting the images from the local system
# The tasks do not use the podman collection because it may not be
# available on the testing system.
- name: Ensure a small container image is available
ansible.builtin.command:
cmd: "podman pull {{ fake_image }}"
changed_when: true

- name: Ensure the image has the correct tag
ansible.builtin.command:
cmd: "podman tag {{ fake_image }} {{ hub_host }}/{{ repository }}:{{ tag }}"
changed_when: true

- name: Ensure the image is pushed in private automation hub
ansible.builtin.command:
cmd: "podman push --tls-verify=false --remove-signatures
--creds={{ ah_username }}:{{ ah_password }}
{{ hub_host }}/{{ repository }}:{{ tag }}"
changed_when: true

# Preparing a README file
- name: Ensure a temporary file exists
ansible.builtin.tempfile:
Expand All @@ -63,7 +39,7 @@
* bullet 1
* bullet 2

- name: Registery creation
- name: Registry creation
ansible.builtin.include_role:
name: ee_registry

Expand Down
Loading
Loading