From e67b5f3c22119f4c40e0e096aa8fae225b699123 Mon Sep 17 00:00:00 2001 From: Nicolas Menard-Guy Date: Thu, 16 Jun 2022 12:07:01 -0400 Subject: [PATCH 1/5] No pip on setup to avoid requirements.txt not found error --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 5ec2538..0908f73 100644 --- a/action.yml +++ b/action.yml @@ -85,7 +85,6 @@ runs: with: python-version: ${{ inputs.python-version }} architecture: x64 - cache: pip - run: python --version shell: bash From 53d752ea17dd2d68c87e5718865eaa573f5793d0 Mon Sep 17 00:00:00 2001 From: Nicolas Menard-Guy Date: Thu, 16 Jun 2022 12:42:12 -0400 Subject: [PATCH 2/5] Upgrade black to get fix for "cannot import name '_unicodefun' from 'click'" https://github.com/psf/black/pull/2966 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 73b61ff..6a1b72a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -black==21.11b1 +black~=22.3.0 flake8==4.0.1 isort==5.10.1 mypy~=0.961 From 2f80fe26ab14eca4402cfc7d380aaaf4242ae891 Mon Sep 17 00:00:00 2001 From: Nicolas Menard-Guy Date: Tue, 21 Jun 2022 10:54:25 -0400 Subject: [PATCH 3/5] Asking user to provide a requirements.txt file --- README.md | 16 +++------------- action.yml | 5 +++-- examples/actions-pipenv_requirements.yml | 20 ++++++++++++++++++++ requirements.txt | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 examples/actions-pipenv_requirements.yml diff --git a/README.md b/README.md index f1b3a49..3138e55 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,9 @@ steps: python-version: "3.7" ``` -### Examples +### 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 @@ -58,18 +59,7 @@ Uses `actions/setup-python@v2`. Only python `3.6` - `3.10` version are tested si 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 diff --git a/action.yml b/action.yml index 0908f73..d10fde3 100644 --- a/action.yml +++ b/action.yml @@ -85,18 +85,19 @@ runs: with: python-version: ${{ inputs.python-version }} architecture: x64 + cache: pip # Installs project's dependencies - run: python --version shell: bash - - name: Windows install dependencies + - name: Windows install linter dependencies if: ${{ runner.os == 'Windows' }} run: | pip install -r ${{ github.action_path }}\requirements.txt echo "path_sep=" >> $GITHUB_ENV shell: pwsh - - name: Posix install dependencies + - name: Posix install linter dependencies if: ${{ runner.os != 'Windows' }} run: pip install -r ${{ github.action_path }}/requirements.txt shell: bash diff --git a/examples/actions-pipenv_requirements.yml b/examples/actions-pipenv_requirements.yml new file mode 100644 index 0000000..85ff586 --- /dev/null +++ b/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: | + pip install pipenv + pipenv requirements > requirements.txt + - uses: marian-code/python-lint-annotate@v3 diff --git a/requirements.txt b/requirements.txt index 6a1b72a..3201eae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ mypy~=0.961 pycodestyle==2.8.0 pydocstyle==6.1.1 pylint==2.12.1 -vulture==2.3 \ No newline at end of file +vulture==2.3 From f59a6e1b9e6319425e8902247304d581944ecec6 Mon Sep 17 00:00:00 2001 From: Nicolas Menard-Guy Date: Tue, 21 Jun 2022 10:54:38 -0400 Subject: [PATCH 4/5] Added info --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3138e55..0f3aaf0 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ steps: python-version: "3.7" ``` +> :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) From 75802e72554f257bac7610529c68ee25f1a3c085 Mon Sep 17 00:00:00 2001 From: Nicolas Menard-Guy Date: Tue, 21 Jun 2022 11:14:19 -0400 Subject: [PATCH 5/5] Install project dependencies --- action.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index d10fde3..473906d 100644 --- a/action.yml +++ b/action.yml @@ -85,21 +85,21 @@ runs: with: python-version: ${{ inputs.python-version }} architecture: x64 - cache: pip # Installs project's dependencies - - - run: python --version - shell: bash + cache: pip - - name: Windows install linter dependencies + - 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 linter dependencies + - 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 shell: bash - name: Lint on Windows