Skip to content

Commit

Permalink
Add code quality checks for commits (#85)
Browse files Browse the repository at this point in the history
* Add code quality checks for commits

* Update travis covig file

* Fix branch in Check code quality action

* Add types for setuptools

* Call the correct make target
  • Loading branch information
martin-majlis authored Feb 23, 2024
1 parent 246154c commit a3e8c9c
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 64 deletions.
4 changes: 2 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ engines:

ratings:
paths:
- "wikipediaapi/**.py"
- "tests/**.py"
- "wikipediaapi/**.py"
- "tests/**.py"
38 changes: 38 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Check code quality

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
code-quality-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install pre-commit
run: |
python -m pip install -U pip
make requirements-dev
make requirements
- name: Install pre-commit hooks
run: |
pre-commit install
- name: Run pre-commit
run: |
pre-commit run -a
- name: Code coverage
run: |
make run-coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: martin-majlis/Wikipedia-API
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
coverage.json
*.cover
.hypothesis/

Expand Down Expand Up @@ -218,4 +219,4 @@ modules.xml



# End of https://www.gitignore.io/api/pycharm+all,jetbrains+all
# End of https://www.gitignore.io/api/pycharm+all,jetbrains+all
46 changes: 18 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,27 @@ repos:
hooks:
- id: prettier

# - repo: https://github.com/pre-commit/mirrors-autopep8
# rev: "v1.5.6"
# hooks:
# - id: autopep8

- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: local
hooks:
- id: isort
name: Run isort
entry: isort
language: python
args: ["--profile", "google", "--filter-files"]

# - repo: https://github.com/asottile/pyupgrade
# rev: v3.2.2
# hooks:
# - id: pyupgrade
# args: [--py36-plus]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
types: [file, python]
- id: black
name: Run black
entry: black
language: python
types: [file, python]
- id: flake8
name: Run flake8
entry: flake8
language: python
additional_dependencies: [flake8-bugbear]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
types: [file, python]
- id: mypy
additional_dependencies:
["types-requests", "types-cachetools", "types-aiofiles"]
name: Run mypy
entry: mypy
language: python
types: [file, python]
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
python:
# version: 3.6
setup_py_install: true
setup_py_install: true
34 changes: 15 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,24 @@ env:

language: python
python:
- '3.4'
- '3.5'
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
install:
- pip install -r requirements.txt
- pip install coverage
- pip install coveralls
- pip install -r requirements.txt
- pip install coverage
- pip install coveralls
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- make run-coverage
- coverage xml
- make run-coverage
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
- coveralls
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
- coveralls
deploy:
provider: pypi
skip_existing: true
Expand All @@ -36,4 +32,4 @@ deploy:
on:
tags: true
after_sucess:
- CODECLIMATE_REPO_TOKEN=d62b9e265b625e28f256147e9636d8fc1abe9f540d4fc82f9f8976171676cec4 codeclimate-test-reporter
- CODECLIMATE_REPO_TOKEN=d62b9e265b625e28f256147e9636d8fc1abe9f540d4fc82f9f8976171676cec4 codeclimate-test-reporter
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ run-tox:
run-coverage:
coverage run --source=wikipediaapi -m unittest discover tests/ '*test.py'
coverage report -m
coverage xml

requirements:
pip3 install -r requirements.txt
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ This will help you determine if the problem is in the library or somewhere else.

.. code-block:: python
import wikipediaapi
import sys
import wikipediaapi
wikipediaapi.log.setLevel(level=wikipediaapi.logging.DEBUG)
# Set handler if you use Python in interactive mode
Expand Down
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ coverage==7.4.2
flake8==7.0.0
isort==5.12.0
mypy==1.4.1
pre-commit==3.3
pygments==2.17.2
sphinx==7.0.1
tox==4.6.3
types-requests==2.31.0
types-setuptools==69.1.0.20240223
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
requests==2.31.0
typing
2 changes: 1 addition & 1 deletion wikipediaapi/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
:members:
:undoc-members:
:member-order: bysource
:exclude-members: __module__, __weakref__
:exclude-members: __module__, __weakref__

0 comments on commit a3e8c9c

Please sign in to comment.