Skip to content

Commit

Permalink
Update Galaxy collection ci to oci-env
Browse files Browse the repository at this point in the history
Add Keycloak as a test profile
Issue: AAH-2421
  • Loading branch information
bmclaughlin committed Feb 2, 2024
1 parent 1b7dbbb commit 0c5ff9f
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 27 deletions.
60 changes: 33 additions & 27 deletions .github/workflows/ci_automation_hub_collection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,52 @@ name: Galaxy Collection CI
on:
pull_request:
branches:
- "*"
- '**'
paths-ignore:
- "CHANGES/**"
- "docs/**"
- "mkdocs.yml"
push:
branches:
- "*"
- '**'
workflow_dispatch:

jobs:
galaxy_collection:
integration:
strategy:
fail-fast: false
matrix:
env:
- TEST_PROFILE: standalone
- TEST_PROFILE: keycloak
runs-on: ubuntu-latest
steps:
- name: Checkout galaxy_ng
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"

# Note: COMPOSE_INTERACTIVE_NO_CLI=1 is required for oci-env to work correctly when there's no interactive terminal
- name: Set environment variables
run: |
echo "OCI_ENV_PATH=${HOME}/work/galaxy_ng/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
- name: Update apt
run: sudo apt -y update

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

- name: setup oci-env
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: Checkout the galaxy collection
uses: actions/checkout@v4
with:
Expand All @@ -42,23 +66,5 @@ jobs:
ansible-galaxy collection build -vvv
ansible-galaxy collection install galaxy-galaxy-1.0.0.tar.gz -vvv
- name: Spin up a standalone galaxy_ng installation
run: |
echo "COMPOSE_PROFILE=standalone" > .compose.env
echo "DEV_SOURCE_PATH=galaxy_ng" >> .compose.env
make docker/all
./compose up -d
pip3 install --upgrade requests pyyaml
python3 dev/common/poll.py
- name: Test the user playbook
run: ansible-playbook dev/galaxy_collection_plays/user.yml -vvv

- name: Test the content playbook
run: ansible-playbook dev/galaxy_collection_plays/content.yml -vvv

- name: Test the repo playbook
run: ansible-playbook dev/galaxy_collection_plays/repo.yml -vvv

- name: Test the ee playbook
run: ansible-playbook dev/galaxy_collection_plays/ee.yml -vvv
- name: run playbook tests
run: make gh-action/${{ matrix.env.TEST_PROFILE }}
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ gh-action/community:
gh-action/certified-sync:
python3 dev/oci_env_integration/actions/certified-sync.py

.PHONY: gh-action/galaxy_collection_standalone
gh-action/galaxy_collection_standalone:
python3 dev/oci_env_integration/actions/galaxy_collection.py

.PHONY: gh-action/galaxy_collection_keycloak
gh-action/galaxy_collection_keycloak:
python3 dev/oci_env_integration/actions/galaxy_collection.py

.PHONY: docker/loaddata
docker/loaddata: ## Load initial data from python script
$(call exec_or_run, api, "/bin/bash", "-c", "/entrypoint.sh manage shell < app/dev/common/setup_test_data.py")
Expand Down
16 changes: 16 additions & 0 deletions dev/oci_env_integration/actions/action_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class OCIEnvIntegrationTest:
env_file (string, required): oci-env env file to use for the tests. These are all loaded
from dev/oci_env_integration/oci_env_configs
run_tests (boolean, required): if true, integration tests will be run inside this instance
run_playbooks (boolean, optional): if true, Galaxy Collection playbook tests will be run inside this instance
db_restore (string, optional): database backup to restore before running tests These are all
loaded from dev/oci_env_integration/oci_env_configs. When defining this, omit
the file extension (ex: fixture, not fixtur.tar.gz)
Expand Down Expand Up @@ -127,6 +128,21 @@ def run_test(self):
f" {pytest_flags} {self.flags}"
)

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

if self.envs[env]["run_playbooks"]:
if len(self.envs[env]["playbooks"]) > 0:
for playbook in self.envs[env]["playbooks"]:
print(f"testing the {playbook} playbook")
self.exec_cmd(
env,
f"exec ansible-playbook src/galaxy_ng/dev/galaxy_collection_plays/{playbook} -vvv"
)

def dump_logs(self):
if not self.do_dump_logs:
return
Expand Down
22 changes: 22 additions & 0 deletions dev/oci_env_integration/actions/galaxy_collection_keycloak.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import action_lib

env = action_lib.OCIEnvIntegrationTest(
envs=[
{
"env_file": "keycloak.compose.env",
"run_tests": False,
"run_playbooks": True,
"playbooks": [
"user.yml",
"content.yml",
"repo.yml",
"ee.yml",
],
"db_restore": None,

# the keycloak profile performs some setup after the service
# comes online
"wait_before_tests": 120
}
]
)
22 changes: 22 additions & 0 deletions dev/oci_env_integration/actions/galaxy_collection_standalone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import action_lib

env = action_lib.OCIEnvIntegrationTest(
envs=[
{
"env_file": "standalone.compose.env",
"run_tests": False,
"run_playbooks": True,
"playbooks": [
"user.yml",
"content.yml",
"repo.yml",
"ee.yml",
],
"db_restore": None,

# the keycloak profile performs some setup after the service
# comes online
# "wait_before_tests": 120
}
]
)

0 comments on commit 0c5ff9f

Please sign in to comment.