Skip to content

Commit 3d142c8

Browse files
authored
Merge pull request #14 from advanced-security/break-system-packages
Adding flag to work around MacOS runner issue Fixed end-to-end tests on this repo to verify Action is working
2 parents adb9d6f + 1001990 commit 3d142c8

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

.github/workflows/lint.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,33 @@ jobs:
2020
fail-fast: false
2121

2222
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v4
25+
2326
# install dependencies for all linters, then run the linter, so we don't get import failures when the linters scan the code
24-
# upgrade pip, so that we can install flake8_sarif_formatter properly from the git repo
25-
- uses: actions/checkout@v4
27+
# not required, just makes the test cases a bit cleaner
2628
- name: Install pip dependencies
29+
if: ${{ ! ( runner.os == 'macOS' && matrix.python-version == '3.7' ) }}
2730
run: |
28-
python3 -mpip install -q --upgrade pip
29-
python3 -mpip install -q flake8 pylint ruff mypy pytype pyright fixit pyre-check
30-
python3 -mpip install -q flake8-sarif-formatter
31+
# deal with HomeBrew managed Python on GitHub Hosted MacOS runners
32+
if [[ "${RUNNER_OS}" == "macOS" ]]; then
33+
PIP_ARGS="--break-system-packages"
34+
else
35+
PIP_ARGS=""
36+
fi
37+
# upgrade pip, so that we can install flake8_sarif_formatter properly from the git repo
38+
python3 -mpip install ${PIP_ARGS} -q --upgrade pip
39+
# install packages one-by-one so it is clearer which fails, if it does
40+
python_packages=('flake8' 'pylint' 'ruff' 'mypy' 'pytype' 'pyright' 'fixit' 'pyre-check' 'flake8-sarif-formatter')
41+
for package in "${python_packages[@]}"; do
42+
echo "Installing Python package ${package}"
43+
if ! python3 -mpip install ${PIP_ARGS} -q "${package}"; then
44+
echo "::warning::Failed to installed Python dependency ${package}, continuing"
45+
fi
46+
done
47+
3148
- name: Run Python Lint
49+
if: ${{ ! ( runner.os == 'macOS' && matrix.python-version == '3.7' ) }}
3250
uses: advanced-security/python-lint-code-scanning-action@main
3351
with:
3452
linter: ${{ matrix.linter }}

action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ runs:
6565
uses: actions/checkout@v4
6666

6767
- name: Set up Python
68-
uses: actions/setup-python@v5
68+
id: setup-python
69+
uses: actions/setup-python@v4
6970
with:
7071
python-version: ${{ inputs.python-version }}
7172

@@ -133,6 +134,11 @@ runs:
133134
fi
134135
fi
135136
137+
# deal with HomeBrew managed Python on GitHub Hosted MacOS runners
138+
if [[ "${RUNNER_OS}" == "macOS" ]]; then
139+
EXTRA_PIP_FLAGS="${EXTRA_PIP_FLAGS} --break-system-packages"
140+
fi
141+
136142
echo "::debug::Installing ${INPUTS_LINTER}${LINTER_VERSION_CONSTRAINT} for Python ${INPUTS_PYTHON_VERSION}"
137143
138144
# install linter

0 commit comments

Comments
 (0)