diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 741d3f8..dda73f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Link Status +name: Tests on: [push, pull_request] @@ -6,6 +6,7 @@ jobs: pre-commit: name: Pre-Commit Checks runs-on: ubuntu-latest + steps: - name: Checkout to master uses: actions/checkout@master @@ -13,26 +14,46 @@ jobs: - name: Setup python uses: actions/setup-python@v1 with: - python-version: '3.7' + python-version: '3.8' architecture: 'x64' - name: Pre-Commit Checks run: | - python -m pip install pre-commit - pre-commit run -a + python -m pip install pip --upgrade + pip install nox + nox -s pre_commit - name: Analysis (git diff) if: failure() run: git diff - tests: - name: Test-${{ matrix.os }}-Py${{ matrix.python-version }} + package: + name: Build & Verify Package needs: pre-commit - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest + + steps: + - name: Checkout to master + uses: actions/checkout@master + + - name: Setup python + uses: actions/setup-python@v1 + with: + python-version: '3.8' + architecture: 'x64' + - name: Build and check with twine + run: | + python -m pip install pip --upgrade + pip install nox + nox -s package + + unit-tests: + name: UnitTests-Python-${{ matrix.python-version }} + needs: [ pre-commit, package ] + runs-on: ubuntu-latest strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: [ '3.6', '3.7' ] + python-version: [ 'pypy3', '3.6', '3.7', '3.8' ] steps: - name: Checkout to master uses: actions/checkout@master @@ -43,10 +64,39 @@ jobs: python-version: ${{ matrix.python-version }} architecture: x64 - - name: Setup Package and Install Devel Dependencies + - name: Unit Tests run: | - python -m pip install -Ur dev-requirements.txt - python -m pip install . + python -m pip install pip --upgrade + pip install nox + nox -s ci_tests - - name: Unit Tests - run: py.test -v tests + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1.0.6 + with: + file: coverage.xml + flags: unittests + name: codecov-linkstatus-{{ matrix.python-version }} + fail_ci_if_error: true + + platform: + name: Platform-${{ matrix.os }} + needs: [ unit-tests] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - name: Checkout to master + uses: actions/checkout@master + + - name: Setup python + uses: actions/setup-python@v1 + with: + python-version: '3.8' + architecture: 'x64' + + - name: Development setup and smoke test on platform ${{ matrix.os }} + run: | + python -m pip install pip --upgrade + pip install nox + nox -s dev_setup diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb8b137..bb5246f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,8 @@ on: jobs: build-and-publish: name: Build and publish Python 🐍 distributions to PyPI - runs-on: ubuntu-18.04 + if: startsWith(github.event.ref, 'refs/tags') + runs-on: ubuntu-latest steps: - name: Checkout to master uses: actions/checkout@master @@ -18,16 +19,16 @@ jobs: - name: Setup python uses: actions/setup-python@v1 with: - python-version: '3.7' + python-version: '3.8' architecture: 'x64' - - name: Build Package + - name: Build Package and Check run: | - python -m pip install --upgrade setuptools wheel + python -m pip install --upgrade setuptools wheel twine python setup.py sdist bdist_wheel + python -m twine check dist/* - name: Deploy to PyPi - if: startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master with: user: __token__ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f4b90b9..27e9a98 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,15 +54,15 @@ Below is the steps for setting up a development environment ```shell git clone https://github.com/pythonpune/linkstatus cd linkstatus -virtualenv .venv +python -m venv .venv source .venv/bin/activate -python -m pip install -Ur dev-requirements.txt python -m pip install -e . linkstatus --help ``` # Run unit test with nox ```shell +python -m pip install nox nox --list # list all available sessions nox -s pre_commit # run pre-commit checks nox -s tests # run unit tests diff --git a/README.md b/README.md index 0ff23f6..ea6b212 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,10 @@

Python Versions - Build Status - License: GPLv3 PyPI version Downloads + + License: GPLv3 Code style: black

diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index 3678590..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -nox -pre-commit -pytest -ruamel.yaml diff --git a/noxfile.py b/noxfile.py index 9728113..a3ea44a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,13 +1,60 @@ import nox +nox.options.sessions = ["pre_commit", "tests"] + @nox.session def pre_commit(session): + """pre-commit checks""" session.install("pre-commit") session.run("pre-commit", "run", "-a") -@nox.session(python=["3.6", "3.7"]) +@nox.session(python=["pypy3", "3.6", "3.7", "3.8"]) def tests(session): - session.install("pytest", "ruamel.yaml", ".") - session.run("pytest", "-sqvv", "tests") + """Run unit test over different python env with code coverage""" + session.install("pytest", "pytest-cov", "ruamel.yaml", "-e", ".") + session.run( + "py.test", + "--cov=linkstatus", + "--cov-report", + "term-missing", + "--cov-branch", + "--color=yes", + "-s", + "-v", + ) + + +@nox.session() +def ci_tests(session): + """This is only to run test on ci""" + session.install("pytest", "pytest-cov", "coverage", "ruamel.yaml", "-e", ".") + session.run( + "py.test", + "--cov=linkstatus", + "--cov-report=xml", + "--cov-branch", + "--color=yes", + "-s", + "-v", + ) + session.run("coverage", "report") + + +@nox.session() +def package(session): + """Build and verify package""" + session.install("twine", "setuptools", "wheel") + session.run("python", "setup.py", "sdist", "bdist_wheel") + session.run("ls", "-l", "dist") + session.run("python", "-m", "twine", "check", "dist/*") + + +@nox.session() +def dev_setup(session): + """Ensure development environment works everywhere. mainly with ci on different platform""" + session.run("python", "-m", "pip", "install", "-e", ".[dev]") + session.run("python", "-c", "import linkstatus; print(linkstatus.__spec__)") + session.install("pytest", "ruamel.yaml") + session.run("py.test", "-v", "tests/test_linkstatus.py") diff --git a/setup.cfg b/setup.cfg index 3b2c993..a615a41 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,12 +21,13 @@ long_description = file: README.md long_description_content_type = text/markdown classifiers = Natural Language :: English - Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 Intended Audience :: End Users/Desktop Intended Audience :: Developers Environment :: Console + License :: OSI Approved :: GNU General Public License v3 (GPLv3) [options] packages = find: @@ -37,7 +38,7 @@ install_requires = markdown requests include_package_data = True -python_requires = >=3.5 +python_requires = >=3.6 [options.entry_points] console_scripts =