|
| 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: true |
| 34 | + type: string |
| 35 | + package_name: |
| 36 | + description: "Name of the Python package." |
| 37 | + required: true |
| 38 | + type: string |
| 39 | + |
| 40 | +jobs: |
| 41 | + PackageInstallation: |
| 42 | + name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Package installation using Python ${{ matrix.python }} |
| 43 | + runs-on: ${{ matrix.runs-on }} |
| 44 | + |
| 45 | + strategy: |
| 46 | + fail-fast: false |
| 47 | + matrix: |
| 48 | + include: ${{ fromJson(inputs.jobs) }} |
| 49 | + |
| 50 | + defaults: |
| 51 | + run: |
| 52 | + shell: ${{ matrix.shell }} |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: 📥 Download artifacts '${{ inputs.wheel }}' from 'Package' job |
| 56 | + uses: pyTooling/download-artifact@v4 |
| 57 | + with: |
| 58 | + name: ${{ inputs.wheel }} |
| 59 | + path: install |
| 60 | + |
| 61 | + - name: '🟦 Setup MSYS2 for ${{ matrix.runtime }}' |
| 62 | + uses: msys2/setup-msys2@v2 |
| 63 | + if: matrix.system == 'msys2' |
| 64 | + with: |
| 65 | + msystem: ${{ matrix.runtime }} |
| 66 | + update: true |
| 67 | + pacboy: >- |
| 68 | + python-pip:p python-wheel:p |
| 69 | + python-lxml:p |
| 70 | + python-ruamel-yaml:p python-ruamel.yaml.clib:p |
| 71 | + python-tomli:p |
| 72 | +
|
| 73 | + - name: 🐍 Setup Python ${{ matrix.python }} |
| 74 | + uses: actions/setup-python@v5 |
| 75 | + if: matrix.system != 'msys2' |
| 76 | + with: |
| 77 | + python-version: ${{ matrix.python }} |
| 78 | + |
| 79 | + - name: 🔧 Install wheel and pip dependencies (native) |
| 80 | + if: matrix.system != 'msys2' |
| 81 | + run: | |
| 82 | + python -m pip install --disable-pip-version-check -U wheel |
| 83 | +
|
| 84 | + - name: 🔧 Install wheel from artifact (Ubuntu/macOS) |
| 85 | + if: matrix.system != 'windows' |
| 86 | + run: | |
| 87 | + python -m pip install --disable-pip-version-check -U install/*.whl |
| 88 | +
|
| 89 | + - name: 🔧 Install wheel from artifact (Windows) |
| 90 | + if: matrix.system == 'windows' |
| 91 | + run: | |
| 92 | + python -m pip install -v --disable-pip-version-check (Get-Item .\install\*.whl).FullName |
| 93 | +
|
| 94 | + - name: 📦 Run application tests (Ubuntu/macOS) |
| 95 | + if: matrix.system != 'windows' |
| 96 | + run: | |
| 97 | + set +e |
| 98 | +
|
| 99 | + ANSI_LIGHT_RED=$'\x1b[91m' |
| 100 | + ANSI_LIGHT_GREEN=$'\x1b[92m' |
| 101 | + ANSI_NOCOLOR=$'\x1b[0m' |
| 102 | +
|
| 103 | + printf "Import package and checking package version ...\n " |
| 104 | + python3 - << EOF | tee ImportTest.log | grep -E "^Package version:\s+[0-9]+\.[0-9]+\.[0-9]+" |
| 105 | + from ${{ inputs.package_name }} import __version__ |
| 106 | +
|
| 107 | + print(f"Package version: {__version__}") |
| 108 | + EOF |
| 109 | + if [[ $? -eq 0 ]]; then |
| 110 | + printf " ${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}\n" |
| 111 | + else |
| 112 | + printf " ${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}\n" |
| 113 | + printf "::error title=%s::%s\n" "InstallPackage" "Couldn't check package version of '${{ inputs.package_name }}'." |
| 114 | + exit 1 |
| 115 | + fi |
| 116 | +
|
| 117 | + - name: 📦 Run application tests (Windows) |
| 118 | + if: matrix.system == 'windows' |
| 119 | + run: | |
| 120 | + $result=$(python -c "from pyEDAA.Reports import __version__; print(f""Package version: {__version__}"")") |
| 121 | + Write-Host $result |
| 122 | + if ($result -match "Package version:\s+\d+\.\d+\.\d+") { |
| 123 | + Write-Host -ForegroundColor Green "[PASSED]" |
| 124 | + } else { |
| 125 | + Write-Host -ForegroundColor Red "[FAILED]" |
| 126 | + Write-Host ("::error title={0}::{1}" -f "InstallPackage", "Couldn't check package version of '${{ inputs.package_name }}'.") |
| 127 | + exit 1 |
| 128 | + } |
0 commit comments