Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] [release_2.1] Create GitHub Actions workflow for running tests (#944) #962

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
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


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: |
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
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}}
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

- name: Upload coverage report
run: codecov --file test/coverage/reports/coverage.xml --flags {{ matrix.py_version.tox_env }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions test/integration/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ansible_runner.exceptions import AnsibleRunnerException


@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'
Expand Down
11 changes: 10 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down