From d8cbe431a9ffb828f6e032461924486cd7ab3f75 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 17 Dec 2021 12:33:09 -0500 Subject: [PATCH 1/8] Add tox environments for unit and inetgration tests as well as Python 3.10 --- tox.ini | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index a72e3adb4..b64f020a8 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,8 @@ deps = ansible27: ansible<2.8 ansible28: ansible<2.9 ansible29: ansible<2.10 ansible-base: ansible-base - py{,3,38}: ansible-core + py{,3,38,39,310}: ansible-core + integration{,-py38,-py39,-py310}: ansible-core -r {toxinidir}/requirements.txt -r {toxinidir}/test/requirements.txt passenv = HOME @@ -24,6 +25,14 @@ commands= yamllint --version yamllint -s . +[testenv:unit{,-py38,-py39,-py310}] +description = Run unit tests +commands = pytest {posargs:test/unit} + +[testenv:integration{,-py38,-py39,-py310}] +description = Run integration tests +commands = pytest {posargs:test/integration} + [testenv:docs] description = Build documentation deps = -r{toxinidir}/docs/requirements.txt From e726b96c0ea866cb38f5280d923504763dad0b63 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 17 Dec 2021 12:33:26 -0500 Subject: [PATCH 2/8] Add CI workflow Only sanity and unit tests for now. --- .github/workflows/ci.yml | 71 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..c14ebfcf0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +name: CI + +on: + pull_request: + push: + + +jobs: + sanity: + name: ${{ matrix.test.name }} + runs-on: ubuntu-20.04 + container: + image: quay.io/ansible/ansible-runner-test-container:2.0.0 + env: + PIP_CACHE_DIR: ${{ runner.temp }}/.cache/pip + PY_COLORS: 1 + TOXENV: ${{ matrix.test.tox_env }} + + strategy: + fail-fast: false + matrix: + test: + - name: Lint + tox_env: linters + + - name: Docs + tox_env: docs + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Create tox environment + run: tox --notest + + - name: Run tests + run: tox + + + unit: + name: Unit - ${{ matrix.py_version.name}} + runs-on: ubuntu-20.04 + container: + image: quay.io/ansible/ansible-runner-test-container:2.0.0 + env: + PIP_CACHE_DIR: ${{ runner.temp }}/.cache/pip + TOXENV: ${{ matrix.py_version.tox_env }} + PY_COLORS: 1 + + strategy: + fail-fast: false + matrix: + py_version: + - name: '3.8' + tox_env: unit-py38 + + - name: '3.9' + tox_env: unit-py39 + + - name: '3.10' + tox_env: unit-py310 + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Create tox environment + run: tox --notest + + - name: Run tests + run: tox From 2f8afb11a444e0788c71561c3eae33f4886d3b4a Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 17 Dec 2021 12:39:24 -0500 Subject: [PATCH 3/8] Add integration tests --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c14ebfcf0..68babe5bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,51 @@ jobs: run: tox + integration: + runs-on: ubuntu-20.04 + name: Integration - ${{ matrix.py_version.name }} + + env: + TOXENV: ${{ matrix.py_version.tox_env }} + PY_COLORS: 1 + + strategy: + fail-fast: false + matrix: + py_version: + - name: '3.8' + tox_env: integration-py38 + + - name: '3.9' + tox_env: integration-py39 + + - name: '3.10' + tox_env: integration-py310 + + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Python ${{ matrix.py_version.name }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.py_version.name }} + + - name: Install tox + run: | + python3 -m pip install --upgrade pip + python3 -m pip install tox + + - name: Create tox environment + run: | + tox --notest + + - name: Run integration tests + run: | + tox + + unit: name: Unit - ${{ matrix.py_version.name}} runs-on: ubuntu-20.04 From 3c55a8469698de8564f5858953d2336a79f36516 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 17 Dec 2021 13:41:45 -0500 Subject: [PATCH 4/8] Mark test as unstable --- test/integration/test_runner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/test_runner.py b/test/integration/test_runner.py index ef569a065..627936c55 100644 --- a/test/integration/test_runner.py +++ b/test/integration/test_runner.py @@ -14,6 +14,7 @@ from test.utils.common import iterate_timeout +@pytest.mark.xfail(reason='Test is unstable') def test_password_prompt(rc): rc.command = [sys.executable, '-c' 'import time; print(input("Password: "))'] rc.expect_passwords[re.compile(r'Password:\s*?$', re.M)] = '1234' From adfd7a64c89daefde8758f32d63eb55c6d4d3a50 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 17 Dec 2021 14:35:21 -0500 Subject: [PATCH 5/8] Upload code coverage report --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68babe5bb..91718b8c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,6 +81,12 @@ jobs: run: | tox + - name: Upload coverage report + run: | + curl --silent --show-error --output codecov https://ansible-ci-files.s3.us-east-1.amazonaws.com/codecov/linux/codecov + chmod +x codecov + ./codecov --file test/coverage/reports/coverage.xml --flags {{ matrix.py_version.tox_env }} + unit: name: Unit - ${{ matrix.py_version.name}} @@ -114,3 +120,6 @@ jobs: - name: Run tests run: tox + + - name: Upload coverage report + run: codecov --file test/coverage/reports/coverage.xml --flags {{ matrix.py_version.tox_env }} From 13138368b6536839b546ded6bccd0e5b392ff7fe Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 17 Dec 2021 14:50:51 -0500 Subject: [PATCH 6/8] Build container image for integration tests --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91718b8c0..86a84580c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,9 +37,29 @@ jobs: run: tox + images: + name: Build Image - ${{ matrix.runtime }} + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + matrix: + runtime: + - docker + - podman + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Build Container Image + run: ${{ matrix.runtime }} build --rm=true -t quay.io/ansible/ansible-runner:devel -t quay.io/ansible/ansible-runner:latest . + + integration: runs-on: ubuntu-20.04 name: Integration - ${{ matrix.py_version.name }} + needs: images env: TOXENV: ${{ matrix.py_version.tox_env }} From 28631f3f2eb8d0f1cd032b24f5640a2ae10c0a97 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 17 Dec 2021 15:18:22 -0500 Subject: [PATCH 7/8] Add Codecov badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 521047ed1..597058ad1 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Ansible Runner [![Documentation](https://readthedocs.org/projects/ansible-runner/badge/?version=stable)](https://ansible-runner.readthedocs.io/en/latest/) [![Code of Conduct](https://img.shields.io/badge/Code%20of%20Conduct-Ansible-silver.svg)](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html) [![Ansible Mailing lists](https://img.shields.io/badge/Mailing%20lists-Ansible-orange.svg)](https://docs.ansible.com/ansible/latest/community/communication.html#mailing-list-information) - +[![codecov](https://codecov.io/gh/ansible/ansible-runner/branch/devel/graph/badge.svg?token=CmCcjBz0pQ)](https://codecov.io/gh/ansible/ansible-runner) Ansible Runner is a tool and Python library that helps when interfacing with Ansible directly or as part of another system. Ansible Runner works as a standalone tool, a container image interface, or a Python module that can be imported. The goal is to provide a stable and consistent interface abstraction to Ansible. From 93bb15eecabb39145f59186eda6bbfefae0d9f43 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Tue, 18 Jan 2022 11:43:59 -0500 Subject: [PATCH 8/8] Build images for runtime before running integration test --- .github/workflows/ci.yml | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86a84580c..3f361578a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,29 +37,9 @@ jobs: run: tox - images: - name: Build Image - ${{ matrix.runtime }} - runs-on: ubuntu-20.04 - - strategy: - fail-fast: false - matrix: - runtime: - - docker - - podman - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Build Container Image - run: ${{ matrix.runtime }} build --rm=true -t quay.io/ansible/ansible-runner:devel -t quay.io/ansible/ansible-runner:latest . - - integration: runs-on: ubuntu-20.04 name: Integration - ${{ matrix.py_version.name }} - needs: images env: TOXENV: ${{ matrix.py_version.tox_env }} @@ -99,6 +79,8 @@ jobs: - name: Run integration tests run: | + docker build --rm=true -t quay.io/ansible/ansible-runner:devel -t quay.io/ansible/ansible-runner:latest . + podman build --rm=true -t quay.io/ansible/ansible-runner:devel -t quay.io/ansible/ansible-runner:latest . tox - name: Upload coverage report