mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-11-22 07:00:19 +00:00
CI - Update workflow to run helm test against multiple versions (#1232)
* 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>
This commit is contained in:
co-authored by
GomathiS
Claude Sonnet 5
parent
ebb0d7f087
commit
782672d2fd
@@ -0,0 +1,2 @@
|
||||
---
|
||||
helm_binary: helm
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- setup_helm_version
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
- connection: local
|
||||
gather_facts: true
|
||||
hosts: localhost
|
||||
|
||||
roles:
|
||||
- helm_pull
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eux
|
||||
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
|
||||
export ANSIBLE_ROLES_PATH=../
|
||||
ansible-playbook playbook.yaml "$@"
|
||||
@@ -1,101 +1,83 @@
|
||||
---
|
||||
- name: Define helm versions to test
|
||||
set_fact:
|
||||
helm_versions:
|
||||
- 3.8.0
|
||||
- 3.1.0
|
||||
- 3.0.0
|
||||
- 4.0.0
|
||||
|
||||
- block:
|
||||
- name: Create temp directory for helm tests
|
||||
tempfile:
|
||||
ansible.builtin.tempfile:
|
||||
state: directory
|
||||
register: tmpdir
|
||||
|
||||
- name: Set temp directory fact
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
temp_dir: "{{ tmpdir.path }}"
|
||||
|
||||
- set_fact:
|
||||
destination: "{{ temp_dir }}"
|
||||
|
||||
- name: Install Helm versions
|
||||
ansible.builtin.include_role:
|
||||
name: install_helm
|
||||
loop: "{{ helm_versions }}"
|
||||
vars:
|
||||
helm_version: "v{{ item }}"
|
||||
helm_install_path: "{{ temp_dir }}/{{ item }}"
|
||||
|
||||
# Testing helm pull with helm version == 3.0.0
|
||||
- block:
|
||||
- name: Run test with helm version '3.0.0'
|
||||
when: helm_version | string is ansible.builtin.version('3.0.0', "==")
|
||||
block:
|
||||
- name: Download chart using chart_ssl_cert_file
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
chart_ssl_cert_file: ssl_cert_file
|
||||
ignore_errors: true
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
- name: Assert that module failed with proper message
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result is failed
|
||||
- _result.msg == "Parameter chart_ssl_cert_file requires helm >= 3.1.0, current version is 3.0.0"
|
||||
|
||||
- name: Download chart using chart_ssl_key_file
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
chart_ssl_key_file: ssl_key_file
|
||||
ignore_errors: true
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result is failed
|
||||
- _result.msg == "Parameter chart_ssl_key_file requires helm >= 3.1.0, current version is 3.0.0"
|
||||
|
||||
- name: Download chart using chart_ca_cert
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
chart_ca_cert: ca_cert_file
|
||||
ignore_errors: true
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
- name: Assert that module failed with proper message
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result is failed
|
||||
- _result.msg == "Parameter chart_ca_cert requires helm >= 3.1.0, current version is 3.0.0"
|
||||
|
||||
vars:
|
||||
helm_path: "{{ temp_dir }}/3.0.0/helm"
|
||||
|
||||
# Testing helm pull with helm version == 3.1.0
|
||||
- block:
|
||||
- name: Run test with helm version '3.1.0'
|
||||
when: helm_version | string is ansible.builtin.version('3.1.0', "==")
|
||||
block:
|
||||
- name: Download chart using chart_ssl_cert_file, chart_ca_cert, chart_ssl_key_file
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
chart_ssl_cert_file: ssl_cert_file
|
||||
chart_ssl_key_file: ssl_key_file
|
||||
chart_ca_cert: ca_cert_file
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
- name: Assert that module failed with proper message
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result is changed
|
||||
- '"--ca-file ca_cert_file" in _result.command'
|
||||
@@ -104,32 +86,31 @@
|
||||
|
||||
- name: Download chart using skip_tls_certs_check
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
skip_tls_certs_check: true
|
||||
ignore_errors: true
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
- name: Assert that module failed with proper message
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result is failed
|
||||
- _result.msg == "Parameter skip_tls_certs_check requires helm >= 3.3.0, current version is 3.1.0"
|
||||
|
||||
vars:
|
||||
helm_path: "{{ temp_dir }}/3.1.0/helm"
|
||||
|
||||
# Testing helm pull with helm version == 3.8.0
|
||||
- block:
|
||||
- name: Run test with helm version '3.8.0'
|
||||
when: helm_version | string is ansible.builtin.version('3.8.0', "==")
|
||||
block:
|
||||
# Test options chart_version, verify, pass-credentials, provenance, untar_chart
|
||||
# skip_tls_certs_check, repo_url, repo_username, repo_password
|
||||
- name: Testing chart version
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: redis
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
chart_version: "0.2.1"
|
||||
verify_chart: true
|
||||
pass_credentials: true
|
||||
@@ -143,7 +124,8 @@
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- assert:
|
||||
- name: Validate module results
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result is changed
|
||||
- '"--version 0.2.1" in _result.command'
|
||||
@@ -154,24 +136,24 @@
|
||||
- '"--insecure-skip-tls-verify" in _result.command'
|
||||
- '"--repo https://charts.bitnami.com/bitnami" in _result.command'
|
||||
- '"--username ansible" in _result.command'
|
||||
- '"--password ***" in _result.command'
|
||||
- '"--password " in _result.command' # can be followed by '***' or '$REDACTED$'
|
||||
- '"--keyring pubring.gpg" in _result.command'
|
||||
- '"Module did not set no_log for pass_credentials" not in _result.stderr'
|
||||
|
||||
- name: Download chart using chart_ref
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
register: _result
|
||||
|
||||
- name: Check chart on local filesystem
|
||||
stat:
|
||||
path: "{{ destination }}/grafana-5.6.0.tgz"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ temp_dir }}/grafana-5.6.0.tgz"
|
||||
register: _chart
|
||||
|
||||
- name: Validate that chart was downloaded
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result is changed
|
||||
- _chart.stat.exists
|
||||
@@ -179,19 +161,19 @@
|
||||
|
||||
- name: Download chart using untar_chart
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
untar_chart: true
|
||||
register: _result
|
||||
|
||||
- name: Check chart on local filesystem
|
||||
stat:
|
||||
path: "{{ destination }}/redis"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ temp_dir }}/redis"
|
||||
register: _chart
|
||||
|
||||
- name: Validate that chart was downloaded
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result is changed
|
||||
- _chart.stat.exists
|
||||
@@ -200,22 +182,22 @@
|
||||
# Test idempotency with tarred chart
|
||||
- name: Download chart with version (first time)
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
chart_version: "24.1.0"
|
||||
register: _result_first
|
||||
|
||||
- name: Download chart with version (second time - should be idempotent)
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
chart_version: "24.1.0"
|
||||
register: _result_second
|
||||
|
||||
- name: Validate idempotency for tarred chart
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result_first is changed
|
||||
- _result_second is not changed
|
||||
@@ -223,81 +205,77 @@
|
||||
# Test force parameter with tarred chart
|
||||
- name: Download chart with force=true (should always download)
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
|
||||
destination: "{{ destination }}"
|
||||
destination: "{{ temp_dir }}"
|
||||
chart_version: "24.1.0"
|
||||
force: true
|
||||
register: _result_force
|
||||
|
||||
- name: Validate force parameter causes download
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result_force is changed
|
||||
|
||||
# Test idempotency with untarred chart in the separate folder
|
||||
- name: Create separate directory for untar test under {{ temp_dir }}
|
||||
ansible.builtin.file:
|
||||
path: "{{ destination }}/untar_test"
|
||||
path: "{{ temp_dir }}/untar_test"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Download and untar chart (first time)
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
|
||||
destination: "{{ destination }}/untar_test"
|
||||
destination: "{{ temp_dir }}/untar_test"
|
||||
chart_version: "24.0.0"
|
||||
untar_chart: true
|
||||
register: _result_untar_first
|
||||
|
||||
- name: Download and untar chart (second time - should be idempotent)
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
|
||||
destination: "{{ destination }}/untar_test"
|
||||
destination: "{{ temp_dir }}/untar_test"
|
||||
chart_version: "24.0.0"
|
||||
untar_chart: true
|
||||
register: _result_untar_second
|
||||
|
||||
- name: Validate idempotency for untarred chart
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result_untar_first is changed
|
||||
- _result_untar_second is not changed
|
||||
|
||||
- name: Download and untar chart with force=true (should remove existing directory and re-extract)
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
|
||||
destination: "{{ destination }}/untar_test"
|
||||
destination: "{{ temp_dir }}/untar_test"
|
||||
chart_version: "24.0.0"
|
||||
untar_chart: true
|
||||
force: true
|
||||
register: _result_untar_force
|
||||
|
||||
- name: Validate first force extraction works
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _result_untar_force is changed
|
||||
|
||||
- name: Verify chart directory still exists after force re-extraction
|
||||
stat:
|
||||
path: "{{ destination }}/untar_test/redis"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ temp_dir }}/untar_test/redis"
|
||||
register: _chart_after_force
|
||||
|
||||
- name: Validate chart directory exists
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _chart_after_force.stat.exists
|
||||
- _chart_after_force.stat.isdir
|
||||
|
||||
vars:
|
||||
helm_path: "{{ temp_dir }}/3.8.0/helm"
|
||||
|
||||
|
||||
always:
|
||||
- name: Delete temp directory
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: "{{ temp_dir }}"
|
||||
|
||||
Reference in New Issue
Block a user