|
| 1 | +# ==================================================================================================================== # |
| 2 | +# Authors: # |
| 3 | +# Patrick Lehmann # |
| 4 | +# # |
| 5 | +# ==================================================================================================================== # |
| 6 | +# Copyright 2025-2025 The pyTooling Authors # |
| 7 | +# # |
| 8 | +# Licensed under the Apache License, Version 2.0 (the "License"); # |
| 9 | +# you may not use this file except in compliance with the License. # |
| 10 | +# You may obtain a copy of the License at # |
| 11 | +# # |
| 12 | +# http://www.apache.org/licenses/LICENSE-2.0 # |
| 13 | +# # |
| 14 | +# Unless required by applicable law or agreed to in writing, software # |
| 15 | +# distributed under the License is distributed on an "AS IS" BASIS, # |
| 16 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # |
| 17 | +# See the License for the specific language governing permissions and # |
| 18 | +# limitations under the License. # |
| 19 | +# # |
| 20 | +# SPDX-License-Identifier: Apache-2.0 # |
| 21 | +# ==================================================================================================================== # |
| 22 | +name: Install Package |
| 23 | + |
| 24 | +on: |
| 25 | + workflow_call: |
| 26 | + inputs: |
| 27 | + jobs: |
| 28 | + description: 'JSON list with environment fields, telling the system and Python versions to run tests with.' |
| 29 | + required: true |
| 30 | + type: string |
| 31 | + wheel: |
| 32 | + description: "Wheel package as input artifact." |
| 33 | + required: false |
| 34 | + default: '' |
| 35 | + type: string |
| 36 | +# requirements: |
| 37 | +# description: 'Python dependencies to be installed through pip.' |
| 38 | +# required: false |
| 39 | +# default: '-r tests/requirements.txt' |
| 40 | +# type: string |
| 41 | +# pacboy: |
| 42 | +# description: 'MSYS2 dependencies to be installed through pacboy (pacman).' |
| 43 | +# required: false |
| 44 | +# default: "" |
| 45 | +# type: string |
| 46 | +# mingw_requirements: |
| 47 | +# description: 'Override Python dependencies to be installed through pip on MSYS2 (MINGW64) only.' |
| 48 | +# required: false |
| 49 | +# default: '' |
| 50 | +# type: string |
| 51 | +# root_directory: |
| 52 | +# description: 'Working directory for running tests.' |
| 53 | +# required: false |
| 54 | +# default: '' |
| 55 | +# type: string |
| 56 | +# tests_directory: |
| 57 | +# description: 'Path to the directory containing tests (relative to root_directory).' |
| 58 | +# required: false |
| 59 | +# default: 'tests' |
| 60 | +# type: string |
| 61 | +# apptest_directory: |
| 62 | +# description: 'Path to the directory containing application tests (relative to tests_directory).' |
| 63 | +# required: false |
| 64 | +# default: 'app' |
| 65 | +# type: string |
| 66 | +# apptest_xml_artifact: |
| 67 | +# description: "Generate application test report with junitxml and upload results as an artifact." |
| 68 | +# required: false |
| 69 | +# default: '' |
| 70 | +# type: string |
| 71 | + |
| 72 | +jobs: |
| 73 | + PackageInstallation: |
| 74 | + name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Package installation using Python ${{ matrix.python }} |
| 75 | + runs-on: ${{ matrix.runs-on }} |
| 76 | + |
| 77 | + strategy: |
| 78 | + fail-fast: false |
| 79 | + matrix: |
| 80 | + include: ${{ fromJson(inputs.jobs) }} |
| 81 | + |
| 82 | + defaults: |
| 83 | + run: |
| 84 | + shell: ${{ matrix.shell }} |
| 85 | + |
| 86 | + steps: |
| 87 | + - name: 📥 Download artifacts '${{ inputs.wheel }}' from 'Package' job |
| 88 | + uses: pyTooling/download-artifact@v4 |
| 89 | + with: |
| 90 | + name: ${{ inputs.wheel }} |
| 91 | + path: install |
| 92 | + |
| 93 | +# - name: Compute pacman/pacboy packages |
| 94 | +# id: pacboy |
| 95 | +# if: matrix.system == 'msys2' |
| 96 | +# shell: python |
| 97 | +# run: | |
| 98 | +# from os import getenv |
| 99 | +# from pathlib import Path |
| 100 | +# from re import compile |
| 101 | +# from sys import version |
| 102 | +# |
| 103 | +# print(f"Python: {version}") |
| 104 | +# |
| 105 | +# def loadRequirementsFile(requirementsFile: Path): |
| 106 | +# requirements = [] |
| 107 | +# with requirementsFile.open("r") as file: |
| 108 | +# for line in file.readlines(): |
| 109 | +# line = line.strip() |
| 110 | +# if line.startswith("#") or line.startswith("https") or line == "": |
| 111 | +# continue |
| 112 | +# elif line.startswith("-r"): |
| 113 | +# # Remove the first word/argument (-r) |
| 114 | +# requirements += loadRequirementsFile(requirementsFile.parent / line[2:].lstrip()) |
| 115 | +# else: |
| 116 | +# requirements.append(line) |
| 117 | +# |
| 118 | +# return requirements |
| 119 | +# |
| 120 | +# requirements = "${{ inputs.requirements }}" |
| 121 | +# if requirements.startswith("-r"): |
| 122 | +# requirementsFile = Path(requirements[2:].lstrip()) |
| 123 | +# try: |
| 124 | +# dependencies = loadRequirementsFile(requirementsFile) |
| 125 | +# except FileNotFoundError as ex: |
| 126 | +# print(f"::error title=FileNotFoundError::{ex}") |
| 127 | +# exit(1) |
| 128 | +# else: |
| 129 | +# dependencies = [req.strip() for req in requirements.split(" ")] |
| 130 | +# |
| 131 | +# packages = { |
| 132 | +# "coverage": "python-coverage:p", |
| 133 | +# "docstr_coverage": "python-pyyaml:p", |
| 134 | +# "igraph": "igraph:p", |
| 135 | +# "jinja2": "python-markupsafe:p", |
| 136 | +# "lxml": "python-lxml:p", |
| 137 | +# "numpy": "python-numpy:p", |
| 138 | +# "markupsafe": "python-markupsafe:p", |
| 139 | +# "pip": "python-pip:p", |
| 140 | +# "pyyaml": "python-pyyaml:p", |
| 141 | +# "ruamel.yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p", |
| 142 | +# "sphinx": "python-markupsafe:p", |
| 143 | +# "tomli": "python-tomli:p", |
| 144 | +# "wheel": "python-wheel:p", |
| 145 | +# "pyEDAA.ProjectModel": "python-ruamel-yaml:p python-ruamel.yaml.clib:p python-lxml:p", |
| 146 | +# "pyEDAA.Reports": "python-ruamel-yaml:p python-ruamel.yaml.clib:p python-lxml:p", |
| 147 | +# } |
| 148 | +# subPackages = { |
| 149 | +# "pytooling": { |
| 150 | +# "yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p", |
| 151 | +# } |
| 152 | +# } |
| 153 | +# |
| 154 | +# regExp = compile(r"(?P<PackageName>[\w_\-\.]+)(?:\[(?P<SubPackages>(?:\w+)(?:\s*,\s*\w+)*)\])?(?:\s*(?P<Comperator>[<>~=]+)\s*)(?P<Version>\d+(?:\.\d+)*)(?:-(?P<VersionExtension>\w+))?") |
| 155 | +# |
| 156 | +# pacboyPackages = set(("python-pip:p", "python-wheel:p", "python-tomli:p")) |
| 157 | +# print(f"Processing dependencies ({len(dependencies)}):") |
| 158 | +# for dependency in dependencies: |
| 159 | +# print(f" {dependency}") |
| 160 | +# |
| 161 | +# match = regExp.match(dependency.lower()) |
| 162 | +# if not match: |
| 163 | +# print(f" Wrong format: {dependency}") |
| 164 | +# print(f"::error title=Identifying Pacboy Packages::Unrecognized dependency format '{dependency}'") |
| 165 | +# continue |
| 166 | +# |
| 167 | +# package = match["PackageName"] |
| 168 | +# if package in packages: |
| 169 | +# rewrite = packages[package] |
| 170 | +# print(f" Found rewrite rule for '{package}': {rewrite}") |
| 171 | +# pacboyPackages.add(rewrite) |
| 172 | +# |
| 173 | +# if match["SubPackages"] and package in subPackages: |
| 174 | +# for subPackage in match["SubPackages"].split(","): |
| 175 | +# if subPackage in subPackages[package]: |
| 176 | +# rewrite = subPackages[package][subPackage] |
| 177 | +# print(f" Found rewrite rule for '{package}[..., {subPackage}, ...]': {rewrite}") |
| 178 | +# pacboyPackages.add(rewrite) |
| 179 | +# |
| 180 | +# # Write jobs to special file |
| 181 | +# github_output = Path(getenv("GITHUB_OUTPUT")) |
| 182 | +# print(f"GITHUB_OUTPUT: {github_output}") |
| 183 | +# with github_output.open("a+") as f: |
| 184 | +# f.write(f"pacboy_packages={' '.join(pacboyPackages)}\n") |
| 185 | + |
| 186 | + - name: '🟦 Setup MSYS2 for ${{ matrix.runtime }}' |
| 187 | + uses: msys2/setup-msys2@v2 |
| 188 | + if: matrix.system == 'msys2' |
| 189 | + with: |
| 190 | + msystem: ${{ matrix.runtime }} |
| 191 | + update: true |
| 192 | +# pacboy: >- |
| 193 | +# ${{ steps.pacboy.outputs.pacboy_packages }} |
| 194 | +# ${{ inputs.pacboy }} |
| 195 | + |
| 196 | + - name: 🐍 Setup Python ${{ matrix.python }} |
| 197 | + uses: actions/setup-python@v5 |
| 198 | + if: matrix.system != 'msys2' |
| 199 | + with: |
| 200 | + python-version: ${{ matrix.python }} |
| 201 | + |
| 202 | + - name: 🔧 Install wheel and pip dependencies (native) |
| 203 | + if: matrix.system != 'msys2' |
| 204 | + run: | |
| 205 | + python -m pip install --disable-pip-version-check -U wheel |
| 206 | +# python -m pip install --disable-pip-version-check ${{ inputs.requirements }} |
| 207 | + |
| 208 | +# - name: 🔧 Install pip dependencies (MSYS2) |
| 209 | +# if: matrix.system == 'msys2' |
| 210 | +# run: | |
| 211 | +# if [ -n '${{ inputs.mingw_requirements }}' ]; then |
| 212 | +# python -m pip install --disable-pip-version-check ${{ inputs.mingw_requirements }} |
| 213 | +# else |
| 214 | +# python -m pip install --disable-pip-version-check ${{ inputs.requirements }} |
| 215 | +# fi |
| 216 | + |
| 217 | + - name: 🔧 Install wheel from artifact |
| 218 | + run: | |
| 219 | + ls -l install |
| 220 | + python -m pip install --disable-pip-version-check -U install/*.whl |
| 221 | +
|
| 222 | + - name: ✅ Run application tests (Ubuntu/macOS) |
| 223 | + if: matrix.system != 'windows' |
| 224 | + run: | |
| 225 | + python3 - << EOF | tee ImportTest.log |
| 226 | + from pyEDAA.Reports import __version__ |
| 227 | +
|
| 228 | + print(f"Package version: {__version__}") |
| 229 | + EOF |
| 230 | +
|
| 231 | + ls -lAh . |
| 232 | +
|
| 233 | + - name: ✅ Run application tests (Windows) |
| 234 | + if: matrix.system == 'windows' |
| 235 | + run: | |
| 236 | + python --version |
| 237 | +
|
| 238 | +# - name: 📤 Upload 'TestReportSummary.xml' artifact |
| 239 | +# if: inputs.apptest_xml_artifact != '' |
| 240 | +# uses: pyTooling/upload-artifact@v4 |
| 241 | +# with: |
| 242 | +# name: ${{ inputs.apptest_xml_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }} |
| 243 | +# working-directory: report/unit |
| 244 | +# path: TestReportSummary.xml |
| 245 | +# if-no-files-found: error |
| 246 | +# retention-days: 1 |
0 commit comments