From 7fea624b5c3a8cafeb0361731ca0c5022fcaadeb Mon Sep 17 00:00:00 2001 From: Simon Brugman Date: Thu, 19 Jan 2023 13:46:21 +0100 Subject: [PATCH] ci: tox with Github actions --- .appveyor.yml | 53 -------------------------------- .coveragerc.in | 8 ----- .github/workflows/ci.yml | 33 ++++++++++++++++++++ pyproject.toml | 65 ++++++++++++++++++++++++++++++++++++++++ tox.ini | 58 ++++++++++++++++++++++++----------- 5 files changed, 138 insertions(+), 79 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .coveragerc.in create mode 100644 .github/workflows/ci.yml create mode 100644 pyproject.toml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 232acf5..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (c) 2020 Hong Xu - -# This file is part of flake8-executable. - -# flake8-executable is free software: you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. - -# flake8-executable is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License -# for more details. - -# You should have received a copy of the GNU Lesser General Public License -# along with flake8-executable. If not, see . - - -environment: - matrix: - - TOXENV: lint - PYTHON_VERSION: 3.10 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 - - TOXENV: py39 - PYTHON_VERSION: 3.9 - APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2019" - - TOXENV: py37 - PYTHON_VERSION: 3.7 - APPVEYOR_BUILD_WORKER_IMAGE: macOS - - TOXENV: py38 - PYTHON_VERSION: 3.8 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu1804 - - TOXENV: py39 - PYTHON_VERSION: 3.9 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 - - TOXENV: py310 - PYTHON_VERSION: 3.10 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 - -build: false - -install: - # AppVeyor requires us to manually source a virtualenv for non-Windows tests. This line is allowed to fail (and should - # fail) on Windows images. - - source ~/venv${PYTHON_VERSION}/bin/activate || (exit 0) - - pip install -U tox - -test_script: - - tox -vv - -branches: - only: - - master diff --git a/.coveragerc.in b/.coveragerc.in deleted file mode 100644 index 7c7d57c..0000000 --- a/.coveragerc.in +++ /dev/null @@ -1,8 +0,0 @@ -[coverage:run] -source = flake8_executable - -[coverage:report] -fail_under = 100 -show_missing = True -exclude_lines = - pragma: no cover {platform} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..10829c7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: [ push, pull_request ] + +jobs: + test: + strategy: + matrix: + python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] + os: [ ubuntu-latest, macos-latest, windows-latest ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v3 + name: Configure pip caching + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: | + pip install --upgrade pip + pip install tox-gh-actions + pip install -e '.[dev]' + - name: Test with tox + run: tox -vv + env: + PLATFORM: ${{ matrix.platform }} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..62f9366 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,65 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = ["setuptools>=61.2"] + +[project] +name = "flake8-executable" +description="A Flake8 plugin for checking executable permissions and shebangs." +readme="README.md" +keywords=["flake8", "linter","qa", "shebang"] +authors = [ + {name = "Hong Xu", email = "hong@topbug.net"}, + {name = "Simon Brugman", email = "sfbbrugman@gmail.com"}, +] +license={text = 'LGPL v3+'} +requires-python=">=3.7" +classifiers=[ + "Environment :: Console", + "Framework :: Flake8", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: Quality Assurance", +] +dependencies = [ + "flake8>=5", +] +dynamic = ["version"] + +[project.urls] +url="https://github.com/xuhdev/flake8-executable" + +[tool.setuptools.packages] +find = {} + +[project.optional-dependencies] +dev = [ + "tox>=3", + "flake8-executable[test]", + "flake8-executable[lint]", +] +lint = [ + "pre-commit", +] +test = [ + "pytest", + "coverage", +] + +[project.entry-points] +"flake8.extension" = {EXE00 = "flake8_executable:ExecutableChecker"} + +[tool.setuptools.dynamic] +version = {attr = "flake8_executable.__version__"} + +[tool.bandit] +exclude_dirs = ["/.eggs", "/tests"] diff --git a/tox.ini b/tox.ini index ce17727..fa46f72 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Hong Xu +# Copyright (c) 2020 Hong Xu , 2023 Simon Brugman # This file is part of flake8-executable. @@ -16,9 +16,25 @@ # along with flake8-executable. If not, see . [tox] -minversion = 3.20 -envlist = py{36,37,38,39}-{linux,macos,windows} +minversion = 4.0 +envlist = py{37,38,39,310,311}-{linux,macos,windows}, lint skipsdist = True +isolated_build = true +skip_missing_interpreters = true + +[gh-actions] +python = + 3.7: py37 + 3.8: py38 + 3.9: py39, lint + 3.10: py310 + 3.11: py311 + +[gh-actions:env] +PLATFORM = + ubuntu-latest: linux + macos-latest: macos + windows-latest: windows [testenv] download = True @@ -30,30 +46,36 @@ setenv = linux: PLATFORM = linux macos: PLATFORM = macos windows: PLATFORM = windows +allowlist_externals = + coverage + pre-commit -[testenv:py{36,37,38,39}-{linux,macos,windows}] -deps = -rrequirements/test.txt +[testenv:py{37,38,39,310,311}-{linux,macos,windows}] +extras = test setenv = {[testenv]setenv} - COVERAGE_RCFILE = {envtmpdir}/coveragerc -commands_pre = - {envpython} -c 'from pathlib import Path; Path(r"{env:COVERAGE_RCFILE}").write_text(Path(".coveragerc.in").read_text().format(platform="{env:PLATFORM}"))' commands = coverage run -m pytest -v coverage report +[coverage:run] +source = flake8_executable + +[coverage:report] +fail_under = 100 +show_missing = True +exclude_lines = + pragma: no cover {platform} + [testenv:lint] -deps = -rrequirements/lint.txt -commands = - flake8 . - bandit -r . - mypy flake8_executable +description = lint using pre-commit +passenv = + {[testenv]passenv} +extras = lint +skip_install = true +commands = pre-commit run --all-files --show-diff-on-failure [testenv:dev] description = development environment with all deps at {envdir} -deps = -rrequirements-dev.txt +extras = dev commands = python -c "print(r'{envpython}')" - -[flake8] -max-line-length = 120 -exclude = .eggs,.git,__pycache__,to-be-tested,.tox