diff --git a/.github/workflows/all_green_ckeck.yml b/.github/workflows/all_green_ckeck.yml new file mode 100644 index 00000000000..2d80af9c4a7 --- /dev/null +++ b/.github/workflows/all_green_ckeck.yml @@ -0,0 +1,44 @@ +--- +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-and-linters: + uses: ./.github/workflows/changelog_and_linters.yml # use the callable changelog_and_linters 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-and-linters.result }}', + '${{ needs.sanity.result }}', + '${{ needs.units.result }}' + ]) == {'success'}" diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 00000000000..a79e3beba1c --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,55 @@ +--- +name: 'Python formatting linter (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-black: + runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }} + steps: + - name: Checkout the collection repository + uses: actions/checkout@v3 + with: + path: ${{ env.source_directory }} + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: "0" + + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: ${{ inputs.python }} + + - name: Read collection metadata from galaxy.yml + id: identify + uses: ansible-network/github_actions/.github/actions/identify_collection@main + with: + source_path: ${{ env.source_directory }} + + - name: Build and install the collection + uses: ansible-network/github_actions/.github/actions/build_install_collection@main + with: + install_python_dependencies: false + source_path: ${{ env.source_directory }} + collection_path: ${{ steps.identify.outputs.collection_path }} + tar_file: ${{ steps.identify.outputs.tar_file }} + + - name: Install black + run: pip install black + + - name: Run black + run: | + black -v --check --diff . + working-directory: ${{ steps.identify.outputs.collection_path }} diff --git a/.github/workflows/changelog_and_linters.yml b/.github/workflows/changelog_and_linters.yml new file mode 100644 index 00000000000..e3f8a5c400d --- /dev/null +++ b/.github/workflows/changelog_and_linters.yml @@ -0,0 +1,10 @@ +--- +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 + 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 new file mode 100644 index 00000000000..88e4fa58a84 --- /dev/null +++ b/tox.ini @@ -0,0 +1,28 @@ +[tox] +minversion = 1.4.2 +skipsdist = True + +[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}