Skip to content

Commit 3fea461

Browse files
author
Florian Maas
authored
Added Python 3.7 support (#27)
* separated documentation environment and modified github workflows accordingly * added py37 to tox and github workflows * added importlib-metadata dependency for python 3.7 * fixed unit tests * added python version button to README
1 parent bbdc7d2 commit 3fea461

File tree

29 files changed

+926
-1958
lines changed

29 files changed

+926
-1958
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "check-docs"
2+
description: "Composite action to verify the documentation."
3+
inputs:
4+
python-version:
5+
required: false
6+
description: "The python version to use"
7+
default: 3.9.7
8+
runs:
9+
using: "composite"
10+
steps:
11+
#----------------------------------------------
12+
# from: https://github.com/snok/install-poetry
13+
# check-out repo and set-up python
14+
#----------------------------------------------
15+
- name: Check out repository
16+
uses: actions/checkout@v2
17+
- name: Set up python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: ${{ inputs.python-version }}
21+
22+
#----------------------------------------------
23+
# ----- install & configure poetry -----
24+
#----------------------------------------------
25+
- name: Install Poetry
26+
uses: snok/install-poetry@v1
27+
with:
28+
virtualenvs-create: true
29+
virtualenvs-in-project: true
30+
installer-parallel: true
31+
32+
#----------------------------------------------
33+
# load cached venv if cache exists
34+
#----------------------------------------------
35+
- name: Load cached venv
36+
id: cached-poetry-dependencies
37+
uses: actions/cache@v2
38+
with:
39+
path: docs/.venv
40+
key: docs-venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
41+
42+
#----------------------------------------------
43+
# install dependencies if cache does not exist
44+
#----------------------------------------------
45+
- name: Install dependencies
46+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
47+
run: |
48+
cd docs
49+
poetry install --no-interaction --no-root
50+
shell: bash
51+
52+
- name: Run checks
53+
run: |
54+
cd docs
55+
poetry run mkdocs build -s
56+
shell: bash
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "deploy-docs"
2+
description: "Composite action to verify the documentation."
3+
inputs:
4+
python-version:
5+
required: false
6+
description: "The python version to use"
7+
default: 3.9.7
8+
runs:
9+
using: "composite"
10+
steps:
11+
#----------------------------------------------
12+
# from: https://github.com/snok/install-poetry
13+
# check-out repo and set-up python
14+
#----------------------------------------------
15+
- name: Check out repository
16+
uses: actions/checkout@v2
17+
- name: Set up python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: ${{ inputs.python-version }}
21+
22+
#----------------------------------------------
23+
# ----- install & configure poetry -----
24+
#----------------------------------------------
25+
- name: Install Poetry
26+
uses: snok/install-poetry@v1
27+
with:
28+
virtualenvs-create: true
29+
virtualenvs-in-project: true
30+
installer-parallel: true
31+
32+
#----------------------------------------------
33+
# load cached venv if cache exists
34+
#----------------------------------------------
35+
- name: Load cached venv
36+
id: cached-poetry-dependencies
37+
uses: actions/cache@v2
38+
with:
39+
path: docs/.venv
40+
key: docs-venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
41+
42+
#----------------------------------------------
43+
# install dependencies if cache does not exist
44+
#----------------------------------------------
45+
- name: Install dependencies
46+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
47+
run: |
48+
cd docs
49+
poetry install --no-interaction --no-root
50+
shell: bash
51+
52+
- name: Run checks
53+
run: |
54+
cd docs
55+
poetry run mkdocs gh-deploy --force
56+
shell: bash

.github/actions/setup-poetry-env/action.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# checkout-and-yarn/action.yml
2-
31
name: "setup-poetry-env"
42
description: "Composite action to setup the Python and poetry environment."
53
inputs:
@@ -38,7 +36,7 @@ runs:
3836
uses: actions/cache@v2
3937
with:
4038
path: .venv
41-
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
39+
key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
4240

4341
#----------------------------------------------
4442
# install dependencies if cache does not exist
@@ -53,6 +51,7 @@ runs:
5351
- name: Install library
5452
run: poetry install --no-interaction
5553
shell: bash
54+
5655
- name: Activate environment
5756
run: source .venv/bin/activate
5857
shell: bash

.github/workflows/on-merge-to-main.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,12 @@ jobs:
2121
- name: Run checks
2222
uses: ./.github/actions/run-checks
2323

24-
- name: Documentation Test
25-
run: |
26-
source .venv/bin/activate
27-
make docs-test
28-
2924
tox:
3025
runs-on: ubuntu-latest
3126
needs: quality
3227
strategy:
3328
matrix:
34-
python-version: ['3.8', '3.9', '3.10']
29+
python-version: ['3.7', '3.8', '3.9', '3.10']
3530
steps:
3631
- name: Check out
3732
uses: actions/checkout@v2
@@ -45,4 +40,15 @@ jobs:
4540
run: |
4641
source .venv/bin/activate
4742
poetry add tox-gh-actions
48-
tox
43+
tox
44+
45+
check-docs:
46+
runs-on: ubuntu-latest
47+
needs: quality
48+
steps:
49+
50+
- name: Check out
51+
uses: actions/checkout@v2
52+
53+
- name: check documentation
54+
uses: ./.github/actions/check-docs

.github/workflows/on-pull-request.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,12 @@ jobs:
1818
- name: Run checks
1919
uses: ./.github/actions/run-checks
2020

21-
- name: Documentation Test
22-
run: |
23-
source .venv/bin/activate
24-
make docs-test
25-
2621
tox:
2722
runs-on: ubuntu-latest
2823
needs: quality
2924
strategy:
3025
matrix:
31-
python-version: ['3.8', '3.9', '3.10']
26+
python-version: ['3.7', '3.8', '3.9', '3.10']
3227
steps:
3328
- name: Check out
3429
uses: actions/checkout@v2
@@ -43,3 +38,17 @@ jobs:
4338
source .venv/bin/activate
4439
poetry add tox-gh-actions
4540
tox
41+
42+
check-docs:
43+
runs-on: ubuntu-latest
44+
needs: quality
45+
steps:
46+
47+
- name: Check out
48+
uses: actions/checkout@v2
49+
50+
- name: check documentation
51+
uses: ./.github/actions/check-docs
52+
53+
54+

.github/workflows/on-release-main.yml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@ jobs:
2020
- name: Run checks
2121
uses: ./.github/actions/run-checks
2222

23-
- name: Documentation Test
24-
run: |
25-
source .venv/bin/activate
26-
make docs-test
27-
2823
tox:
2924
needs: quality
3025
runs-on: ubuntu-latest
3126
strategy:
3227
matrix:
33-
python-version: ['3.8', '3.9', '3.10']
28+
python-version: ['3.7', '3.8', '3.9', '3.10']
3429
steps:
3530
- name: Check out
3631
uses: actions/checkout@v2
@@ -46,6 +41,18 @@ jobs:
4641
poetry add tox-gh-actions
4742
tox
4843
44+
45+
check-docs:
46+
runs-on: ubuntu-latest
47+
needs: quality
48+
steps:
49+
50+
- name: Check out
51+
uses: actions/checkout@v2
52+
53+
- name: check documentation
54+
uses: ./.github/actions/check-docs
55+
4956
publish:
5057
runs-on: ubuntu-latest
5158
needs: tox
@@ -70,18 +77,15 @@ jobs:
7077
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
7178
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
7279

73-
documentation:
80+
81+
deploy-docs:
7482
runs-on: ubuntu-latest
75-
needs: publish
83+
needs: quality
7684
steps:
77-
85+
7886
- name: Check out
7987
uses: actions/checkout@v2
8088

81-
- name: Set up the environment
82-
uses: ./.github/actions/setup-poetry-env
83-
84-
- name: Generate documentation
85-
run: |
86-
source .venv/bin/activate
87-
mkdocs gh-deploy --force
89+
- name: check documentation
90+
uses: ./.github/actions/deploy-docs
91+

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ publish: ## publish a release to pypi.
3939
build-and-publish: build publish ## Build and publish.
4040

4141
docs-test: ## Test if documentation can be built without warnings or errors
42-
@mkdocs build -s
42+
@( cd docs ; poetry run mkdocs build -s)
4343

4444
docs: ## Build and serve the documentation
45-
@mkdocs serve
45+
@( cd docs ; poetry run mkdocs serve )
4646

4747
.PHONY: docs
4848

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Release](https://img.shields.io/github/v/release/fpgmaas/deptry)](https://img.shields.io/github/v/release/fpgmaas/deptry)
44
[![Build status](https://img.shields.io/github/workflow/status/fpgmaas/deptry/merge-to-main)](https://img.shields.io/github/workflow/status/fpgmaas/deptry/merge-to-main)
5-
[![Commit activity](https://img.shields.io/github/commit-activity/m/fpgmaas/deptry)](https://img.shields.io/github/commit-activity/m/fpgmaas/deptry)
5+
[![Supported Python versions](https://img.shields.io/pypi/pyversions/deptry)](https://pypi.org/project/deptry/)
66
[![Docs](https://img.shields.io/badge/docs-gh--pages-blue)](https://fpgmaas.github.io/deptry/)
77
[![Code style with black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
88
[![Imports with isort](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/)

deptry/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def _override_config_with_pyproject_toml(self) -> None:
3333
pyproject_toml_config = self._read_configuration_from_pyproject_toml()
3434
if pyproject_toml_config:
3535
self._override_with_toml_argument("ignore_dependencies", List[str], pyproject_toml_config)
36+
self._override_with_toml_argument("ignore_directories", List[str], pyproject_toml_config)
37+
self._override_with_toml_argument("ignore_notebooks", List[str], pyproject_toml_config)
3638

3739
def _read_configuration_from_pyproject_toml(self) -> Optional[Dict]:
3840
try:

deptry/core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from pathlib import Path
23
from typing import List
34

@@ -12,6 +13,10 @@ def __init__(self, ignore_dependencies: List[str], ignore_directories: List[str]
1213
self.ignore_dependencies = ignore_dependencies
1314
self.ignore_directories = ignore_directories
1415
self.ignore_notebooks = ignore_notebooks
16+
logging.debug("Running with the following configuration:")
17+
logging.debug(f"ignore_dependencies: {ignore_dependencies}")
18+
logging.debug(f"ignore_directories: {ignore_directories}")
19+
logging.debug(f"ignore_notebooks: {ignore_notebooks}")
1520

1621
def run(self) -> List[str]:
1722
all_python_files = PythonFileFinder(

0 commit comments

Comments
 (0)