Skip to content

Commit

Permalink
Introduce integration tests (#24)
Browse files Browse the repository at this point in the history
Test for 

* ah_namespace
* ah_namespace
* ah_collection
* ah_collection_upload
* ah_approval
* collection_*
* ah_ee_registry

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
  • Loading branch information
Akasurde authored Sep 19, 2024
1 parent e1217d6 commit 5e8f5c8
Show file tree
Hide file tree
Showing 17 changed files with 911 additions and 105 deletions.
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,
}
]
)
30 changes: 30 additions & 0 deletions .github/files/galaxy.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
authors:
- Sean Sullivan @sean-m-sullivan
- Tom Page @Tompage1994
- David Danielsson @djdanielsson
dependencies: {}
description: Ansible content that interacts with the Ansible Automation Hub API
documentation: https://github.com/ansible-collections/ansible_hub/blob/main/README.md
license:
- GPL-3.0-only
namespace: {{ collection_namespace }}
name: {{ collection_name }}
version: {{ collection_version }}
readme: README.md
repository: {{ collection_repo }}
issues: {{ collection_repo }}/issues
tags:
- cloud
- infrastructure
- galaxy
- ansible
- galaxy
- automation
build_ignore:
- tools
- setup.cfg
- galaxy.yml.j2
- template_galaxy.yml
- '*.tar.gz'
...
105 changes: 0 additions & 105 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,110 +166,6 @@ jobs:
# https://github.com/ansible-community/ansible-test-gh-action#pull-request-change-detection
pull-request-change-detection: false
###
# Integration tests (RECOMMENDED)
#
# https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html


# If the application you are testing is available as a docker container and you want to test
# multiple versions see the following for an example:
# https://github.com/ansible-collections/community.zabbix/tree/master/.github/workflows

integration:
# Ansible-test on various stable branches does not yet work well with cgroups v2.
# Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04
# image for these stable branches. The list of branches where this is necessary will
# shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28
# for the latest list.
runs-on: >-
${{ contains(fromJson(
'["stable-2.9", "stable-2.10", "stable-2.11"]'
), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }}
name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }})
strategy:
fail-fast: false
matrix:
ansible:
- devel
# - milestone
python:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
include:
# Add new versions announced in
# https://github.com/ansible-collections/news-for-maintainers in a timely manner,
# consider dropping testing against EOL versions and versions you don't support.
# ansible-core 2.15
- ansible: stable-2.15
python: '3.5'
- ansible: stable-2.15
python: '3.6'
- ansible: stable-2.15
python: '3.7'
- ansible: stable-2.15
python: '3.8'
- ansible: stable-2.15
python: '3.9'
- ansible: stable-2.15
python: '3.10'
- ansible: stable-2.15
python: '3.11'
# ansible-core 2.16
- ansible: stable-2.16
python: '3.6'
- ansible: stable-2.16
python: '3.7'
- ansible: stable-2.16
python: '3.8'
- ansible: stable-2.16
python: '3.9'
- ansible: stable-2.16
python: '3.10'
- ansible: stable-2.16
python: '3.11'
- ansible: stable-2.16
python: '3.12'
# ansible-core 2.17
- ansible: stable-2.17
python: '3.7'
- ansible: stable-2.17
python: '3.8'
- ansible: stable-2.17
python: '3.9'
- ansible: stable-2.17
python: '3.10'
- ansible: stable-2.17
python: '3.11'
- ansible: stable-2.17
python: '3.12'


steps:
- name: >-
Perform integration testing against
Ansible version ${{ matrix.ansible }}
under Python ${{ matrix.python }}
# See the documentation for the following GitHub action on
# https://github.com/ansible-community/ansible-test-gh-action/blob/main/README.md
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: ${{ matrix.ansible }}
# OPTIONAL command to run before invoking `ansible-test integration`
# pre-test-cmd:
target-python-version: ${{ matrix.python }}
testing-type: integration
# OPTIONAL If your integration tests require code
# from other collections, install them like this
test-deps: ansible.netcommon
# OPTIONAL If set to true, will test only against changed files,
# which should improve CI performance. See limitations on
# https://github.com/ansible-community/ansible-test-gh-action#pull-request-change-detection
pull-request-change-detection: false
check: # This job does nothing and is only used for the branch protection
# or multi-stage CI jobs, like making sure that all tests pass before
Expand All @@ -279,7 +175,6 @@ jobs:
needs:
- sanity
- units
- integration

runs-on: ubuntu-latest

Expand Down
128 changes: 128 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
name: Test integration tests with galaxy_ng

on:
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
push:
branches:
- main
- stable-*
pull_request:
# Run CI once per day (at 06:00 UTC)
# This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-base version
schedule:
- cron: '0 6 * * *'

jobs:

integration:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
galaxy_ng_version:
# - stable-4.8
# - stable-4.9
- master
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

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

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

- name: (Linux) Install docker compose
run: |
curl -L -o /tmp/docker-compose https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-linux-x86_64
install /tmp/docker-compose /usr/local/bin/
# 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=${GITHUB_WORKSPACE}/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
echo "AH_HOST=http://localhost:55001/" >> $GITHUB_ENV
echo "AH_USERNAME=admin" >> $GITHUB_ENV
echo "AH_PASSWORD=admin" >> $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
working-directory: galaxy_ng
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: Move ci cfg to oci
run: mv .github/files/ci.py ./galaxy_ng/dev/oci_env_integration/actions/ci.py

- name: Stand up galaxy_ng
working-directory: galaxy_ng
run: python3 dev/oci_env_integration/actions/ci.py

- name: Create integration config
working-directory: /home/runner/collections/ansible_collections/ansible/hub/tests/integration/
run: |
echo "ah_host: 'http://localhost:55001/'" > integration_config.yml
echo "ah_username: admin" >> integration_config.yml
echo "ah_password: admin" >> integration_config.yml
echo "ah_verify_ssl: false" >> integration_config.yml
- name: Run integration test - ah_namespace
run: ansible-test integration ah_namespace
working-directory: /home/runner/collections/ansible_collections/ansible/hub

- name: Run integration test - ah_build
run: ansible-test integration ah_build
working-directory: /home/runner/collections/ansible_collections/ansible/hub

- name: Run integration test - ah_approval
run: ansible-test integration ah_approval
working-directory: /home/runner/collections/ansible_collections/ansible/hub

- name: Run integration test - ah_collection
run: ansible-test integration ah_collection
working-directory: /home/runner/collections/ansible_collections/ansible/hub

- name: Run integration test - ah_collection_upload
run: ansible-test integration ah_collection_upload
working-directory: /home/runner/collections/ansible_collections/ansible/hub

- name: Run integration test - collection_remote
run: ansible-test integration collection_remote
working-directory: /home/runner/collections/ansible_collections/ansible/hub

- name: Run integration test - collection_repository
run: ansible-test integration collection_repository
working-directory: /home/runner/collections/ansible_collections/ansible/hub

- name: Run integration test - collection_repository_sync
run: ansible-test integration collection_repository_sync
working-directory: /home/runner/collections/ansible_collections/ansible/hub

- name: Run integration test - ah_ee_registry
run: ansible-test integration ah_ee_registry
working-directory: /home/runner/collections/ansible_collections/ansible/hub
Loading

0 comments on commit 5e8f5c8

Please sign in to comment.