mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 11:06:56 +08:00
Extend Unit Tests to multiple systems (ubuntu, windows, msys2 and macos)
This commit is contained in:
33
.github/workflows/Parameters.yml
vendored
33
.github/workflows/Parameters.yml
vendored
@@ -33,7 +33,12 @@ on:
|
||||
python_version_list:
|
||||
description: 'Space separated list of Python versions to run tests with.'
|
||||
required: false
|
||||
default: '3.6 3.7 3.8 3.9 3.10'
|
||||
default: '3.7 3.8 3.9 3.10'
|
||||
type: string
|
||||
system_list:
|
||||
description: 'Space separated list of systems to run tests on.'
|
||||
required: false
|
||||
default: 'ubuntu windows msys2 macos'
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the tool.'
|
||||
@@ -75,19 +80,39 @@ jobs:
|
||||
print("Parameters:")
|
||||
print(params)
|
||||
|
||||
systems = '${{ inputs.system_list }}'.split(' ')
|
||||
versions = '${{ inputs.python_version_list }}'.split(' ')
|
||||
if '3.6' in versions:
|
||||
print('WARNING: support for Python 3.6 ended in 2021.12.23')
|
||||
print("::warning title=Deprecated::Support for Python 3.6 ended in 2021.12.23.")
|
||||
if '3.11' in versions:
|
||||
print(f"::notice title=Experimental::Python 3.11 (3.11.0-alpha3) is a pre-release.")
|
||||
data = {
|
||||
'python': {
|
||||
'3.6': { 'icon': '⚫', 'until': '2021.12.23' },
|
||||
'3.7': { 'icon': '🔴', 'until': '2023.06.27' },
|
||||
'3.8': { 'icon': '🟠', 'until': '2024.10' },
|
||||
'3.9': { 'icon': '🟡', 'until': '2025.10' },
|
||||
'3.10': { 'icon': '🟢', 'until': '2026.10' },
|
||||
'3.11': { 'icon': '🟣', 'until': '2027.10' },
|
||||
},
|
||||
'sys': {
|
||||
'ubuntu': { 'icon': '🐧', 'runs-on': 'ubuntu-latest', 'shell': 'bash' },
|
||||
'windows': { 'icon': '🧊', 'runs-on': 'windows-latest', 'shell': 'pwsh' },
|
||||
'msys2': { 'icon': '🟦', 'runs-on': 'windows-latest', 'shell': 'msys2 {0}' },
|
||||
'macos': { 'icon': '🍎', 'runs-on': 'macos-latest', 'shell': 'bash' }
|
||||
}
|
||||
}
|
||||
jobs = [
|
||||
{'python': version, 'icon': data[version]['icon']}
|
||||
for version in versions
|
||||
{
|
||||
'sysicon': data['sys'][system]['icon'],
|
||||
'system': system,
|
||||
'runs-on': data['sys'][system]['runs-on'],
|
||||
'shell': data['sys'][system]['shell'],
|
||||
'pyicon': data['python'][version]['icon'],
|
||||
'python': '3.11.0-alpha.3' if version == '3.11' else version
|
||||
}
|
||||
for system in systems
|
||||
for version in (versions if system != 'msys2' else ['3.9'])
|
||||
]
|
||||
print(f'::set-output name=python_jobs::{jobs!s}')
|
||||
print("Python jobs:")
|
||||
|
||||
44
.github/workflows/UnitTesting.yml
vendored
44
.github/workflows/UnitTesting.yml
vendored
@@ -26,7 +26,7 @@ on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
jobs:
|
||||
description: 'JSON list with field <python>, telling the versions to run tests with.'
|
||||
description: 'JSON list with environment fields, telling the system and Python versions to run tests with.'
|
||||
required: true
|
||||
type: string
|
||||
requirements:
|
||||
@@ -48,29 +48,59 @@ on:
|
||||
jobs:
|
||||
|
||||
UnitTesting:
|
||||
name: ${{ matrix.icon }} Unit Tests using Python ${{ matrix.python }}
|
||||
runs-on: ubuntu-latest
|
||||
name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Unit Tests using Python ${{ matrix.python }}
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: ${{ fromJson(inputs.jobs) }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ matrix.shell }}
|
||||
|
||||
steps:
|
||||
- name: ⏬ Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: '🟦 Setup MSYS2'
|
||||
if: matrix.system == 'msys2'
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: MINGW64
|
||||
update: true
|
||||
pacboy: >-
|
||||
python-pip:p
|
||||
python-wheel:p
|
||||
python-coverage:p
|
||||
python-lxml:p
|
||||
|
||||
- name: 🐍 Setup Python ${{ matrix.python }}
|
||||
if: matrix.system != 'msys2'
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
|
||||
- name: 🔧 Install dependencies
|
||||
- name: ⚙️ Update pip
|
||||
run: python -m pip install -U pip
|
||||
|
||||
- name: ⚙️ Install wheel
|
||||
if: matrix.system != 'msys2'
|
||||
run: |
|
||||
python -m pip install -U pip
|
||||
python -m pip install ${{ inputs.requirements }}
|
||||
python -m pip install -U wheel
|
||||
|
||||
- name: 🔧 Install dependencies
|
||||
run: python -m pip install ${{ inputs.requirements }}
|
||||
|
||||
- name: ☑ Run unit tests
|
||||
if: matrix.system == 'windows'
|
||||
run: |
|
||||
$PYTEST_ARGS = if ("${{ inputs.artifact }}".length -gt 0) { "--junitxml=TestReport.xml" } else { "" }
|
||||
python -m pytest -rA ${{ inputs.unittest_directory }} $PYTEST_ARGS --color=yes
|
||||
|
||||
- name: ☑ Run unit tests
|
||||
if: matrix.system != 'windows'
|
||||
run: |
|
||||
[ 'x${{ inputs.artifact }}' != 'x' ] && PYTEST_ARGS='--junitxml=TestReport.xml' || unset PYTEST_ARGS
|
||||
python -m pytest -rA ${{ inputs.unittest_directory }} $PYTEST_ARGS --color=yes
|
||||
@@ -79,7 +109,7 @@ jobs:
|
||||
if: inputs.artifact != ''
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ inputs.artifact }}-${{ matrix.python }}
|
||||
name: ${{ inputs.artifact }}-${{ matrix.system }}-${{ matrix.python }}
|
||||
path: TestReport.xml
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
@@ -34,6 +34,7 @@ jobs:
|
||||
with:
|
||||
name: ToolName
|
||||
# Optional
|
||||
system_list: 'ubuntu windows msys2 macos'
|
||||
python_version: '3.10'
|
||||
python_version_list: '3.8 3.9 3.10'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user