Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .coveragerc

This file was deleted.

4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 119
exclude = src/spdx/parser/tagvalue/parsetab.py
extend-ignore = E203
33 changes: 33 additions & 0 deletions .github/workflows/check_codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run Linter

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
check_code_style:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Installation
run: pip install ".[codestyle]"
- name: Check code with isort
run: |
isort src tests --check
black src tests --check
flake8 src tests
2 changes: 1 addition & 1 deletion .github/workflows/install_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Install and Test
on:
push:
branches:
- refactor-python-tools
- main
pull_request:
workflow_dispatch:

Expand Down
33 changes: 23 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,36 @@ Here's the process to make changes to the codebase:
of [the Developer Certificate of Origin](https://developercertificate.org/). Git has utilities for signing off on
commits: `git commit -s` or `--signoff` signs a current commit, and `git rebase --signoff <revision-range>`
retroactively signs a range of past commits.

6. Test your changes:
```sh
python setup.py test # in the repo root
pip install pytest
pytest -vvs # in the repo root
```
You may use other test runners, such as `pytest` or `nose` at your preference.
7. Push the branch to your fork on GitHub:

7. Check your code style. When opening a pull request, your changes will automatically be checked with `isort`, `black`
and `flake8` to make sure your changes fit with the rest of the code style.
```sh
pip install .[code_style]
# run the following commands in the repo root
isort src tests
black src tests
flake8 src tests
```
`black` and `isort` will automatically format the code and sort the imports. The configuration for these linters
can be found in the `pyproject.toml`. `flake8` lists all problems found which then need to be resolved manually.
The configuration for the linter can be found in the `.flake8` file.

8. Push the branch to your fork on GitHub:
```sh
git push origin fix-or-improve-something
```
8. Make a pull request on GitHub.
9. Continue making more changes and commits on the branch, with `git commit --signoff` and `git push`.
10. When done, write a comment on the PR asking for a code review.
11. Some other developer will review your changes and accept your PR. The merge should be done with `rebase`, if
9. Make a pull request on GitHub.
10. Continue making more changes and commits on the branch, with `git commit --signoff` and `git push`.
11. When done, write a comment on the PR asking for a code review.
12. Some other developer will review your changes and accept your PR. The merge should be done with `rebase`, if
possible, or with `squash`.
12. The temporary branch on GitHub should be deleted (there is a button for deleting it).
13. Delete the local branch as well:
13. The temporary branch on GitHub should be deleted (there is a button for deleting it).
14. Delete the local branch as well:
```sh
git checkout master
git pull -p
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dynamic = ["version"]

[project.optional-dependencies]
test = ["pytest"]
code_style = ["isort", "black", "flake8"]

[project.scripts]
pyspdxtools = "spdx.clitools.pyspdxtools:main"
Expand All @@ -50,3 +51,11 @@ git_describe_command = ["git", "describe", "--dirty", "--tags", "--long", "--mat

[tool.aliases]
release = "clean --all sdist --formats=gztar bdist_wheel"

[tool.black]
line-length = 119
include = "(^/src/.*.py|^/tests/.*.py)"

[tool.isort]
profile = "black"
line_length = 119
25 changes: 0 additions & 25 deletions tox.ini

This file was deleted.