From e785f1faa99a73d43863429ccdccf62f5268727f Mon Sep 17 00:00:00 2001 From: alexanderbazhenoff Date: Tue, 2 Apr 2024 18:11:30 +0300 Subject: [PATCH] fixes --- .github/workflows/ansible_sanity_testing.yml | 144 ++---------------- .github/workflows/sanity_testing_workflow.yml | 133 ++++++++++++++++ meta/runtime.yml | 2 +- 3 files changed, 148 insertions(+), 131 deletions(-) create mode 100644 .github/workflows/sanity_testing_workflow.yml diff --git a/.github/workflows/ansible_sanity_testing.yml b/.github/workflows/ansible_sanity_testing.yml index a6c89cb..6eb9ed8 100644 --- a/.github/workflows/ansible_sanity_testing.yml +++ b/.github/workflows/ansible_sanity_testing.yml @@ -1,133 +1,17 @@ --- -name: Sanity tests -on: - workflow_call: - inputs: - collection_pre_install: - required: false - type: string - default: "" - matrix_exclude: -# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix -# 2.14 supports Python 3.9-3.11 -# 2.15 supports Python 3.9-3.11 -# 2.16 supports Python 3.10-3.12 -# https://docs.ansible.com/ansible/devel/roadmap/ROADMAP_2_17.html -# milestone is 2.17 until after 2.17 branches from devel -# devel is 2.17 until 2024-04-01 -# remove 3.12/milestone from matrix_exclude when milestone is next forwarded - default: >- - [ - { - "ansible-version": "stable-2.14", - "python-version": "3.12" - }, - { - "ansible-version": "stable-2.15", - "python-version": "3.12" - }, - { - "ansible-version": "stable-2.16", - "python-version": "3.9" - }, - { - "ansible-version": "milestone", - "python-version": "3.9" - }, - { - "ansible-version": "milestone", - "python-version": "3.12" - }, - { - "ansible-version": "devel", - "python-version": "3.9" - } - ] - required: false - type: string - matrix_include: - default: >- - [] - required: false - type: string - unstable: - default: >- - [ - "devel", - ] - required: false - type: string +name: Ansible Sanity Teststing +on: # yamllint disable-line rule:truthy + push: null + pull_request: + branches: + - main + - master +permissions: read-all + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true jobs: - sanity: - env: - PY_COLORS: "1" - source_directory: "./source" - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - ansible-version: - - stable-2.14 - - stable-2.15 - - stable-2.16 - - milestone - - devel - python-version: - - "3.9" - - "3.10" - - "3.11" - - "3.12" - exclude: ${{ fromJSON(inputs.matrix_exclude) }} - include: ${{ fromJSON(inputs.matrix_include) }} - runs-on: ${{ matrix.os }} - continue-on-error: ${{ contains(fromJSON(inputs.unstable), matrix.ansible-version) }} - - name: "py${{ matrix.python-version }} / ${{ matrix.os }} / ${{ matrix.ansible-version }}" - steps: - - name: Checkout the collection repository - uses: ansible-network/github_actions/.github/actions/checkout_dependency@main - with: - path: ${{ env.source_directory }} - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: "0" - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - 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 - - - name: Pre install collections dependencies first so the collection install does not - run: ansible-galaxy collection install --pre ${{ inputs.collection_pre_install }} -p /home/runner/collections/ - if: ${{ inputs.collection_pre_install != '' && matrix.ansible-version != 'stable-2.9' }} - - - 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 }} - ansible_version: ${{ matrix.ansible-version }} - - - name: Print the ansible version - run: ansible --version - - - name: Print the python dependencies - run: python3 -m pip list - - - name: Run sanity tests - run: ansible-test sanity --requirements --color --python ${{ matrix.python-version }} - working-directory: ${{ steps.identify.outputs.collection_path }} + sanity_testing: + uses: alexanderbazhenoff/ansible-collection-linux/.github/workflows/sanity_testing_workflow.yml@1_1_10 diff --git a/.github/workflows/sanity_testing_workflow.yml b/.github/workflows/sanity_testing_workflow.yml new file mode 100644 index 0000000..96b4e45 --- /dev/null +++ b/.github/workflows/sanity_testing_workflow.yml @@ -0,0 +1,133 @@ +--- +# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix +# 2.14 supports Python 3.9-3.11 +# 2.15 supports Python 3.9-3.11 +# 2.16 supports Python 3.10-3.12 +# https://docs.ansible.com/ansible/devel/roadmap/ROADMAP_2_17.html +# milestone is 2.17 until after 2.17 branches from devel +# devel is 2.17 until 2024-04-01 +# remove 3.12/milestone from matrix_exclude when milestone is next forwarded +name: Sanity tests +on: + workflow_call: + inputs: + collection_pre_install: + required: false + type: string + default: "" + matrix_exclude: + default: >- + [ + { + "ansible-version": "stable-2.14", + "python-version": "3.12" + }, + { + "ansible-version": "stable-2.15", + "python-version": "3.12" + }, + { + "ansible-version": "stable-2.16", + "python-version": "3.9" + }, + { + "ansible-version": "milestone", + "python-version": "3.9" + }, + { + "ansible-version": "milestone", + "python-version": "3.12" + }, + { + "ansible-version": "devel", + "python-version": "3.9" + } + ] + required: false + type: string + matrix_include: + default: >- + [] + required: false + type: string + unstable: + default: >- + [ + "devel", + ] + required: false + type: string + +jobs: + sanity: + env: + PY_COLORS: "1" + source_directory: "./source" + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + ansible-version: + - stable-2.14 + - stable-2.15 + - stable-2.16 + - milestone + - devel + python-version: + - "3.9" + - "3.10" + - "3.11" + - "3.12" + exclude: ${{ fromJSON(inputs.matrix_exclude) }} + include: ${{ fromJSON(inputs.matrix_include) }} + runs-on: ${{ matrix.os }} + continue-on-error: ${{ contains(fromJSON(inputs.unstable), matrix.ansible-version) }} + + name: "py${{ matrix.python-version }} / ${{ matrix.os }} / ${{ matrix.ansible-version }}" + steps: + - name: Checkout the collection repository + uses: ansible-network/github_actions/.github/actions/checkout_dependency@main + with: + path: ${{ env.source_directory }} + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: "0" + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - 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 + + - name: Pre install collections dependencies first so the collection install does not + run: ansible-galaxy collection install --pre ${{ inputs.collection_pre_install }} -p /home/runner/collections/ + if: ${{ inputs.collection_pre_install != '' && matrix.ansible-version != 'stable-2.9' }} + + - 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 }} + ansible_version: ${{ matrix.ansible-version }} + + - name: Print the ansible version + run: ansible --version + + - name: Print the python dependencies + run: python3 -m pip list + + - name: Run sanity tests + run: ansible-test sanity --requirements --color --python ${{ matrix.python-version }} + working-directory: ${{ steps.identify.outputs.collection_path }} diff --git a/meta/runtime.yml b/meta/runtime.yml index a945fab..510f6d9 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,3 +1,3 @@ --- -requires_ansible: '>=2.9.0' \ No newline at end of file +requires_ansible: '>=2.10.0'