Skip to content

Commit

Permalink
Added Python typing hints to most of the code
Browse files Browse the repository at this point in the history
* Updated README about compatibility with Python 2.x
* Created LICENSE and CONTRIBUTING files
* Update CI pipeline to allow building only last commit and cancel
  builds in progress
* Added more unit tests for Build
  • Loading branch information
lechat committed Mar 29, 2023
1 parent b1af616 commit 99cacc3
Show file tree
Hide file tree
Showing 40 changed files with 836 additions and 739 deletions.
40 changes: 35 additions & 5 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,52 @@ name: CI_TEST

on:
push:
paths:
- 'requirements.txt'
- '**.py'
- '**.yml'
pull_request:
branches: [ "master" ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
token: ["stable", "latest"]

steps:
- uses: actions/checkout@v3
- name: Harden Runner
uses: step-security/harden-runner@1f99358870fe1c846a3ccba386cc2b2246836776 # v2.2.1
with:
egress-policy: block
allowed-endpoints: >
azure.archive.ubuntu.com:80
esm.ubuntu.com:443
files.pythonhosted.org:443
ftp-chi.osuosl.org:443
ftp-nyc.osuosl.org:443
get.jenkins.io:443
github.com:443
mirror.xmission.com:443
motd.ubuntu.com:443
packages.microsoft.com:443
ppa.launchpadcontent.net:443
pypi.org:443
updates.jenkins-ci.org:80
updates.jenkins.io:443
updates.jenkins.io:80
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
Expand Down Expand Up @@ -51,9 +82,8 @@ jobs:
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=79 --statistics
flake8 jenkinsapi/ --count --select=E9,F63,F7,F82 --ignore F821,W503,W504 --show-source --statistics
flake8 jenkinsapi/ --count --exit-zero --max-complexity=10 --max-line-length=79 --statistics
- name: Test with pytest
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ coverage.xml
*.war
venv/
tags
.pytype/
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,3 @@ repos:
- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 PyContribs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 8 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ Python versions

The project has been tested against Python versions:

* 2.7
* 3.4
* 3.5
* 3.6
* 3.7
* 2.7 - last version compatible with Python 2.7 is tagged Py2 in repository and available on PyPi as version 0.3.13
* 3.8 - 3.11

Jenkins versions
----------------
Expand Down Expand Up @@ -146,25 +143,26 @@ missing test dependencies:
virtualenv
source .venv/bin/active
(venv) python setup.py test
(.venv) pip install -r requirements.txt
(.venv) python setup.py test
Development
-----------

* Make sure that you have Java_ installed.
* Make sure that you have Java_ installed. Jenkins will be automatically
downloaded and started during tests.
* Create virtual environment for development
* Install package in development mode

.. code-block:: bash
(venv) pip install -e .
(venv) pip install -r test-requirements.txt
(.venv) pip install -r test-requirements.txt
* Make your changes, write tests and check your code

.. code-block:: bash
(venv) tox
(.venv) pytest
Project Contributors
Expand Down
13 changes: 8 additions & 5 deletions doc/source/rules_for_contributors.rst → doc/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ The JenkinsAPI project welcomes contributions via GitHub. Please bear in mind th
Python compatibility
--------------------

The project currently targets Python 2.6 and Python 2.7. Support for Python 3.x will be introduced soon. Please do not add any features which
will break our supported Python 2.x versions or make it harder for us to migrate to Python 3.x
The project currently targets Python 3.8+. Last version compatible with Python 2.7 is tagged as Py2.

Code formatting
---------------

The project follows strict PEP8 guidelines. Please use a tool like black to format your code before submitting a pull request. Tell black to use 79 characters per line (black -l 79).

Test Driven Development
-----------------------

Please do not submit pull requests without tests. That's really important. Our project is all about test-driven development. It would be
embarrasing if our project failed because of a lack of tests!
Please do not submit pull requests without tests. That's really important. Our project is all about test-driven development. It would be embarrasing if our project failed because of a lack of tests!

You might want to follow a typical test driven development cycle: http://en.wikipedia.org/wiki/Test-driven_development

Expand All @@ -24,7 +27,7 @@ Features implemented without tests will be removed. Unmaintained features (which
Check the CI status before comitting
------------------------------------

We have a Travis CI account - please verify that your branch works before making a pull request.
Project uses Github Actions, please verify that your branch passes all tests before making a pull request.

Any problems?
-------------
Expand Down
Loading

0 comments on commit 99cacc3

Please sign in to comment.