Skip to content

Adding input use-external-python; adding workflow tests for this case #1

Adding input use-external-python; adding workflow tests for this case

Adding input use-external-python; adding workflow tests for this case #1

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 }}"

Check failure on line 56 in .github/workflows/test-python-install.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/test-python-install.yml

Invalid workflow file

You have an error in your yaml syntax on line 56
test "$should_appear" == "line_exists"