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

Create GitHub Actions workflow for running tests #944

Merged
merged 8 commits into from Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
116 changes: 116 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,116 @@
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:
samdoran marked this conversation as resolved.
Show resolved Hide resolved
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
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
1 change: 1 addition & 0 deletions test/integration/test_runner.py
Expand Up @@ -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'
Expand Down
11 changes: 10 additions & 1 deletion tox.ini
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