Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Sanity failures in stable-2.4 #674

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
profile: production

exclude_paths:
- tests/integration
- tests/sanity
21 changes: 21 additions & 0 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Changelog
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
types:
- opened
- reopened
- labeled
- unlabeled
- synchronize
branches:
- main
- stable-*

jobs:
changelog:
uses: ansible-network/github_actions/.github/workflows/changelog.yml@main
14 changes: 14 additions & 0 deletions .github/workflows/galaxy-import.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: galaxy-import
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*

jobs:
galaxy_importer:
uses: ansible-network/github_actions/.github/workflows/galaxy_importer.yml@main
144 changes: 144 additions & 0 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
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.splitter.outputs.test_targets }}
test_targets_json: ${{ steps.splitter.outputs.test_targets_json }}
test_jobs: ${{ steps.splitter.outputs.test_jobs }}
steps:
- name: Checkout the collection repository
uses: actions/checkout@v3
with:
path: ${{ env.source_dir }}
fetch-depth: "0"

- 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: Display splitter output
run: |
echo "test_targets=${{ steps.splitter.outputs.test_targets }}"
echo "test_targets_json=${{ steps.splitter.outputs.test_targets_json }}"
echo "test_jobs=${{ steps.splitter.outputs.test_jobs }}"
shell: bash
integration:
runs-on: ubuntu-latest
timeout-minutes: 60
needs:
- splitter
if: ${{ needs.splitter.outputs.test_targets != '' }}
env:
source: "./source"
cloud_common: "./cloudcommon"
ansible_posix: "./ansible_posix"
GomathiselviS marked this conversation as resolved.
Show resolved Hide resolved
strategy:
fail-fast: false
matrix:
ansible-version:
- milestone
python-version:
- "3.12"
enable-turbo-mode:
- true
- false
workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }}
name: "integration-py${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}"
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_json }}
WORKFLOW_ID: ${{ matrix.workflow-id }}

- name: Display ansible test targets
run: |
echo "ansible_test_targets -> ${{ steps.read-targets.outputs.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
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: install cloud.common collection
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: create kubernetes cluster
uses: helm/[email protected]

- 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 }}
24 changes: 24 additions & 0 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Linters
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*
tags:
- '*'

jobs:
linters:
uses: ansible-network/github_actions/.github/workflows/tox-linters.yml@main
ansible-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run ansible-lint
uses: ansible/[email protected]
15 changes: 15 additions & 0 deletions .github/workflows/sanity-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Sanity tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*

jobs:
sanity:
uses: ansible-network/github_actions/.github/workflows/sanity.yml@main
14 changes: 14 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Unit tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*

jobs:
unit-source:
uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main
4 changes: 4 additions & 0 deletions changelogs/fragments/fix_sanity_errors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
trivial:
- Fix sanity validate-modules and yamllint failures.
- Add GH workflows.
40 changes: 39 additions & 1 deletion plugins/filter/k8s.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,50 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# SPDX-License-Identifier: GPL-3.0-or-later
GomathiselviS marked this conversation as resolved.
Show resolved Hide resolved

from __future__ import absolute_import, division, print_function

__metaclass__ = type


DOCUMENTATION = r"""

name: k8s_config_resource_name
short_description: Generate resource name for the given resource of type ConfigMap, Secret
description:
- Generate resource name for the given resource of type ConfigMap, Secret.
- Resource must have a C(metadata.name) key to generate a resource name
options:
_input:
description:
- A valid YAML definition for a ConfigMap or a Secret.
type: dict
required: true
author:
- ansible cloud team

"""

EXAMPLES = r"""
# Dump generated name for a configmap into a variable
- set_fact:

Check failure on line 30 in plugins/filter/k8s.py

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[indentation]

Wrong indentation: expected 0 but found 2
generated_name: '{{ definition | kubernetes.core.k8s_config_resource_name }}'
vars:
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: myconfigmap
namespace: mynamespace
"""

RETURN = r"""
_value:
description: Generated resource name.
type: str
"""


from ansible.errors import AnsibleFilterError
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
generate_hash,
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/helm_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- If set to C(uninstalling), show releases that are currently being uninstalled.
type: list
elements: str
default: []
version_added: "2.3.0"
get_all_values:
description:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/helm_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
required: false
type: list
elements: str
default: []
version_added: 2.4.0
values_files:
description:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/k8s_drain.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
description:
- Specify options to delete pods.
- This option has effect only when C(state) is set to I(drain).
default: {}
suboptions:
terminate_grace_period:
description:
Expand Down Expand Up @@ -103,7 +104,7 @@
state: drain
name: foo
delete_options:
terminate_grace_period: 900

Check failure on line 107 in plugins/modules/k8s_drain.py

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[indentation]

Wrong indentation: expected 6 but found 8

- name: Mark node "foo" as schedulable.
kubernetes.core.k8s_drain:
Expand All @@ -114,7 +115,7 @@
kubernetes.core.k8s_drain:
state: cordon
name: foo

Check failure on line 118 in plugins/modules/k8s_drain.py

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[empty-lines]

Too many blank lines (1 > 0)
"""

RETURN = r"""
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/k8s_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@
description: List of label selectors to use to filter results
type: list
elements: str
default: []
field_selectors:
description: List of field selectors to use to filter results
type: list
elements: str
default: []

extends_documentation_fragment:
- kubernetes.core.k8s_auth_options
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/k8s_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- Only one of I(name) or I(label_selectors) may be provided.
type: list
elements: str
default: []
container:
description:
- Use to specify the container within a pod to grab the log from.
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/k8s_rollback.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
description: List of label selectors to use to filter results.
type: list
elements: str
default: []
field_selectors:
description: List of field selectors to use to filter results.
type: list
elements: str
default: []
extends_documentation_fragment:
- kubernetes.core.k8s_auth_options
- kubernetes.core.k8s_name_options
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/k8s_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
description: List of label selectors to use to filter results.
type: list
elements: str
default: []
version_added: 2.0.0
continue_on_error:
description:
Expand Down
2 changes: 2 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ pytest
pytest-xdist
pytest-mock
pytest-forked
virtualenv
pytest-ansible
12 changes: 3 additions & 9 deletions tests/sanity/ignore-2.14.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
plugins/module_utils/client/discovery.py import-3.6!skip
plugins/module_utils/client/discovery.py import-3.7!skip
plugins/module_utils/client/discovery.py import-3.8!skip
plugins/module_utils/client/discovery.py import-3.9!skip
plugins/module_utils/client/discovery.py import-3.10!skip
plugins/module_utils/client/resource.py import-3.6!skip
plugins/module_utils/client/resource.py import-3.7!skip
plugins/module_utils/client/resource.py import-3.8!skip
plugins/module_utils/client/discovery.py import-3.11!skip
plugins/module_utils/client/resource.py import-3.9!skip
plugins/module_utils/client/resource.py import-3.10!skip
plugins/module_utils/k8sdynamicclient.py import-3.6!skip
plugins/module_utils/k8sdynamicclient.py import-3.7!skip
plugins/module_utils/k8sdynamicclient.py import-3.8!skip
plugins/module_utils/client/resource.py import-3.11!skip
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
Expand Down
Loading
Loading