mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
Extend Unit Tests to multiple systems (ubuntu, windows, msys2 and macos)
This commit is contained in:
43
.github/workflows/Parameters.yml
vendored
43
.github/workflows/Parameters.yml
vendored
@@ -33,7 +33,12 @@ on:
|
|||||||
python_version_list:
|
python_version_list:
|
||||||
description: 'Space separated list of Python versions to run tests with.'
|
description: 'Space separated list of Python versions to run tests with.'
|
||||||
required: false
|
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
|
type: string
|
||||||
name:
|
name:
|
||||||
description: 'Name of the tool.'
|
description: 'Name of the tool.'
|
||||||
@@ -75,19 +80,39 @@ jobs:
|
|||||||
print("Parameters:")
|
print("Parameters:")
|
||||||
print(params)
|
print(params)
|
||||||
|
|
||||||
|
systems = '${{ inputs.system_list }}'.split(' ')
|
||||||
versions = '${{ inputs.python_version_list }}'.split(' ')
|
versions = '${{ inputs.python_version_list }}'.split(' ')
|
||||||
if '3.6' in versions:
|
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 = {
|
data = {
|
||||||
'3.6': { 'icon': '⚫', 'until': '2021.12.23' },
|
'python': {
|
||||||
'3.7': { 'icon': '🔴', 'until': '2023.06.27' },
|
'3.6': { 'icon': '⚫', 'until': '2021.12.23' },
|
||||||
'3.8': { 'icon': '🟠', 'until': '2024.10' },
|
'3.7': { 'icon': '🔴', 'until': '2023.06.27' },
|
||||||
'3.9': { 'icon': '🟡', 'until': '2025.10' },
|
'3.8': { 'icon': '🟠', 'until': '2024.10' },
|
||||||
'3.10': { 'icon': '🟢', 'until': '2026.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 = [
|
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(f'::set-output name=python_jobs::{jobs!s}')
|
||||||
print("Python jobs:")
|
print("Python jobs:")
|
||||||
|
|||||||
44
.github/workflows/UnitTesting.yml
vendored
44
.github/workflows/UnitTesting.yml
vendored
@@ -26,7 +26,7 @@ on:
|
|||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
jobs:
|
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
|
required: true
|
||||||
type: string
|
type: string
|
||||||
requirements:
|
requirements:
|
||||||
@@ -48,29 +48,59 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
UnitTesting:
|
UnitTesting:
|
||||||
name: ${{ matrix.icon }} Unit Tests using Python ${{ matrix.python }}
|
name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Unit Tests using Python ${{ matrix.python }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.runs-on }}
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include: ${{ fromJson(inputs.jobs) }}
|
include: ${{ fromJson(inputs.jobs) }}
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: ${{ matrix.shell }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: ⏬ Checkout repository
|
- name: ⏬ Checkout repository
|
||||||
uses: actions/checkout@v2
|
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 }}
|
- name: 🐍 Setup Python ${{ matrix.python }}
|
||||||
|
if: matrix.system != 'msys2'
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python }}
|
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: |
|
run: |
|
||||||
python -m pip install -U pip
|
python -m pip install -U wheel
|
||||||
python -m pip install ${{ inputs.requirements }}
|
|
||||||
|
- name: 🔧 Install dependencies
|
||||||
|
run: python -m pip install ${{ inputs.requirements }}
|
||||||
|
|
||||||
- name: ☑ Run unit tests
|
- 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: |
|
run: |
|
||||||
[ 'x${{ inputs.artifact }}' != 'x' ] && PYTEST_ARGS='--junitxml=TestReport.xml' || unset PYTEST_ARGS
|
[ 'x${{ inputs.artifact }}' != 'x' ] && PYTEST_ARGS='--junitxml=TestReport.xml' || unset PYTEST_ARGS
|
||||||
python -m pytest -rA ${{ inputs.unittest_directory }} $PYTEST_ARGS --color=yes
|
python -m pytest -rA ${{ inputs.unittest_directory }} $PYTEST_ARGS --color=yes
|
||||||
@@ -79,7 +109,7 @@ jobs:
|
|||||||
if: inputs.artifact != ''
|
if: inputs.artifact != ''
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.artifact }}-${{ matrix.python }}
|
name: ${{ inputs.artifact }}-${{ matrix.system }}-${{ matrix.python }}
|
||||||
path: TestReport.xml
|
path: TestReport.xml
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: ToolName
|
name: ToolName
|
||||||
# Optional
|
# Optional
|
||||||
|
system_list: 'ubuntu windows msys2 macos'
|
||||||
python_version: '3.10'
|
python_version: '3.10'
|
||||||
python_version_list: '3.8 3.9 3.10'
|
python_version_list: '3.8 3.9 3.10'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user