mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
Allow installing additional packaged via apt and allow running before scripts for ubuntu and macos.
This commit is contained in:
52
.github/workflows/UnitTesting.yml
vendored
52
.github/workflows/UnitTesting.yml
vendored
@@ -29,21 +29,36 @@ on:
|
|||||||
description: 'JSON list with environment fields, telling the system and Python 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
|
||||||
|
apt:
|
||||||
|
description: 'Ubuntu dependencies to be installed through apt.'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
type: string
|
||||||
|
pacboy:
|
||||||
|
description: 'MSYS2 dependencies to be installed through pacboy (pacman).'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
type: string
|
||||||
requirements:
|
requirements:
|
||||||
description: 'Python dependencies to be installed through pip.'
|
description: 'Python dependencies to be installed through pip.'
|
||||||
required: false
|
required: false
|
||||||
default: '-r tests/requirements.txt'
|
default: '-r tests/requirements.txt'
|
||||||
type: string
|
type: string
|
||||||
pacboy:
|
|
||||||
description: 'MSYS2 dependencies to be installed through pacboy (pacman).'
|
|
||||||
required: false
|
|
||||||
default: ""
|
|
||||||
type: string
|
|
||||||
mingw_requirements:
|
mingw_requirements:
|
||||||
description: 'Override Python dependencies to be installed through pip on MSYS2 (MINGW64) only.'
|
description: 'Override Python dependencies to be installed through pip on MSYS2 (MINGW64) only.'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
type: string
|
type: string
|
||||||
|
macos_before_script:
|
||||||
|
description: 'Scripts to execute before pytest on macOS.'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
type: string
|
||||||
|
ubuntu_before_script:
|
||||||
|
description: 'Scripts to execute before pytest on Ubuntu.'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
type: string
|
||||||
root_directory:
|
root_directory:
|
||||||
description: 'Working directory for running tests.'
|
description: 'Working directory for running tests.'
|
||||||
required: false
|
required: false
|
||||||
@@ -113,6 +128,13 @@ jobs:
|
|||||||
- name: ⏬ Checkout repository
|
- name: ⏬ Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Package Manager steps
|
||||||
|
- name: 🔧 Install apt dependencies on Ubuntu
|
||||||
|
if: matrix.system == 'ubuntu' && inputs.apt != ''
|
||||||
|
run: sudo apt-get install -y --no-install-recommends ${{ inputs.apt }}
|
||||||
|
|
||||||
|
# Compute Dependencies for MSYS2 steps
|
||||||
|
|
||||||
- name: 🔧 Install dependencies (system Python for Python shell)
|
- name: 🔧 Install dependencies (system Python for Python shell)
|
||||||
if: matrix.system == 'msys2'
|
if: matrix.system == 'msys2'
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
@@ -206,6 +228,8 @@ jobs:
|
|||||||
with github_output.open("a+") as f:
|
with github_output.open("a+") as f:
|
||||||
f.write(f"pacboy_packages={' '.join(pacboyPackages)}\n")
|
f.write(f"pacboy_packages={' '.join(pacboyPackages)}\n")
|
||||||
|
|
||||||
|
# Python setup
|
||||||
|
|
||||||
- name: '🟦 Setup MSYS2 for ${{ matrix.runtime }}'
|
- name: '🟦 Setup MSYS2 for ${{ matrix.runtime }}'
|
||||||
if: matrix.system == 'msys2'
|
if: matrix.system == 'msys2'
|
||||||
uses: msys2/setup-msys2@v2
|
uses: msys2/setup-msys2@v2
|
||||||
@@ -222,6 +246,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python }}
|
python-version: ${{ matrix.python }}
|
||||||
|
|
||||||
|
# Python Dependency steps
|
||||||
|
|
||||||
- name: 🔧 Install wheel,tomli and pip dependencies (native)
|
- name: 🔧 Install wheel,tomli and pip dependencies (native)
|
||||||
if: matrix.system != 'msys2'
|
if: matrix.system != 'msys2'
|
||||||
run: |
|
run: |
|
||||||
@@ -237,6 +263,18 @@ jobs:
|
|||||||
python -m pip install --disable-pip-version-check ${{ inputs.requirements }}
|
python -m pip install --disable-pip-version-check ${{ inputs.requirements }}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Before scripts
|
||||||
|
|
||||||
|
- name: 🍎 macOS before scripts
|
||||||
|
if: matrix.system == 'ubuntu' && inputs.macos_before_script != ''
|
||||||
|
run: ${{ inputs.macos_before_script }}
|
||||||
|
|
||||||
|
- name: 🐧 Ubuntu before scripts
|
||||||
|
if: matrix.system == 'ubuntu' && inputs.ubuntu_before_script != ''
|
||||||
|
run: ${{ inputs.ubuntu_before_script }}
|
||||||
|
|
||||||
|
# Read pyproject.toml
|
||||||
|
|
||||||
- name: 🔁 Extract configurations from pyproject.toml
|
- name: 🔁 Extract configurations from pyproject.toml
|
||||||
id: getVariables
|
id: getVariables
|
||||||
shell: python
|
shell: python
|
||||||
@@ -294,6 +332,8 @@ jobs:
|
|||||||
|
|
||||||
print(f"DEBUG:\n html={htmlDirectory}\n xml={xmlFile}\n json={jsonFile}")
|
print(f"DEBUG:\n html={htmlDirectory}\n xml={xmlFile}\n json={jsonFile}")
|
||||||
|
|
||||||
|
# Run pytests
|
||||||
|
|
||||||
- name: ✅ Run unit tests (Ubuntu/macOS)
|
- name: ✅ Run unit tests (Ubuntu/macOS)
|
||||||
if: matrix.system != 'windows'
|
if: matrix.system != 'windows'
|
||||||
run: |
|
run: |
|
||||||
@@ -343,6 +383,8 @@ jobs:
|
|||||||
coverage html --data-file=.coverage -d ${{ steps.getVariables.outputs.coverage_report_html_directory }}
|
coverage html --data-file=.coverage -d ${{ steps.getVariables.outputs.coverage_report_html_directory }}
|
||||||
rm ${{ steps.getVariables.outputs.coverage_report_html_directory }}/.gitignore
|
rm ${{ steps.getVariables.outputs.coverage_report_html_directory }}/.gitignore
|
||||||
|
|
||||||
|
# Upload artifacts
|
||||||
|
|
||||||
- name: 📤 Upload 'TestReportSummary.xml' artifact
|
- name: 📤 Upload 'TestReportSummary.xml' artifact
|
||||||
if: inputs.unittest_xml_artifact != ''
|
if: inputs.unittest_xml_artifact != ''
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|||||||
Reference in New Issue
Block a user