From 7c318a6d446a6734d00a0f7c25bc6772095f8eff Mon Sep 17 00:00:00 2001 From: rohitthakur2590 Date: Thu, 19 Oct 2023 18:23:46 +0530 Subject: [PATCH 1/2] Maintenance, workfloe and lint changes Signed-off-by: rohitthakur2590 --- .github/CODEOWNERS | 0 .github/dependabot.yml | 9 ++++++++ .github/release-drafter.yml | 3 +++ .github/workflows/ack.yml | 15 +++++++++++++ .github/workflows/codecoverage.yml | 15 +++++++++++++ .github/workflows/lint.yml | 12 ++++++++++ .github/workflows/push.yml | 27 +++++++++++++++++++++++ .github/workflows/release.yml | 14 ++++++++++++ .github/workflows/{test.yml => tests.yml} | 19 ++++++++-------- .gitignore | 7 ++++++ .pre-commit-config.yaml | 12 ++++++---- 11 files changed, 120 insertions(+), 13 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/ack.yml create mode 100644 .github/workflows/codecoverage.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/push.yml create mode 100644 .github/workflows/release.yml rename .github/workflows/{test.yml => tests.yml} (77%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..e69de29b diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..5b32d4c1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily + labels: + - "skip-changelog" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..e3e5966e --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,3 @@ +--- +# see https://github.com/ansible-community/devtools +_extends: ansible-community/devtools diff --git a/.github/workflows/ack.yml b/.github/workflows/ack.yml new file mode 100644 index 00000000..fda595dc --- /dev/null +++ b/.github/workflows/ack.yml @@ -0,0 +1,15 @@ +--- +# See https://github.com/ansible-community/devtools/blob/main/.github/workflows/ack.yml +name: ack + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +on: # yamllint disable-line rule:truthy + pull_request_target: + types: [opened, labeled, unlabeled, synchronize] + +jobs: + ack: + uses: ansible/devtools/.github/workflows/ack.yml@main diff --git a/.github/workflows/codecoverage.yml b/.github/workflows/codecoverage.yml new file mode 100644 index 00000000..c2a7ad60 --- /dev/null +++ b/.github/workflows/codecoverage.yml @@ -0,0 +1,15 @@ +--- +name: code_coverage + +on: # yamllint disable-line rule:truthy + push: + pull_request: + branches: [ main ] + +jobs: + codecoverage: + uses: ansible-network/github_actions/.github/workflows/coverage_network_devices.yml@main + with: + collection_pre_install: >- + git+https://github.com/ansible-collections/ansible.utils.git + git+https://github.com/ansible-collections/ansible.netcommon.git diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..853e4b69 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,12 @@ +--- +name: ansible-lint +on: # yamllint disable-line rule:truthy + pull_request: + branches: ["main"] +jobs: + build: + name: Ansible Lint + runs-on: ubuntu-latest + steps: + - name: Run ansible-lint + uses: ansible/ansible-lint@main diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 00000000..e82df35c --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,27 @@ +--- +# push workflow is shared and expected to perform actions after a merge happens +# on a maintenance branch (default or release). For example updating the +# draft release-notes. +# based on great work from +# https://github.com/T-Systems-MMS/ansible-collection-icinga-director +name: push + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +on: # yamllint disable-line rule:truthy + workflow_dispatch: + +env: + NAMESPACE: cisco + COLLECTION_NAME: asa + ANSIBLE_COLLECTIONS_PATHS: ./ + +jobs: + update_release_draft: + uses: ansible/devtools/.github/workflows/push_network.yml@main + with: + repo: ansible-collections/cisco.asa + secrets: + BOT_PAT: ${{ secrets.BOT_PAT }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..eb04259d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,14 @@ +--- +name: release +on: # yamllint disable-line rule:truthy + release: + types: [published] + +jobs: + release: + uses: ansible/devtools/.github/workflows/release_collection.yml@main + with: + environment: release + secrets: + ah_token: ${{ secrets.AH_TOKEN }} + ansible_galaxy_api_key: ${{ secrets.ANSIBLE_GALAXY_API_KEY }} diff --git a/.github/workflows/test.yml b/.github/workflows/tests.yml similarity index 77% rename from .github/workflows/test.yml rename to .github/workflows/tests.yml index e77967b3..0fb4cc0c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/tests.yml @@ -1,20 +1,22 @@ --- -name: Test collection +name: test_collection concurrency: - group: ${{ github.head_ref }} + group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true on: # yamllint disable-line rule:truthy pull_request: branches: [main] workflow_dispatch: + schedule: + - cron: '0 0 * * *' + jobs: - ansible-lint: - uses: ansible-network/github_actions/.github/workflows/ansible-lint.yml@main changelog: uses: ansible-network/github_actions/.github/workflows/changelog.yml@main + if: github.event_name != 'schedule' sanity: uses: ansible-network/github_actions/.github/workflows/sanity.yml@main unit-galaxy: @@ -26,9 +28,8 @@ jobs: git+https://github.com/ansible-collections/ansible.utils.git git+https://github.com/ansible-collections/ansible.netcommon.git all_green: - if: ${{ always() }} + if: ${{ always() && (github.event_name != 'schedule') }} needs: - - ansible-lint - changelog - sanity - unit-galaxy @@ -36,10 +37,10 @@ jobs: runs-on: ubuntu-latest steps: - run: >- - python -c "assert set([ - '${{ needs.ansible-lint.result }}', + python -c "assert 'failure' not in + set([ '${{ needs.changelog.result }}', '${{ needs.sanity.result }}', '${{ needs.unit-galaxy.result }}', '${{ needs.unit-source.result }}' - ]) == {'success'}" + ])" diff --git a/.gitignore b/.gitignore index 894a44cc..45d94ba4 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,10 @@ venv.bak/ # mypy .mypy_cache/ + +# ide +*.code-workspace +.vscode/ +.DS_Store + +changelogs/.plugin-cache.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf907dc4..8fdbd4b3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: - repo: https://github.com/ansible-network/collection_prep rev: 1.1.1 hooks: - - id: autoversion + # - id: autoversion # removed as being handled by GHA push and release drafter - id: update-docs - repo: https://github.com/pre-commit/pre-commit-hooks @@ -18,14 +18,17 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/add-trailing-comma - rev: v2.5.1 + rev: v3.1.0 hooks: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.9-for-vscode" + rev: "v3.0.3" hooks: - id: prettier + entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" + pass_filenames: false + args: [] additional_dependencies: - prettier - prettier-plugin-toml @@ -35,8 +38,9 @@ repos: hooks: - id: isort name: Sort import statements using isort + args: ["--filter-files"] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.9.1 hooks: - id: black From 96c24fa2afc4c0eaed21c71a224db9fa985a45ba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:54:55 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- plugins/module_utils/network/asa/rm_templates/ogs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/network/asa/rm_templates/ogs.py b/plugins/module_utils/network/asa/rm_templates/ogs.py index 26a03247..d79d3dd1 100644 --- a/plugins/module_utils/network/asa/rm_templates/ogs.py +++ b/plugins/module_utils/network/asa/rm_templates/ogs.py @@ -93,7 +93,7 @@ def _tmplt_services_object(config_data): if config_data["services_object"].get("source_port"): if config_data["services_object"]["source_port"].get("range"): cmd += " source range {start} {end}".format( - **config_data["services_object"]["source_port"]["range"] + **config_data["services_object"]["source_port"]["range"], ) else: key = list(config_data["services_object"]["source_port"])[0] @@ -104,7 +104,7 @@ def _tmplt_services_object(config_data): if config_data["services_object"].get("destination_port"): if config_data["services_object"]["destination_port"].get("range"): cmd += " destination range {start} {end}".format( - **config_data["services_object"]["destination_port"]["range"] + **config_data["services_object"]["destination_port"]["range"], ) else: key = list(config_data["services_object"]["destination_port"])[0]