Install Python package and readout embedded package version.

This commit is contained in:
Patrick Lehmann
2025-05-05 18:55:24 +02:00
parent 330a21e6c3
commit 5891636ec9
5 changed files with 200 additions and 6 deletions

View File

@@ -158,6 +158,18 @@ jobs:
# exclude_list: ${{ inputs.apptest_exclude_list }}
# disable_list: ${{ inputs.apptest_disable_list }}
InstallParams:
uses: pyTooling/Actions/.github/workflows/Parameters.yml@dev
with:
package_namespace: ${{ inputs.package_namespace }}
package_name: ${{ inputs.package_name }}
python_version: ${{ inputs.unittest_python_version }}
python_version_list: ''
system_list: ${{ inputs.unittest_system_list }}
include_list: ${{ inputs.unittest_include_list }}
exclude_list: ${{ inputs.unittest_exclude_list }}
disable_list: ${{ inputs.unittest_disable_list }}
UnitTesting:
uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@dev
needs:
@@ -199,11 +211,23 @@ jobs:
uses: pyTooling/Actions/.github/workflows/Package.yml@dev
needs:
- UnitTestingParams
- UnitTesting
# - UnitTesting
with:
python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}
Install:
uses: pyTooling/Actions/.github/workflows/InstallPackage.yml@dev
needs:
- ConfigParams
- UnitTestingParams
- InstallParams
- Package
with:
jobs: ${{ needs.InstallParams.outputs.python_jobs }}
wheel: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}
package_name: ${{ needs.ConfigParams.outputs.package_fullname }}
# AppTesting:
# uses: pyTooling/Actions/.github/workflows/ApplicationTesting.yml@dev
# needs:
@@ -244,7 +268,7 @@ jobs:
- UnitTestingParams
- UnitTesting
with:
testsuite-summary-name: ${{ inputs.package_name }}
testsuite-summary-name: ${{ needs.ConfigParams.outputs.package_fullname }}
merged_junit_filename: ${{ needs.ConfigParams.outputs.unittest_merged_report_xml_filename }}
merged_junit_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}
dorny: ${{ inputs.dorny }}
@@ -314,6 +338,7 @@ jobs:
needs:
- Prepare
- UnitTesting
- Install
# - AppTesting
# - StaticTypeCheck
- Package
@@ -332,6 +357,7 @@ jobs:
needs:
- Prepare
- UnitTesting
- Install
# - AppTesting
# - StaticTypeCheck
- Package

View File

@@ -145,6 +145,12 @@ jobs:
namespace = "${{ inputs.package_namespace }}".strip()
name = "${{ inputs.package_name }}".strip()
print(dedent(f"""\
INPUTS:
package_namespace: {namespace}
package_name: {name}
"""))
if namespace == "" or namespace == ".":
fullname = f"{name}"
directory = f"{name}"
@@ -154,6 +160,13 @@ jobs:
directory = f"{namespace}/{name}"
mypy_prepare_command = f"touch {namespace}/__init__.py"
print(dedent(f"""\
OUTPUTS:
package_fullname: {fullname}
package_directory: {directory}
mypy_prepare_command: {mypy_prepare_command}
"""))
github_output = Path(getenv("GITHUB_OUTPUT"))
print(f"GITHUB_OUTPUT: {github_output}")
with github_output.open("a+", encoding="utf-8") as f:
@@ -234,4 +247,11 @@ jobs:
coverage_report_json={coverageJSONFile.as_posix()}
"""))
print(f"DEBUG:\n unittest xml: {unittestXMLFile}\n merged unittest xml: {mergedUnittestXMLFile}\n coverage html: {coverageHTMLDirectory}\n coverage xml: {coverageXMLFile}\n coverage json: {coverageJSONFile}")
print(dedent(f"""\
DEBUG:
unittest xml: {unittestXMLFile}
merged unittest xml: {mergedUnittestXMLFile}
coverage html: {coverageHTMLDirectory}
coverage xml: {coverageXMLFile}
coverage json: {coverageJSONFile}
"""))

128
.github/workflows/InstallPackage.yml vendored Normal file
View File

@@ -0,0 +1,128 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# #
# ==================================================================================================================== #
# Copyright 2025-2025 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Install Package
on:
workflow_call:
inputs:
jobs:
description: 'JSON list with environment fields, telling the system and Python versions to run tests with.'
required: true
type: string
wheel:
description: "Wheel package as input artifact."
required: true
type: string
package_name:
description: "Name of the Python package."
required: true
type: string
jobs:
PackageInstallation:
name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Package installation 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: 📥 Download artifacts '${{ inputs.wheel }}' from 'Package' job
uses: pyTooling/download-artifact@v4
with:
name: ${{ inputs.wheel }}
path: install
- name: '🟦 Setup MSYS2 for ${{ matrix.runtime }}'
uses: msys2/setup-msys2@v2
if: matrix.system == 'msys2'
with:
msystem: ${{ matrix.runtime }}
update: true
pacboy: >-
python-pip:p python-wheel:p
python-lxml:p
python-ruamel-yaml:p python-ruamel.yaml.clib:p
python-tomli:p
- name: 🐍 Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
if: matrix.system != 'msys2'
with:
python-version: ${{ matrix.python }}
- name: 🔧 Install wheel and pip dependencies (native)
if: matrix.system != 'msys2'
run: |
python -m pip install --disable-pip-version-check -U wheel
- name: 🔧 Install wheel from artifact (Ubuntu/macOS)
if: matrix.system != 'windows'
run: |
python -m pip install --disable-pip-version-check -U install/*.whl
- name: 🔧 Install wheel from artifact (Windows)
if: matrix.system == 'windows'
run: |
python -m pip install -v --disable-pip-version-check (Get-Item .\install\*.whl).FullName
- name: 📦 Run application tests (Ubuntu/macOS)
if: matrix.system != 'windows'
run: |
set +e
ANSI_LIGHT_RED=$'\x1b[91m'
ANSI_LIGHT_GREEN=$'\x1b[92m'
ANSI_NOCOLOR=$'\x1b[0m'
printf "Import package and checking package version ...\n "
python3 - << EOF | tee ImportTest.log | grep -E "^Package version:\s+[0-9]+\.[0-9]+\.[0-9]+"
from ${{ inputs.package_name }} import __version__
print(f"Package version: {__version__}")
EOF
if [[ $? -eq 0 ]]; then
printf " ${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}\n"
else
printf " ${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}\n"
printf "::error title=%s::%s\n" "InstallPackage" "Couldn't check package version of '${{ inputs.package_name }}'."
exit 1
fi
- name: 📦 Run application tests (Windows)
if: matrix.system == 'windows'
run: |
$result=$(python -c "from ${{ inputs.package_name }} import __version__; print(f""Package version: {__version__}"")")
Write-Host $result
if ($result -match "Package version:\s+\d+\.\d+\.\d+") {
Write-Host -ForegroundColor Green "[PASSED]"
} else {
Write-Host -ForegroundColor Red "[FAILED]"
Write-Host ("::error title={0}::{1}" -f "InstallPackage", "Couldn't check package version of '${{ inputs.package_name }}'.")
exit 1
}

View File

@@ -13,6 +13,12 @@ jobs:
with:
package_name: pyDummy
InstallParams:
uses: pyTooling/Actions/.github/workflows/Parameters.yml@dev
with:
package_name: pyDummy
python_version_list: ''
UnitTestingParams:
uses: pyTooling/Actions/.github/workflows/Parameters.yml@dev
with:
@@ -90,12 +96,24 @@ jobs:
uses: pyTooling/Actions/.github/workflows/Package.yml@dev
needs:
- UnitTestingParams
- UnitTesting
- PlatformTesting
# - UnitTesting
# - PlatformTesting
with:
python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}
Install:
uses: pyTooling/Actions/.github/workflows/InstallPackage.yml@dev
needs:
- ConfigParams
- UnitTestingParams
- InstallParams
- Package
with:
jobs: ${{ needs.InstallParams.outputs.python_jobs }}
wheel: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}
package_name: ${{ needs.ConfigParams.outputs.package_fullname }}
PublishCoverageResults:
uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@dev
needs:
@@ -194,6 +212,7 @@ jobs:
- Prepare
- UnitTesting
- PlatformTesting
- Install
# - StaticTypeCheck
- Package
- PublishToGitHubPages
@@ -211,6 +230,7 @@ jobs:
- Prepare
- UnitTesting
- PlatformTesting
- Install
# - StaticTypeCheck
- Package
- PublishToGitHubPages