Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requirements not found error + fix for error in black #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 7 additions & 13 deletions README.md
Expand Up @@ -49,27 +49,21 @@ steps:
python-version: "3.7"
```

### Examples
> :information_source: python-lint-annotate expects a `requirements.txt` file in your project.
> See example to generate one with `pipenv`.
> Leave an empty one if needed.

### More Examples
* [Only lint changed files, and ignore missing docstrings](examples/actions-only_changed_files.yml)
* [Install requirements from pipenv and lint all files](examples/actions-pipenv_requirements.yml)

## Details

Uses `actions/setup-python@v2`. Only python `3.6` - `3.10` version are tested since
they are by far most common now. Other python `3.x` versions should also work.
Any python `2.x` versions are unsupported! You can lint on Linux, Windows and MacOS.

The lintner versions are:

```bash
pycodestyle==2.8.0
pydocstyle==6.1.1
pylint==2.12.1
mypy==0.910
black==21.11b1
flake8==4.0.1
vulture==2.3
isort==5.10.1
```
The linter versions are defined in [requirements.txt](requirements.txt)

## IMPORTANT - test environment

Expand Down
10 changes: 5 additions & 5 deletions action.yml
Expand Up @@ -86,20 +86,20 @@ runs:
python-version: ${{ inputs.python-version }}
architecture: x64
cache: pip

- run: python --version
shell: bash

- name: Windows install dependencies
if: ${{ runner.os == 'Windows' }}
run: |
pip install -r ${{ github.action_path }}\requirements.txt
pip install -r requirements.txt # project's dependencies
pip install -r ${{ github.action_path }}\requirements.txt # linters
echo "path_sep=" >> $GITHUB_ENV
shell: pwsh

- name: Posix install dependencies
if: ${{ runner.os != 'Windows' }}
run: pip install -r ${{ github.action_path }}/requirements.txt
run: |
pip install -r requirements.txt # project's dependencies
pip install -r ${{ github.action_path }}/requirements.txt # linters
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup-python's cache argument was expecting a requirements.txt but is not doing the install

See the example in their readme file:
https://github.com/actions/setup-python#caching-packages-dependencies

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i have noticed this as well. Thanks for the fix

shell: bash

- name: Lint on Windows
Expand Down
20 changes: 20 additions & 0 deletions examples/actions-pipenv_requirements.yml
@@ -0,0 +1,20 @@
name: Install requirements from pipenv and lint all files
on:
pull_request:
types: [ opened, reopened, synchronize, edited ]
jobs:
lint:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Generate requirements.txt file
run: |
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking if shouldn't just do this automatically? Check if the requirements file exists (provided by user). If not, install pipenv and generate dependencies.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have time to do that then go ahead, but I don't

pip install pipenv
pipenv requirements > requirements.txt
- uses: marian-code/python-lint-annotate@v3
4 changes: 2 additions & 2 deletions requirements.txt
@@ -1,8 +1,8 @@
black==21.11b1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to update README file

black~=22.3.0
flake8==4.0.1
isort==5.10.1
mypy~=0.961
pycodestyle==2.8.0
pydocstyle==6.1.1
pylint==2.12.1
vulture==2.3
vulture==2.3