ci: support running multiple versions of ansible-lint and ansible-test #532
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: tox | |
| on: # yamllint disable-line rule:truthy | |
| - pull_request | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| jobs: | |
| python: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| pyver_os: | |
| - ver: '2.7' | |
| os: ubuntu-22.04 | |
| # 3.6 gets tested in tox-py36.yml | |
| - ver: '3.9' | |
| os: ubuntu-latest | |
| - ver: '3.10' | |
| os: ubuntu-latest | |
| - ver: '3.11' | |
| os: ubuntu-latest | |
| - ver: '3.12' | |
| os: ubuntu-latest | |
| - ver: '3.13' | |
| os: ubuntu-latest | |
| runs-on: ${{ matrix.pyver_os.os }} | |
| steps: | |
| - name: checkout PR | |
| uses: actions/checkout@v3 | |
| - name: Set up Python 2.7 | |
| if: ${{ matrix.pyver_os.ver == '2.7' }} | |
| run: | | |
| set -euxo pipefail | |
| sudo apt update | |
| sudo apt install -y python2.7 | |
| - name: Set up Python 3 | |
| if: ${{ matrix.pyver_os.ver != '2.7' }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.pyver_os.ver }} | |
| - name: Install platform dependencies, python, tox | |
| run: | | |
| set -euxo pipefail | |
| python -m pip install --upgrade pip | |
| pip install -rtox-requirements.txt | |
| - name: Run tox tests | |
| run: | | |
| set -euxo pipefail | |
| toxpyver=$(echo "${{ matrix.pyver_os.ver }}" | tr -d .) | |
| case "$toxpyver" in | |
| *-alpha*|*-beta*) toxpyver=$(echo "$toxpyver" | sed 's/^.* \([1-9][0-9]*\)$/\1/') ;; | |
| 27) export SAFETY_CMD="echo skipping safety" ;; | |
| esac | |
| toxpyenv="py${toxpyver}-tox30" | |
| # run linters only on ubuntu-latest | |
| if test X${{ matrix.pyver_os.os }} = Xubuntu-latest; then | |
| linters="black,isort,pylint,flake8,mypy,bandit,pydocstyle," | |
| fi | |
| # run python unit tests only on the toxenv that matches the | |
| # current system version of python | |
| tox -e "${linters:-}$toxpyenv,coveralls" |