Adding input use-external-python; adding workflow tests for this case #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | ||
push: | ||
pull_request: | ||
name: Check python installation | ||
jobs: | ||
pythoninstall: | ||
name: Test Python install | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | ||
use-external-python: [true, false] | ||
env: | ||
python-test-package: python-dummy | ||
steps: | ||
- name: Get the branch name | ||
id: get_branch | ||
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | ||
- uses: actions/checkout@v4 | ||
- name: Install Python if required | ||
if: ${{ matrix.use-external-python }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install a test dependency if external Python is used | ||
if: ${{ matrix.use-external-python }} | ||
run: | ||
pip install ${{ env.python-test-package }} | ||
- name: Test Action usage | ||
uses: ${{ github.repository }}@${{ env.BRANCH_NAME }} | ||
with: | ||
python-root-list: "./tests/*.py ./tests/subtest/*.py" | ||
use-black: true | ||
use-isort: true | ||
use-mypy: true | ||
use-pycodestyle: true | ||
use-pydocstyle: true | ||
extra-pycodestyle-options: "--max-line-length=88" | ||
use-pylint: false | ||
use-flake8: false | ||
use-vulture: true | ||
python-version: ${{ matrix.python-version }} | ||
use-external-python: ${{ matrix.use-external-python }} | ||
- name: Check if test dependency exists after execution | ||
description: "If use-external-python is set, then python test package should be installed. False otherwise" | ||
run: | ||
pip freeze > all-deps.txt | ||
should_appear=$( if [[ "${{ matrix.use-external-python }}" == "true" ]]; then echo 0; else echo 1; fi ) | ||
line_exists=$( grep -qF "${{ env.python-test-package }}" "all-deps.txt"; echo $? ) | ||
echo "test package should be installed: ${{ matrix.use-external-python }}" | ||
test "$should_appear" == "line_exists" | ||