mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
generate matrix of jobs in workflow Params, instead of UnitTesting
This commit is contained in:
29
.github/workflows/Params.yml
vendored
29
.github/workflows/Params.yml
vendored
@@ -8,6 +8,11 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
default: '3.10'
|
default: '3.10'
|
||||||
type: string
|
type: string
|
||||||
|
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'
|
||||||
|
type: string
|
||||||
name:
|
name:
|
||||||
description: 'Name of the tool.'
|
description: 'Name of the tool.'
|
||||||
required: true
|
required: true
|
||||||
@@ -16,6 +21,9 @@ on:
|
|||||||
params:
|
params:
|
||||||
description: "Parameters to be used in other jobs."
|
description: "Parameters to be used in other jobs."
|
||||||
value: ${{ jobs.Params.outputs.params }}
|
value: ${{ jobs.Params.outputs.params }}
|
||||||
|
python_jobs:
|
||||||
|
description: "List of Python versions to be used in the matrix of other jobs."
|
||||||
|
value: ${{ jobs.Params.outputs.python_jobs }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
@@ -23,9 +31,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
params: ${{ steps.params.outputs.params }}
|
params: ${{ steps.params.outputs.params }}
|
||||||
|
python_jobs: ${{ steps.params.outputs.python_jobs }}
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- id: params
|
- name: Generate 'params' and 'python_jobs'
|
||||||
|
id: params
|
||||||
shell: python
|
shell: python
|
||||||
run: |
|
run: |
|
||||||
name = '${{ inputs.name }}'
|
name = '${{ inputs.name }}'
|
||||||
@@ -40,3 +50,20 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
print(f'::set-output name=params::{params!s}')
|
print(f'::set-output name=params::{params!s}')
|
||||||
|
print("Params:")
|
||||||
|
print(params)
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'3.6': { 'icon': '🔴', 'until': '23.12.2021' },
|
||||||
|
'3.7': { 'icon': '🟠', 'until': '27.06.2023' },
|
||||||
|
'3.8': { 'icon': '🟡', 'until': 'Oct. 2024' },
|
||||||
|
'3.9': { 'icon': '🟢', 'until': 'Oct. 2025' },
|
||||||
|
'3.10': { 'icon': '🟢', 'until': 'Oct. 2026' },
|
||||||
|
}
|
||||||
|
jobs = [
|
||||||
|
{'python': version, 'icon': data[version]['icon']}
|
||||||
|
for version in '${{ inputs.python_version_list }}'.split(' ')
|
||||||
|
]
|
||||||
|
print(f'::set-output name=python_jobs::{jobs!s}')
|
||||||
|
print("Python jobs:")
|
||||||
|
print(jobs)
|
||||||
|
|||||||
33
.github/workflows/UnitTesting.yml
vendored
33
.github/workflows/UnitTesting.yml
vendored
@@ -3,10 +3,9 @@ name: Unit Testing
|
|||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
python_versions:
|
jobs:
|
||||||
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: true
|
||||||
default: '3.6 3.7 3.8 3.9 3.10'
|
|
||||||
type: string
|
type: string
|
||||||
requirements:
|
requirements:
|
||||||
description: 'Python dependencies to be installed through pip.'
|
description: 'Python dependencies to be installed through pip.'
|
||||||
@@ -21,40 +20,14 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
|
||||||
Versions:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
jobs: ${{ steps.versions.outputs.jobs }}
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- id: versions
|
|
||||||
shell: python
|
|
||||||
run: |
|
|
||||||
icons = {
|
|
||||||
'3.6': '🔴', # until 23.12.2021
|
|
||||||
'3.7': '🟠', # until 27.06.2023
|
|
||||||
'3.8': '🟡', # until Oct. 2024
|
|
||||||
'3.9': '🟢', # until Oct. 2025
|
|
||||||
'3.10': '🟢', # until Oct. 2026
|
|
||||||
}
|
|
||||||
jobs = [
|
|
||||||
{'python': version, 'icon': icons[version]}
|
|
||||||
for version in '${{ inputs.python_versions }}'.split(' ')
|
|
||||||
]
|
|
||||||
print(f'::set-output name=jobs::{jobs!s}')
|
|
||||||
|
|
||||||
|
|
||||||
UnitTesting:
|
UnitTesting:
|
||||||
name: ${{ matrix.icon }} Unit Tests using Python ${{ matrix.python }}
|
name: ${{ matrix.icon }} Unit Tests using Python ${{ matrix.python }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
|
||||||
- Versions
|
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include: ${{ fromJson(needs.Versions.outputs.jobs) }}
|
include: ${{ fromJson(inputs.jobs) }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: ⏬ Checkout repository
|
- name: ⏬ Checkout repository
|
||||||
|
|||||||
Reference in New Issue
Block a user