mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-11-21 14:48:37 +00:00
* add matrix to test run helm tests with multiple version * fix(ci): resolve SonarCloud security findings in helm integration workflow Enforce HTTPS/TLS for the ansible-core download and pin and wheel-lock the selinux_please_lie_to_me install. Suppress the two remaining findings (ansible-core source install and shared test-requirements.txt pins) that cannot be fixed here without breaking CI, following the existing sonar.issue.ignore.multicriteria pattern. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(ci): fix remaining sanity and SonarCloud quality gate failures Remove stale import-3.9!skip entries from tests/sanity/ignore-2.23.txt; ansible-core devel dropped the import-3.9 sanity test target entirely, so referencing it now fails the "ignores" sanity test itself. Switch the e4/e5 sonar.issue.ignore.multicriteria resourceKey patterns in sonar-project.properties from a bare literal filename to a **/ glob, matching the working e1-e3 patterns. The literal path was not matching during analysis, so the two intended suppressions (githubactions:S8541/S8544 on integration-tests-helm.yaml) never took effect and kept failing the new code security rating gate. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * test(helm): add regression coverage for plain_http/helm-diff fix, enable helm_uninstall target helm_diff: replace the unreachable "< 3.13.0" OCI-chart block (plain_http is only ever true for >= 3.13.0, so the two conditions could never both hold) with a ">= 3.13.0" case that installs helm-diff and runs a plain_http diff upgrade, exercising the exact path the plain_http/--plain-http fix touches. helm_plain_http: replace the HTTPS Bitnami-backed test with one that pushes a local chart to the plain-HTTP registry from setup_helm_registry and exercises helm/helm_pull/helm_template against it, so success assertions verify plain HTTP actually works rather than only that the flag was passed. Also drop the now-stale redis* .gitignore entry. helm_uninstall: add the missing aliases file (every sibling helm target has one; without it the target is not picked up by CI target selection) and replace a dead assertion gated on helm < 3.7.0 with one that matches the versions this target actually runs against (>= 3.8.0). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(ci): make the S8541/S8544 SonarCloud suppressions actually take effect The three flagged lines (ansible-core source install, shared requirements.txt install) have been open since before the suppression rules were added, and two prior attempts at the e4/e5 resourceKey pattern (literal filename, then a **/filename glob) left them unresolved across multiple fresh analyses - already-raised issues on unchanged lines do not appear to get re-evaluated against newly added ignore rules. Broaden e4/e5 to the same .github/workflows/**/*.yaml pattern already proven to work for e3 (confirmed: githubactions:S7637 has 20 open issues org-wide but 0 here, despite this repo having @main references e3 is meant to suppress). This is also a more honest scope: all_green_check.yaml has the identical ansible-core-from-source and shared-requirements.txt patterns, not just integration-tests-helm.yaml. Also make a no-op edit to the two flagged lines (reorder the pip flag and the two -r files; verified zero package overlap between requirements.txt and test-requirements.txt) so SonarCloud treats them as changed and re-evaluates them against the fixed suppression rule, rather than carrying forward the stale pre-suppression issue state. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Fix tests and the possibility to run helm tests locally Fix linters errors --------- Co-authored-by: GomathiS <gosriniv@redhat.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
201 lines
7.2 KiB
YAML
201 lines
7.2 KiB
YAML
name: Integration tests
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- reopened
|
|
- labeled
|
|
- unlabeled
|
|
- synchronize
|
|
branches:
|
|
- main
|
|
- stable-*
|
|
|
|
jobs:
|
|
splitter:
|
|
env:
|
|
source_dir: "./source"
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
test_targets: ${{ steps.select-targets.outputs.targets }}
|
|
test_jobs: ${{ steps.select-targets.outputs.jobs }}
|
|
steps:
|
|
- name: Checkout the collection repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
path: ${{ env.source_dir }}
|
|
fetch-depth: "0"
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
- name: list changes for pull request
|
|
id: splitter
|
|
uses: ansible-network/github_actions/.github/actions/ansible_test_splitter@main
|
|
with:
|
|
collections_to_test: ${{ env.source_dir }}
|
|
total_jobs: 8
|
|
|
|
- name: Remove all Helm related targets
|
|
id: select-targets
|
|
run: |
|
|
import os, json
|
|
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh:
|
|
data = os.environ.get("ALL_TEST_TARGETS")
|
|
index = 0
|
|
result = {}
|
|
for target in data.split(";"):
|
|
if target and ':' in target:
|
|
k8s = [v for v in target.split(':', maxsplit=1)[1].split(',') if not v.startswith('helm')]
|
|
if k8s:
|
|
result[index] = ' '.join(k8s)
|
|
index += 1
|
|
fh.write(f'targets={json.dumps(result)}\n')
|
|
fh.write(f'jobs={json.dumps(list(result.keys()))}\n')
|
|
shell: python
|
|
env:
|
|
ALL_TEST_TARGETS: ${{ steps.splitter.outputs.test_targets }}
|
|
|
|
- name: Display splitter output
|
|
env:
|
|
TARGETS: ${{ steps.select-targets.outputs.targets }}
|
|
JOBS: ${{ steps.select-targets.outputs.jobs }}
|
|
run: |
|
|
echo "targets => $TARGETS"
|
|
echo "jobs => $JOBS"
|
|
shell: bash
|
|
integration:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
needs:
|
|
- splitter
|
|
if: ${{ needs.splitter.outputs.test_jobs != '' && needs.splitter.outputs.test_jobs != '[]' }}
|
|
env:
|
|
source: "./source"
|
|
cloud_common: "./cloudcommon"
|
|
ansible_posix: "./ansible_posix"
|
|
community_general: "./community_general"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# Ref must match a branch/tag on github.com/ansible/ansible (e.g. stable-2.18, not 2.18).
|
|
#
|
|
ansible-version: ["stable-2.18", "stable-2.21", "milestone"]
|
|
enable-turbo-mode: [true, false]
|
|
python-version: ["3.12", "3.13"]
|
|
exclude:
|
|
# stable-2.18 is used mainly because turbo mode, no reason to test it with turbo mode disabled
|
|
- ansible-version: "stable-2.18"
|
|
enable-turbo-mode: false
|
|
# turbo mode is supported only by ansible<2.19
|
|
- ansible-version: "milestone"
|
|
enable-turbo-mode: true
|
|
- ansible-version: "stable-2.21"
|
|
enable-turbo-mode: true
|
|
# stable-2.18 supports 3.12
|
|
- ansible-version: "stable-2.18"
|
|
python-version: "3.13"
|
|
- ansible-version: "stable-2.21"
|
|
python-version: "3.12"
|
|
- ansible-version: "milestone"
|
|
python-version: "3.12"
|
|
workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }}
|
|
name: Integration tests
|
|
steps:
|
|
- name: Read target
|
|
id: read-targets
|
|
run: |
|
|
import json, os
|
|
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh:
|
|
fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n')
|
|
shell: python
|
|
env:
|
|
ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets }}
|
|
WORKFLOW_ID: ${{ matrix.workflow-id }}
|
|
|
|
- name: Display ansible test targets
|
|
env:
|
|
ANSIBLE_TEST_TARGETS: ${{ steps.read-targets.outputs.ansible_test_targets }}
|
|
run: |
|
|
echo "ansible_test_targets -> $ANSIBLE_TEST_TARGETS"
|
|
|
|
- name: Checkout kubernetes.core repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
path: ${{ env.source }}
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
# install ansible
|
|
- name: Install ansible-core (${{ matrix.ansible-version }})
|
|
run: >-
|
|
python3 -m pip install
|
|
https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz
|
|
--disable-pip-version-check
|
|
shell: bash
|
|
|
|
- name: Build and install collection
|
|
id: install-src
|
|
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
|
with:
|
|
install_python_dependencies: true
|
|
source_path: ${{ env.source }}
|
|
|
|
- name: checkout ansible-collections/cloud.common
|
|
if: ${{ matrix.enable-turbo-mode == true }}
|
|
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
|
|
with:
|
|
repository: ansible-collections/cloud.common
|
|
path: ${{ env.cloud_common }}
|
|
ref: main
|
|
|
|
- name: checkout ansible-collections/ansible.posix
|
|
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
|
|
with:
|
|
repository: ansible-collections/ansible.posix
|
|
path: ${{ env.ansible_posix }}
|
|
ref: main
|
|
|
|
- name: checkout ansible-collections/community.general
|
|
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
|
|
with:
|
|
repository: ansible-collections/community.general
|
|
path: ${{ env.community_general }}
|
|
ref: main
|
|
|
|
- name: install cloud.common collection
|
|
if: ${{ matrix.enable-turbo-mode == true }}
|
|
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
|
with:
|
|
install_python_dependencies: true
|
|
source_path: ${{ env.cloud_common }}
|
|
|
|
- name: install ansible.posix collection
|
|
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
|
with:
|
|
install_python_dependencies: true
|
|
source_path: ${{ env.ansible_posix }}
|
|
|
|
- name: install community.general collection
|
|
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
|
with:
|
|
install_python_dependencies: false
|
|
source_path: ${{ env.community_general }}
|
|
|
|
- name: create kubernetes cluster
|
|
uses: helm/kind-action@v1.8.0
|
|
with:
|
|
node_image: "kindest/node:v1.29.2"
|
|
|
|
- name: Run integration tests
|
|
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main
|
|
with:
|
|
collection_path: ${{ steps.install-src.outputs.collection_path }}
|
|
python_version: ${{ matrix.python-version }}
|
|
ansible_version: ${{ matrix.ansible-version }}
|
|
ansible_test_targets: ${{ steps.read-targets.outputs.ansible_test_targets }}
|
|
ansible_test_environment: |
|
|
ENABLE_TURBO_MODE=${{ matrix.enable-turbo-mode }}
|