Skip to content

Commit fd01666

Browse files
authored
Merge pull request #16 from clalarco/issue-15-skip-python-installation
Resolves #15 Allow to use an external python module
2 parents ffe24b3 + 93ec7a8 commit fd01666

File tree

3 files changed

+76
-3
lines changed

3 files changed

+76
-3
lines changed

.github/workflows/all-lints.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,20 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
os: [ubuntu-latest, macos-latest, windows-latest]
11+
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
1212
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
13+
exclude:
14+
- os: macos-latest
15+
python-version: 3.8
16+
- os: macos-latest
17+
python-version: 3.9
18+
- os: macos-latest
19+
python-version: 3.10
20+
- os: macos-13
21+
python-version: 3.11
22+
- os: macos-13
23+
python-version: 3.12
24+
1325
steps:
1426
- uses: actions/checkout@v4
1527
- uses: marian-code/python-lint-annotate@master
+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)