| 1 |
name: Integration tests |
| 2 |
on: |
| 3 |
pull_request: |
| 4 |
types: |
| 5 |
- opened |
| 6 |
- reopened |
| 7 |
- labeled |
| 8 |
- unlabeled |
| 9 |
- synchronize |
| 10 |
branches: |
| 11 |
- main |
| 12 |
- stable-* |
| 13 |
|
| 14 |
jobs: |
| 15 |
splitter: |
| 16 |
env: |
| 17 |
source_dir: "./source" |
| 18 |
runs-on: ubuntu-latest |
| 19 |
outputs: |
| 20 |
test_targets: ${{ steps.splitter.outputs.test_targets }} |
| 21 |
test_targets_json: ${{ steps.splitter.outputs.test_targets_json }} |
| 22 |
test_jobs: ${{ steps.splitter.outputs.test_jobs }} |
| 23 |
steps: |
| 24 |
- name: Checkout the collection repository |
| 25 |
uses: actions/checkout@v3 |
| 26 |
with: |
| 27 |
path: ${{ env.source_dir }} |
| 28 |
fetch-depth: "0" |
| 29 |
ref: ${{ github.event.pull_request.head.sha }} |
| 30 |
|
| 31 |
- name: list changes for pull request |
| 32 |
id: splitter |
| 33 |
uses: ansible-network/github_actions/.github/actions/ansible_test_splitter@main |
| 34 |
with: |
| 35 |
collections_to_test: ${{ env.source_dir }} |
| 36 |
total_jobs: 8 |
| 37 |
|
| 38 |
- name: Display splitter output |
| 39 |
run: | |
| 40 |
echo "test_targets=${{ steps.splitter.outputs.test_targets }}" |
| 41 |
echo "test_targets_json=${{ steps.splitter.outputs.test_targets_json }}" |
| 42 |
echo "test_jobs=${{ steps.splitter.outputs.test_jobs }}" |
| 43 |
shell: bash |
| 44 |
integration: |
| 45 |
runs-on: ubuntu-latest |
| 46 |
timeout-minutes: 60 |
| 47 |
needs: |
| 48 |
- splitter |
| 49 |
if: ${{ needs.splitter.outputs.test_targets != '' }} |
| 50 |
env: |
| 51 |
source: "./source" |
| 52 |
cloud_common: "./cloudcommon" |
| 53 |
ansible_posix: "./ansible_posix" |
| 54 |
community_general: "./community_general" |
| 55 |
strategy: |
| 56 |
fail-fast: false |
| 57 |
matrix: |
| 58 |
|
| 59 |
ansible-version: ["stable-2.18", "milestone"] |
| 60 |
enable-turbo-mode: [true, false] |
| 61 |
exclude: |
| 62 |
- ansible-version: "milestone" |
| 63 |
enable-turbo-mode: true |
| 64 |
python-version: |
| 65 |
- "3.12" |
| 66 |
workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }} |
| 67 |
name: "integration-py${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}-enable_turbo=${{ matrix.enable-turbo-mode }}" |
| 68 |
steps: |
| 69 |
- name: Read target |
| 70 |
id: read-targets |
| 71 |
run: | |
| 72 |
import json, os |
| 73 |
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh: |
| 74 |
fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n') |
| 75 |
shell: python |
| 76 |
env: |
| 77 |
ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets_json }} |
| 78 |
WORKFLOW_ID: ${{ matrix.workflow-id }} |
| 79 |
|
| 80 |
- name: Display ansible test targets |
| 81 |
run: | |
| 82 |
echo "ansible_test_targets -> ${{ steps.read-targets.outputs.ansible_test_targets }}" |
| 83 |
|
| 84 |
- name: Checkout kubernetes.core repository |
| 85 |
uses: actions/checkout@v3 |
| 86 |
with: |
| 87 |
path: ${{ env.source }} |
| 88 |
ref: ${{ github.event.pull_request.head.sha }} |
| 89 |
|
| 90 |
- name: Set up Python ${{ matrix.python-version }} |
| 91 |
uses: actions/setup-python@v4 |
| 92 |
with: |
| 93 |
python-version: ${{ matrix.python-version }} |
| 94 |
|
| 95 |
|
| 96 |
- name: Install ansible-core (${{ matrix.ansible-version }}) |
| 97 |
run: >- |
| 98 |
python3 -m pip install |
| 99 |
https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz |
| 100 |
--disable-pip-version-check |
| 101 |
shell: bash |
| 102 |
|
| 103 |
- name: Build and install collection |
| 104 |
id: install-src |
| 105 |
uses: ansible-network/github_actions/.github/actions/build_install_collection@main |
| 106 |
with: |
| 107 |
install_python_dependencies: true |
| 108 |
source_path: ${{ env.source }} |
| 109 |
|
| 110 |
- name: checkout ansible-collections/cloud.common |
| 111 |
if: ${{ matrix.enable-turbo-mode == true }} |
| 112 |
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main |
| 113 |
with: |
| 114 |
repository: ansible-collections/cloud.common |
| 115 |
path: ${{ env.cloud_common }} |
| 116 |
ref: main |
| 117 |
|
| 118 |
- name: checkout ansible-collections/ansible.posix |
| 119 |
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main |
| 120 |
with: |
| 121 |
repository: ansible-collections/ansible.posix |
| 122 |
path: ${{ env.ansible_posix }} |
| 123 |
ref: main |
| 124 |
|
| 125 |
- name: checkout ansible-collections/community.general |
| 126 |
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main |
| 127 |
with: |
| 128 |
repository: ansible-collections/community.general |
| 129 |
path: ${{ env.community_general }} |
| 130 |
ref: main |
| 131 |
|
| 132 |
- name: install cloud.common collection |
| 133 |
if: ${{ matrix.enable-turbo-mode == true }} |
| 134 |
uses: ansible-network/github_actions/.github/actions/build_install_collection@main |
| 135 |
with: |
| 136 |
install_python_dependencies: true |
| 137 |
source_path: ${{ env.cloud_common }} |
| 138 |
|
| 139 |
- name: install ansible.posix collection |
| 140 |
uses: ansible-network/github_actions/.github/actions/build_install_collection@main |
| 141 |
with: |
| 142 |
install_python_dependencies: true |
| 143 |
source_path: ${{ env.ansible_posix }} |
| 144 |
|
| 145 |
- name: install community.general collection |
| 146 |
uses: ansible-network/github_actions/.github/actions/build_install_collection@main |
| 147 |
with: |
| 148 |
install_python_dependencies: false |
| 149 |
source_path: ${{ env.community_general }} |
| 150 |
|
| 151 |
- name: create kubernetes cluster |
| 152 |
uses: helm/[email protected] |
| 153 |
with: |
| 154 |
node_image: "kindest/node:v1.29.2" |
| 155 |
|
| 156 |
- name: Run integration tests |
| 157 |
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main |
| 158 |
with: |
| 159 |
collection_path: ${{ steps.install-src.outputs.collection_path }} |
| 160 |
python_version: ${{ matrix.python-version }} |
| 161 |
ansible_version: ${{ matrix.ansible-version }} |
| 162 |
ansible_test_targets: ${{ steps.read-targets.outputs.ansible_test_targets }} |
| 163 |
ansible_test_environment: | |
| 164 |
ENABLE_TURBO_MODE=${{ matrix.enable-turbo-mode }} |