diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml deleted file mode 100644 index 26b4b77..0000000 --- a/.github/workflows/ansible-test.yml +++ /dev/null @@ -1,209 +0,0 @@ -# README FIRST -# 1. replace "NAMESPACE/COLLECTION_NAME" with the correct name, ie "community/zabbix" -# 2. If you don't have unit tests remove that section -# 3. If your collection depends on other collections ensure they are installed, see "Install collection dependencies" -# If you need help please ask in #ansible-devel on Freenode IRC - -name: CI -on: -# Run CI against all pushes (direct commits) and Pull Requests -- push -- pull_request - -jobs: - -### -# Sanity tests (REQUIRED) -# -# https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html - - sanity: - name: Sanity (Ⓐ${{ matrix.ansible }}) - strategy: - matrix: - ansible: - # It's important that Sanity is tested against all stable-X.Y branches - # Testing against `devel` may fail as new tests are added. - - stable-2.9 - - stable-2.10 - runs-on: ubuntu-latest - steps: - - # ansible-test requires the collection to be in a directory in the form - # .../ansible_collections/NAMESPACE/COLLECTION_NAME/ - - - name: Check out code - uses: actions/checkout@v2 - with: - path: ansible_collections/ansible/utils - - - name: Set up Python - uses: actions/setup-python@v2 - with: - # it is just required to run that once as "ansible-test sanity" in the docker image - # will run on all python versions it supports. - python-version: 3.8 - - # Install the head of the given branch (devel, stable-2.10) - - name: Install ansible-base (${{ matrix.ansible }}) - run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check - - # run ansible-test sanity inside of Docker. - # The docker container has all the pinned dependencies that are required - # and all python versions ansible supports. - - name: Run sanity tests - run: ansible-test sanity --docker -v --color - working-directory: ./ansible_collections/ansible/utils - -### -# Unit tests (OPTIONAL) -# -# https://docs.ansible.com/ansible/latest/dev_guide/testing_units.html - - units: - runs-on: ubuntu-latest - name: Units (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) - strategy: - # As soon as the first unit test fails, cancel the others to free up the CI queue - fail-fast: true - matrix: - ansible: - - stable-2.9 - - stable-2.10 - python: - - 2.7 - - 3.5 - - 3.6 - - 3.7 - - 3.8 - - 3.9 - exclude: - - ansible: stable-2.9 - python: 3.9 - - steps: - - name: Check out code - uses: actions/checkout@v2 - with: - path: ansible_collections/ansible/utils - - - name: Set up Python ${{ matrix.ansible }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - - name: Install ansible-base (${{ matrix.ansible }}) - run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check - - # OPTIONAL If your unit test requires Python libraries from other collections - # Install them like this - - name: Install collection dependencies - run: ansible-galaxy collection install ansible.utils -p . - - # Run the unit tests - - name: Run unit test - run: ansible-test units -v --color --python ${{ matrix.python }} --docker --coverage - working-directory: ./ansible_collections/ansible/utils - - # ansible-test support producing code coverage date - - name: Generate coverage report - run: ansible-test coverage xml -v --requirements --group-by command --group-by version - working-directory: ./ansible_collections/ansible/utils - - # See the reports at https://codecov.io/gh/ansible_collections/GITHUBORG/REPONAME - - uses: codecov/codecov-action@v1 - with: - fail_ci_if_error: false - -## -# Integration tests (RECOMMENDED) -# https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html -# If the application you are testing is available as a docker container and you want to test -# multiple versions see the following for an example: -# https://github.com/ansible-collections/community.zabbix/tree/master/.github/workflows - - integration: - runs-on: ubuntu-latest - name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}}) - strategy: - fail-fast: false - matrix: - ansible: - - stable-2.9 - - stable-2.10 - python: - - 2.7 - - 3.5 - - 3.6 - - 3.7 - - 3.8 - - 3.9 - exclude: - - ansible: stable-2.9 - python: 3.9 - - steps: - - name: Check out code - uses: actions/checkout@v2 - with: - path: ansible_collections/ansible/utils - - - name: Set up Python ${{ matrix.ansible }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - - name: Install ansible-base (${{ matrix.ansible }}) - run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check - -# - name: Install collection dependencies -# run: | -# python -m pip install --upgrade pip -# pip install -r requirements.txt -# working-directory: ./ansible_collections/ansible/utils - - # OPTIONAL If your integration test requires Python libraries or modules from other collections - # Install them like this - - name: Install collection dependencies - run: ansible-galaxy collection install ansible.utils -p . - - # Run the integration tests - - name: Run integration test - run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker --coverage - working-directory: ./ansible_collections/ansible/utils - - # ansible-test support producing code coverage date - - name: Generate coverage report - run: ansible-test coverage xml -v --requirements --group-by command --group-by version - working-directory: ./ansible_collections/ansible/utils - - # See the reports at https://codecov.io/gh/ansible_collections/GITHUBORG/REPONAME - - uses: codecov/codecov-action@v1 - with: - fail_ci_if_error: false - - -## -# Formatting with black -# Require all code be formatted with black -# with line length 79 - - black: - name: Black (formatting) - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - with: - path: ansible_collections/ansible/utils - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Install Black - run: pip install black - - - name: Run black --check - run: black -l79 --diff --check ansible_collections/ansible/utils diff --git a/.github/workflows/merge_on_gate.yml b/.github/workflows/merge_on_gate.yml deleted file mode 100644 index 016b0cd..0000000 --- a/.github/workflows/merge_on_gate.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Merge a pull request -on: - pull_request: - branches: - - main - types: [labeled] - -jobs: - merge: - if: | - github.event.label.name == 'gate' - name: merge - runs-on: ubuntu-latest - steps: - - name: Install gh - run: | - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 - sudo apt-add-repository https://cli.github.com/packages - sudo apt update - sudo apt install gh - - - name: Check out code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Checkout default branch and merge PR - env: - DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} - PR: ${{ github.event.number }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git checkout $DEFAULT_BRANCH - gh pr merge $PR --squash --delete-branch=false diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 2bde00a..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -name: Publish -on: - release: - types: - - created - -jobs: - publish: - name: Publish to galaxy - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Install ansible-base - run: pip install ansible-base - - - name: Update the galaxy.yml with the release - env: - VERSION: ${{ github.event.release.tag_name }} - run: | - sed -i 's/0.0.0/'$VERSION'/' galaxy.yml - cat galaxy.yml - - # - name: Build and publish - # env: - # ANSIBLE_GALAXY_API_KEY: ${{ secrets.ANSIBLE_GALAXY_API_KEY }} - # run: | - # ansible-galaxy collection build - # ansible-galaxy collection publish *.tar.gz --api-key $ANSIBLE_GALAXY_API_KEY diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 0000000..ba9c980 --- /dev/null +++ b/bindep.txt @@ -0,0 +1,6 @@ +# This is a cross-platform list tracking distribution packages needed by tests; +# see https://docs.openstack.org/infra/bindep/ for additional information. + +gcc-c++ [doc test platform:rpm] +python3-devel [test platform:rpm] +python3 [test platform:rpm] diff --git a/changelogs/fragments/test_ci.yaml b/changelogs/fragments/test_ci.yaml new file mode 100644 index 0000000..47e2100 --- /dev/null +++ b/changelogs/fragments/test_ci.yaml @@ -0,0 +1,3 @@ +--- +major_changes: + - test ci. diff --git a/plugins/test/validate.py b/plugins/test/validate.py index 8ff73af..6a5f06c 100644 --- a/plugins/test/validate.py +++ b/plugins/test/validate.py @@ -147,7 +147,7 @@ def validate(*args, **kwargs): class TestModule(object): """data validation test""" - + # For testing test_map = {"validate": validate} def tests(self): diff --git a/zuul.yaml b/zuul.yaml new file mode 100644 index 0000000..82cb33b --- /dev/null +++ b/zuul.yaml @@ -0,0 +1,4 @@ +--- +- project: + templates: + - ansible-collections-ansible-utils-units