diff --git a/.github/workflows/all_green_check.yml b/.github/workflows/all_green_check.yml new file mode 100644 index 00000000000..f477281545b --- /dev/null +++ b/.github/workflows/all_green_check.yml @@ -0,0 +1,45 @@ +--- +name: all_green + +concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + +on: # yamllint disable-line rule:truthy + pull_request: + types: + - opened + - reopened + - labeled + - unlabeled + - synchronize + branches: + - main + - 'stable-*' + tags: + - '*' + +jobs: + changelog: + uses: ./.github/workflows/changelog.yml # use the callable changelog job to run tests + linters: + uses: ./.github/workflows/linters.yml # use the callable linters job to run tests + sanity: + uses: ./.github/workflows/sanity.yml # use the callable sanity job to run tests + units: + uses: ./.github/workflows/units.yml # use the callable units job to run tests + all_green: + if: ${{ always() }} + needs: + - changelog-and-linters + - sanity + - units + runs-on: ubuntu-latest + steps: + - run: >- + python -c "assert set([ + '${{ needs.changelog.result }}', + '${{ needs.sanity.result }}', + '${{ needs.linters.result }}', + '${{ needs.units.result }}' + ]) == {'success'}" diff --git a/.github/workflows/ansible-bot.yml b/.github/workflows/ansible-bot.yml index 23da46607f7..347abc738f7 100644 --- a/.github/workflows/ansible-bot.yml +++ b/.github/workflows/ansible-bot.yml @@ -14,4 +14,4 @@ jobs: steps: - uses: actions-ecosystem/action-add-labels@v1 with: - labels: needs_triage \ No newline at end of file + labels: needs_triage diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 00000000000..e4a6fd3c654 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,17 @@ +--- +name: black + +concurrency: + group: '${{ github.workflow }} @ ${{ github.sha }}' + cancel-in-progress: true + +on: + push: + branches: + - main + - 'stable-*' + pull_request_target: + +jobs: + format: + uses: abikouo/github_actions/.github/workflows/black.yml@automate_changes_a diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 00000000000..156ed40da81 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,8 @@ +--- +name: changelog + +on: [workflow_call] # allow this workflow to be called from other workflows + +jobs: + changelog: + uses: ansible-network/github_actions/.github/workflows/changelog.yml@main diff --git a/.github/workflows/changelog_and_linters.yml b/.github/workflows/changelog_and_linters.yml new file mode 100644 index 00000000000..e6a3e3d1898 --- /dev/null +++ b/.github/workflows/changelog_and_linters.yml @@ -0,0 +1,10 @@ +--- +name: changelog and linters + +on: [workflow_call] # allow this workflow to be called from other workflows + +jobs: + changelog: + uses: ansible-network/github_actions/.github/workflows/changelog.yml@main + linters: + uses: abikouo/github_actions/.github/workflows/tox-linters.yml@tox_linters diff --git a/.github/workflows/darker-pr.yml b/.github/workflows/darker-pr.yml deleted file mode 100644 index df5d71f827a..00000000000 --- a/.github/workflows/darker-pr.yml +++ /dev/null @@ -1,50 +0,0 @@ ---- -name: 'Python formatting linter (Darker / Black)' - -on: - workflow_dispatch: - pull_request: - branches: - - main - -permissions: - contents: read - pull-requests: read - -# This allows a subsequently queued workflow run to interrupt previous runs -concurrency: - group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' - cancel-in-progress: true - -jobs: - check-darker: - runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }} - steps: - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: ${{ inputs.python }} - - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - - name: Install darker - shell: bash - run: | - pip install darker - - - name: Rebase against current base - shell: bash - run: | - git config user.email "github@example.com" - git config user.name "Git Hub Testing Rebase" - git rebase ${{ github.event.pull_request.base.sha }} - git show -s - - - name: Run darker - shell: bash - run: | - darker --check --diff --color --rev ${{ github.event.pull_request.base.sha }}.. diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml new file mode 100644 index 00000000000..01bc4c9c086 --- /dev/null +++ b/.github/workflows/sanity.yml @@ -0,0 +1,64 @@ +--- +name: sanity tests + +on: [workflow_call] # allow this workflow to be called from other workflows + +jobs: + sanity: + uses: ansible-network/github_actions/.github/workflows/sanity.yml@main + with: + matrix_include: "[]" + matrix_exclude: >- + [ + { + "ansible-version": "stable-2.9" + }, + { + "ansible-version": "stable-2.12", + "python-version": "3.7" + }, + { + "ansible-version": "stable-2.12", + "python-version": "3.11" + }, + { + "ansible-version": "stable-2.13", + "python-version": "3.7" + }, + { + "ansible-version": "stable-2.13", + "python-version": "3.11" + }, + { + "ansible-version": "stable-2.14", + "python-version": "3.7" + }, + { + "ansible-version": "stable-2.14", + "python-version": "3.8" + }, + { + "ansible-version": "stable-2.15", + "python-version": "3.7" + }, + { + "ansible-version": "stable-2.15", + "python-version": "3.8" + }, + { + "ansible-version": "milestone", + "python-version": "3.7" + }, + { + "ansible-version": "milestone", + "python-version": "3.8" + }, + { + "ansible-version": "devel", + "python-version": "3.7" + }, + { + "ansible-version": "devel", + "python-version": "3.8" + } + ] diff --git a/.github/workflows/units.yml b/.github/workflows/units.yml new file mode 100644 index 00000000000..b55028a08df --- /dev/null +++ b/.github/workflows/units.yml @@ -0,0 +1,64 @@ +--- +name: unit tests + +on: [workflow_call] # allow this workflow to be called from other workflows + +jobs: + unit-source: + uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main + with: + matrix_exclude: >- + [ + { + "python-version": "3.11" + }, + { + "ansible-version": "stable-2.12", + "python-version": "3.7" + }, + { + "ansible-version": "stable-2.13", + "python-version": "3.7" + }, + { + "ansible-version": "stable-2.12", + "python-version": "3.8" + }, + { + "ansible-version": "stable-2.13", + "python-version": "3.8" + }, + { + "ansible-version": "stable-2.14", + "python-version": "3.7" + }, + { + "ansible-version": "stable-2.14", + "python-version": "3.8" + }, + { + "ansible-version": "stable-2.15", + "python-version": "3.7" + }, + { + "ansible-version": "stable-2.15", + "python-version": "3.8" + }, + { + "ansible-version": "milestone", + "python-version": "3.7" + }, + { + "ansible-version": "milestone", + "python-version": "3.8" + }, + { + "ansible-version": "devel", + "python-version": "3.7" + }, + { + "ansible-version": "devel", + "python-version": "3.8" + } + ] + collection_pre_install: '' diff --git a/.github/workflows/update-variables.yml b/.github/workflows/update-variables.yml index 4c9103bed20..339d76aad0f 100644 --- a/.github/workflows/update-variables.yml +++ b/.github/workflows/update-variables.yml @@ -14,4 +14,4 @@ on: jobs: update-variables: - uses: abikouo/github_actions/.github/workflows/update_aws_variables.yml@automate_aws_user_agent_variable \ No newline at end of file + uses: abikouo/github_actions/.github/workflows/update_aws_variables.yml@automate_aws_user_agent_variable diff --git a/tox.ini b/tox.ini index deba4740bd9..13fba5e6b0b 100644 --- a/tox.ini +++ b/tox.ini @@ -24,6 +24,31 @@ commands = coverage erase description = Generate a HTML complexity report in the complexity directory deps = # See: https://github.com/lordmauve/flake8-html/issues/30 - flake8>=3.3.0,<5.0.0' + flake8>=3.3.0,<5.0.0 flake8-html commands = -flake8 --select C90 --max-complexity 10 --format=html --htmldir={posargs:complexity} plugins + +[testenv:black_check] +deps = + black >=23.0, <24.0 + +commands = + black -v --check --diff {toxinidir}/plugins {toxinidir}/tests + +[testenv:black] +deps = + {[testenv:black_check]deps} + +commands = + black -v {posargs:{toxinidir}/plugins {toxinidir}/tests} + +[testenv:linters] +deps = + yamllint + flake8 + {[testenv:black_check]deps} + +commands = + {[testenv:black_check]commands} + yamllint -s {toxinidir} + flake8 {toxinidir}