Skip to content

Added oc-zoscloudbroker module, overhauled tests (Ansible Sanity, Uni… #418

Added oc-zoscloudbroker module, overhauled tests (Ansible Sanity, Uni…

Added oc-zoscloudbroker module, overhauled tests (Ansible Sanity, Uni… #418

Workflow file for this run

# Execute Molecule Tests
name: Test
on:
push:
branches:
- "**"
paths-ignore:
- "docs/**"
- "**.md"
tags-ignore:
- "**"
pull_request_target:
concurrency:
group: >-
${{ github.workflow }}-${{
github.event.pull_request.number || github.sha
}}
cancel-in-progress: true
jobs:
authorize:
name: Authorize
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true
lint:
name: Lint
needs: authorize
runs-on: ubuntu-latest
steps:
- name: Check-out repository for Branch builds
uses: actions/checkout@v3
if: github.event_name != 'pull_request_target'
- name: Check-out repository for PR builds
uses: actions/checkout@v3
with:
ref: "refs/pull/${{ github.event.number }}/merge"
if: github.event_name == 'pull_request_target'
- name: Install Python Requirements
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
- name: Perform PIP installs
run: pip install ansible-lint==6.16.0
- name: Perform collection installs
run: ansible-galaxy collection install ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk --force
- name: Run ansible-lint
run: |
ansible-galaxy collection install --force -r ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/requirements.yml
ansible-lint --config-file ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/.ansible-lint --project-dir ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/playbooks/ --exclude ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/playbooks/molecule/
sanity:
name: Run Sanity Tests (Ⓐ${{ matrix.ansible }})
needs: [lint, authorize]
runs-on: >-
${{ contains(fromJson(
'["stable-2.9", "stable-2.10", "stable-2.11"]'
), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }}
strategy:
matrix:
ansible:
- stable-2.16
# - milestone
steps:
- name: Perform sanity testing with ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
collection-root: /ibm/operator_collection_sdk/
ansible-core-version: stable-2.16
testing-type: sanity
unit:
name: Run Unit Tests (Ⓐ${{ matrix.ansible }})
needs: [lint, authorize]
runs-on: >-
${{ contains(fromJson(
'["stable-2.9", "stable-2.10", "stable-2.11"]'
), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }}
strategy:
matrix:
ansible:
- stable-2.16
steps:
- name: Perform unit testing with ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
collection-root: /ibm/operator_collection_sdk/
ansible-core-version: stable-2.16
target-python-version: 3.11
testing-type: units
test-deps: >-
kubernetes.core
integration:
name: Run Integration Tests
needs: [lint, authorize]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Log into OCP
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
- name: Setup Cluster Environment before integration Tests
continue-on-error: true
run: |
chmod +x ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/integration_setup.sh
bash ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/integration_setup.sh \
--collection-root=${GITHUB_WORKSPACE}/ibm/operator_collection_sdk
env:
OCP_NAMESPACE: integration-${GITHUB_REF_NAME}-${RUNNER_OS}
ZOSCB_RELEASE: ibm-zoscb.${{ vars.ZOSCB_RELEASE }}
- name: Install Python Requirements
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
- name: Perform PIP and Collection Installs
run: |
pip install -r ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/requirements.txt
ansible-galaxy collection install --force -r ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/requirements.yml
ansible-galaxy collection install ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk --force
- name: Perform Integration Testing with ansible-test
run: |
cd ~/.ansible/collections/ansible_collections/ibm/operator_collection_sdk
ansible-test integration -v
- name: Cleanup Cluster Environment after integration Tests
if: always()
run: |
chmod +x ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/integration_clean.sh
bash ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/integration_clean.sh \
--collection-root=${GITHUB_WORKSPACE}/ibm/operator_collection_sdk
env:
OCP_NAMESPACE: integration-${GITHUB_REF_NAME}-${RUNNER_OS}
ZOSCB_RELEASE: ibm-zoscb.${{ vars.ZOSCB_RELEASE }}
molecule-tests:
name: Run Molecule Tests
needs: [lint, authorize]
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
steps:
- name: Check-out repository for Branch builds
uses: actions/checkout@v3
if: github.event_name != 'pull_request_target'
- name: Check-out repository for PR builds
uses: actions/checkout@v3
with:
ref: "refs/pull/${{ github.event.number }}/merge"
if: github.event_name == 'pull_request_target'
- name: Install Python Requirements
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
- name: Perform PIP installs
run: pip install -r ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/requirements.txt
- name: Perform collection installs
run: |
ansible-galaxy collection install --force -r ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/requirements.yml
ansible-galaxy collection install ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk --force
- name: Install oc cli
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: latest
- name: Log into OCP
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
- name: Execute Molecule Tests
run: |
cd ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/playbooks
export ANSIBLE_PYTHON_INTERPRETER="$(which python)"
OCP_NAMESPACE=molecule-${GITHUB_REF_NAME}-${RUNNER_OS} molecule test --all
env:
OPENSHIFT_SERVER: ${{ secrets.OPENSHIFT_SERVER }}
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }}
ZOSCB_RELEASE: ibm-zoscb.${{ vars.ZOSCB_RELEASE }}