Skip to content

Commit 93ec7a8

Browse files
committed
ISSUE-15 New parameter to use an existing python installation.
- New parameter use-external-python to use an already installed python - Installation of requirements.txt uses --ignore-installed to avoid overriding versions defined in an external python - Adding a test workflow to check use-external-python
1 parent 0d460ff commit 93ec7a8

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
on:
2+
push:
3+
pull_request:
4+
name: Check python installation
5+
jobs:
6+
pythoninstall:
7+
name: Test Python install
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest]
12+
python-version: ['3.11']
13+
use-external-python: [true, false]
14+
env:
15+
python-test-package: python-dummy
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Python if required
20+
if: ${{ matrix.use-external-python }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install a test dependency if external Python is used
26+
if: ${{ matrix.use-external-python }}
27+
run:
28+
pip install ${{ env.python-test-package }}
29+
30+
- name: Test Action usage
31+
uses: ./
32+
with:
33+
python-root-list: "./tests/*.py ./tests/subtest/*.py"
34+
use-black: true
35+
use-isort: true
36+
use-mypy: true
37+
use-pycodestyle: true
38+
use-pydocstyle: true
39+
extra-pycodestyle-options: "--max-line-length=88"
40+
use-pylint: false
41+
use-flake8: false
42+
use-vulture: true
43+
python-version: ${{ matrix.python-version }}
44+
use-external-python: ${{ matrix.use-external-python }}
45+
46+
- name: Check if test dependency exists after execution
47+
run: |
48+
pip freeze > all-deps.txt
49+
should_appear=$( if [[ "${{ matrix.use-external-python }}" == "true" ]]; then echo 0; else echo 1; fi )
50+
line_exists=$( grep -qF "${{ env.python-test-package }}" "all-deps.txt"; echo $? )
51+
echo "test package should be installed: ${{ matrix.use-external-python }}"
52+
echo "test package is present (0 = present): ${line_exists}"
53+
cat all-deps.txt
54+
test "${should_appear}" == "${line_exists}"
55+

action.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,17 @@ inputs:
7676
description: "Set desired python version with this keyword"
7777
required: false
7878
default: "3.8"
79+
use-external-python:
80+
description: "false (default): Install a new Python for this action; true: use the python installation in the previous steps"
81+
type: boolean
82+
required: false
83+
default: false
7984

8085
runs:
8186
using: "composite"
8287
steps:
8388
- name: Setup python
89+
if: ${{ ! inputs.use-external-python }}
8490
uses: actions/setup-python@v5
8591
with:
8692
python-version: ${{ inputs.python-version }}
@@ -93,13 +99,13 @@ runs:
9399
- name: Windows install dependencies
94100
if: ${{ runner.os == 'Windows' }}
95101
run: |
96-
pip install -r ${{ github.action_path }}\requirements.txt
102+
pip install -r ${{ github.action_path }}\requirements.txt --ignore-installed
97103
echo "path_sep=" >> $GITHUB_ENV
98104
shell: pwsh
99105

100106
- name: Posix install dependencies
101107
if: ${{ runner.os != 'Windows' }}
102-
run: pip install -r ${{ github.action_path }}/requirements.txt
108+
run: pip install -r ${{ github.action_path }}/requirements.txt --ignore-installed
103109
shell: bash
104110

105111
- name: Lint on Windows

0 commit comments

Comments
 (0)