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

Add ansible lint checker in PR mandatory checks #459

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
🐍 python:
- "**/*.py"
- "*.py"
Expand All @@ -7,7 +8,7 @@
- "*.md"

⚙ ci:
- ".github/**"
- .github/**

⚙ build:
- "Makefile"
- Makefile
22 changes: 22 additions & 0 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: ansible-lint
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
name: Ansible Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.x (latest)
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Run ansible-lint
uses: ansible/ansible-lint@main
5 changes: 3 additions & 2 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Black
on:
push:
Expand All @@ -15,8 +16,8 @@ jobs:
- name: Set up Python 3.x (latest)
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: 3.x
- name: black
uses: psf/black@stable
with:
version: "22.6.0"
version: 22.6.0
5 changes: 3 additions & 2 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Flake8
on:
push:
Expand All @@ -15,8 +16,8 @@ jobs:
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
python-version: "3.9"
- name: Run Flake8
run: |
pip install -r requirements.txt
flake8
flake8
5 changes: 3 additions & 2 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Isort
on:
push:
Expand All @@ -15,5 +16,5 @@ jobs:
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: '3.x'
- uses: isort/isort-action@master
python-version: 3.x
- uses: isort/isort-action@master
47 changes: 24 additions & 23 deletions .github/workflows/ok-to-test-command.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Integration Test cases
on:
pull_request:
Expand All @@ -10,14 +11,14 @@ jobs:
strategy:
max-parallel: 1
matrix:
python-version: ['3.9']
python-version: ["3.9"]
if: github.event_name == 'repository_dispatch'
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."

- uses: actions/checkout@v2
with:
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
ref: refs/pull/${{ github.event.client_payload.pull_request.number }}/merge
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -47,13 +48,13 @@ jobs:
args="${{ github.event.client_payload.slash_command.args.all }}"
flag=""
if [ "$args" = "allow-disabled" ]
then
then
flag="--allow-disabled"
fi
echo '${{ secrets.FOUNDATION_CONFIG }}' > tests/integration/targets/prepare_foundation_env/vars/main.yml
echo '${{ secrets.FC_CONFIG }}' > tests/integration/targets/prepare_fc_env/vars/main.yml
echo '${{ secrets.PC_CONFIG }}' > tests/integration/targets/prepare_env/vars/main.yml
echo '${{ secrets.NDB_CONFIG }}' > tests/integration/targets/prepare_ndb_env/vars/main.yml
echo '${{ secrets.PC_CONFIG }}' > tests/integration/targets/prepare_env/vars/main.yml
echo '${{ secrets.NDB_CONFIG }}' > tests/integration/targets/prepare_ndb_env/vars/main.yml
ansible-playbook tests/integration/targets/prepare_env/tasks/prepare_env.yml
ansible-playbook tests/integration/targets/prepare_ndb_env/tasks/prepare_env.yml
ansible-playbook tests/integration/targets/prepare_fc_env/tasks/prepare_fc_env.yml
Expand All @@ -65,23 +66,23 @@ jobs:

- name: Code Coverage Check
if: ${{ always() }}
run: |
cd /home/${USER}/.ansible/collections/ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
ansible-test coverage html
sshpass -p '${{ secrets.FILER_PASSWORD }}' scp -r tests/output ${{ secrets.FILER_LOCATION }}
echo "Code coverage: Checking if code coverage is above threshold..."
export COVERAGE_THRESHOLD=70
echo "Threshold: $COVERAGE_THRESHOLD %"
totalCoverage=`grep TOTAL coverage.txt | awk '{print $6}' | sed 's/%//'`
echo "TOTAL_COVERAGE=${totalCoverage}" >> $GITHUB_ENV
echo "Current integration test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $COVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "Coverage passed"
else
echo "Current integration test coverage is below threshold. Please add more integration tests or adjust threshold to a lower value."
echo "Coverage check failed"
exit 1
fi
run: |
cd /home/${USER}/.ansible/collections/ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
ansible-test coverage html
sshpass -p '${{ secrets.FILER_PASSWORD }}' scp -r tests/output ${{ secrets.FILER_LOCATION }}
echo "Code coverage: Checking if code coverage is above threshold..."
export COVERAGE_THRESHOLD=70
echo "Threshold: $COVERAGE_THRESHOLD %"
totalCoverage=`grep TOTAL coverage.txt | awk '{print $6}' | sed 's/%//'`
echo "TOTAL_COVERAGE=${totalCoverage}" >> $GITHUB_ENV
echo "Current integration test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $COVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "Coverage passed"
else
echo "Current integration test coverage is below threshold. Please add more integration tests or adjust threshold to a lower value."
echo "Coverage check failed"
exit 1
fi

- run: echo "🍏 This job's status is ${{ job.status }}."

Expand All @@ -105,7 +106,7 @@ jobs:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ok-to-test.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: 'Ok-To-Test'
---
name: Ok-To-Test

on: [issue_comment]

jobs:
test:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request }}
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}. And Github Token is ${{ secrets.GITHUB_TOKEN }}"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- run: echo "Your Github Token is ${{ secrets.GITHUB_TOKEN }}"

- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v2
with:
token: ${{ secrets.PAT }}
commands: ok-to-test
permission: write
- run: echo "🍏 This job's status is ${{ job.status }}."
- run: echo "🍏 This job's status is ${{ job.status }}."
5 changes: 3 additions & 2 deletions .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
name: PR Labeler

on:
- pull_request
- pull_request

jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
repo-token: ${{ secrets.GITHUB_TOKEN }}
39 changes: 20 additions & 19 deletions .github/workflows/unit_testing.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Run compile and tests

on:
Expand All @@ -9,10 +10,10 @@ on:
- main
jobs:
sanity:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ['3.9']
python-version: ["3.9"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -38,10 +39,10 @@ jobs:
cd /home/${USER}/.ansible/collections/ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
ansible-test sanity --docker default --python ${{ matrix.python-version }} -v
unit_testing:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9']
python-version: ["3.9"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -68,18 +69,18 @@ jobs:
ansible-test units --docker default --python ${{ matrix.python-version }} --coverage -v
ansible-test coverage report --include */plugins/* --omit */utils.py,_fetch_url* > coverage.txt
- name: Code Coverage Check
run: |
cd /home/${USER}/.ansible/collections/ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
echo "Code coverage: Checking if code coverage is above threshold..."
export TESTCOV_THRESHOLD=55
echo "Threshold: $TESTCOV_THRESHOLD %"
totalCoverage=`grep TOTAL coverage.txt | awk '{print $6}' | sed 's/%//'`
echo "TOTAL_COVERAGE=${totalCoverage}" >> $GITHUB_ENV
echo "Current test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $TESTCOV_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "Coverage passed"
else
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
echo "Coverage check failed"
exit 1
fi
run: |
cd /home/${USER}/.ansible/collections/ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
echo "Code coverage: Checking if code coverage is above threshold..."
export TESTCOV_THRESHOLD=55
echo "Threshold: $TESTCOV_THRESHOLD %"
totalCoverage=`grep TOTAL coverage.txt | awk '{print $6}' | sed 's/%//'`
echo "TOTAL_COVERAGE=${totalCoverage}" >> $GITHUB_ENV
echo "Current test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $TESTCOV_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "Coverage passed"
else
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
echo "Coverage check failed"
exit 1
fi
35 changes: 18 additions & 17 deletions changelogs/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
changelog_filename_template: ../CHANGELOG.rst
changelog_filename_version_depth: 0
changes_file: changelog.yaml
Expand All @@ -11,21 +12,21 @@ prelude_section_name: release_summary
prelude_section_title: Release Summary
sanitize_changelog: true
sections:
- - major_changes
- Major Changes
- - minor_changes
- Minor Changes
- - breaking_changes
- Breaking Changes / Porting Guide
- - deprecated_features
- Deprecated Features
- - removed_features
- Removed Features (previously deprecated)
- - security_fixes
- Security Fixes
- - bugfixes
- Bugfixes
- - known_issues
- Known Issues
- - major_changes
- Major Changes
- - minor_changes
- Minor Changes
- - breaking_changes
- Breaking Changes / Porting Guide
- - deprecated_features
- Deprecated Features
- - removed_features
- Removed Features (previously deprecated)
- - security_fixes
- Security Fixes
- - bugfixes
- Bugfixes
- - known_issues
- Known Issues
title: Nutanix.Ncp
trivial_section_name: trivial
trivial_section_name: trivial
7 changes: 3 additions & 4 deletions examples/acp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
validate_certs: false

tasks:

- name: Create ACP with all specfactions
ntnx_acps:
validate_certs: False
nutanix.ncp.ntnx_acps:
validate_certs: false
state: present
nutanix_host: "{{ IP }}"
nutanix_username: "{{ username }}"
Expand All @@ -41,7 +40,7 @@
collection: ALL

- name: Delete ACP
ntnx_acps:
nutanix.ncp.ntnx_acps:
state: absent
acp_uuid: "{{ acp_uuid }}"
register: result
13 changes: 6 additions & 7 deletions examples/acp_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
validate_certs: false

tasks:

- name: List ACPs using ascending, sorting and name filter
ntnx_floating_ips_info:
nutanix.ncp.ntnx_floating_ips_info:
filter:
name: "{{ acp_name }}"
kind: access_control_policy
sort_order: "ASCENDING"
sort_attribute: "name"
sort_order: ASCENDING
sort_attribute: name
register: result
ignore_errors: True
ignore_errors: true

- name: List ACPs using length and offset
ntnx_floating_ips_info:
nutanix.ncp.ntnx_floating_ips_info:
length: 3
offset: 0
register: result
ignore_errors: True
ignore_errors: true
Loading
Loading