Skip to content

Commit

Permalink
build/install collection in container
Browse files Browse the repository at this point in the history
Issue: AAH-2421
  • Loading branch information
bmclaughlin committed Feb 5, 2024
1 parent c226f80 commit 2909148
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/ci_automation_hub_collection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,5 @@ jobs:
pip install -e $OCI_ENV_PATH/client/
mkdir $OCI_ENV_PATH/db_backup/
- name: Checkout the galaxy collection
uses: actions/checkout@v4
with:
repository: ansible/galaxy_collection
path: galaxy_collection

- name: Build and install the collection
working-directory: galaxy_collection
run: |
# The ansible.cfg defined in the collection repository might break the test. We want the same variables for installation and running.
rm -f ansible.cfg
rm -f galaxy.yml
mv .github/files/galaxy.yml.j2 .
ansible all -i localhost, -c local -m template -a "src=galaxy.yml.j2 dest=galaxy.yml" -e collection_namespace=galaxy -e collection_name=galaxy -e collection_version=1.0.0 -e collection_repo=https://github.com/ansible/automation_hub_collection
ansible-galaxy collection build -vvv
ansible-galaxy collection install galaxy-galaxy-1.0.0.tar.gz -vvv
- name: run playbook tests
run: make gh-action/${{ matrix.env.TEST_PROFILE }}
20 changes: 20 additions & 0 deletions dev/oci_env_integration/actions/action_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,33 @@ def run_test(self):
f" {pytest_flags} {self.flags}"
)

def install_galaxy_collection(self, env):
self.exec_cmd(
env,
"exec git clone https://github.com/ansible/galaxy_collection /src/galaxy_collection_test"
)

# The ansible.cfg defined in the collection repository might break the test. We want the same variables for installation and running.
self.exec_cmd(env, "exec rm -f /src/galaxy_collection_test/ansible.cfg")
self.exec_cmd(env, "exec rm -f /src/galaxy_collection_test/galaxy.yml")
self.exec_cmd(env, "exec mv /src/galaxy_collection_test/.github/files/galaxy.yml.j2 /src/galaxy_collection_test/")
self.exec_cmd(
env,
'exec ansible all -i localhost, -c local -m template -a "src=/src/galaxy_collection_test/galaxy.yml.j2 dest=/src/galaxy_collection_test/galaxy.yml" -e collection_namespace=galaxy -e collection_name=galaxy -e collection_version=1.0.0 -e collection_repo=https://github.com/ansible/automation_hub_collection'
)
self.exec_cmd(env, "exec ansible-galaxy collection build --output-path /src/galaxy_collection_test/ /src/galaxy_collection_test/ -vvv")
self.exec_cmd(env, "exec ansible-galaxy collection install /src/galaxy_collection_test/galaxy-galaxy-1.0.0.tar.gz -vvv --force")
self.exec_cmd(env, "exec rm -rf /src/galaxy_collection_test")

def run_playbooks(self):
for env in self.envs:
if self.envs[env]["run_playbooks"]:
if wait_time := self.envs[env].get("wait_before_tests", 20):
print(f"waiting {wait_time} seconds")
time.sleep(wait_time)

self.install_galaxy_collection(env)

if len(self.envs[env]["playbooks"]) > 0:
for playbook in self.envs[env]["playbooks"]:
print(f"testing the {playbook} playbook")
Expand Down

0 comments on commit 2909148

Please sign in to comment.