From 0b744011ac7252f2cd96f76b75a772c48e19f0d6 Mon Sep 17 00:00:00 2001 From: Cory Dolphin Date: Sun, 25 Jun 2023 22:35:45 -0700 Subject: [PATCH] Convert CI to use GHA (#331) Adds initial Github Actions based test and release tooling. --- .github/workflows/release.yml | 29 ++++++++++++++++++ .github/workflows/unittests.yaml | 28 ++++++++++++++++++ .travis.yml | 51 -------------------------------- flask_cors/extension.py | 2 +- setup.py | 4 +-- 5 files changed, 60 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/unittests.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..71ba6e0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,29 @@ +name: Release to PyPi + +on: + release: + types: [published] + +jobs: + deploy: + name: upload release to PyPI + runs-on: ubuntu-latest + # Specifying a GitHub environment is optional, but strongly encouraged + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.github/workflows/unittests.yaml b/.github/workflows/unittests.yaml new file mode 100644 index 0000000..2b776a3 --- /dev/null +++ b/.github/workflows/unittests.yaml @@ -0,0 +1,28 @@ +name: Python package + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ "3.8", "3.9", "3.10", "3.11"] + dependencies: + - "flask==1.1 Jinja2==3.0.3 itsdangerous==2.0.1 werkzeug==2.0.3" + - "flask==2.3.2" + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + # You can test your matrix by printing the current Python version + - name: Install deps + run: pip install -U setuptools pep8 coverage docutils pygments packaging pytest pytest-cov ${{ matrix.dependencies }} + - name: Run tests + run: | + coverage erase + python setup.py clean build install + pytest --cov=flask_cors diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8a30d01..0000000 --- a/.travis.yml +++ /dev/null @@ -1,51 +0,0 @@ -sudo: false -cache: -- pip -language: python -arch: - - amd64 - - ppc64le - - arm64 -python: - - '3.8' - - '3.9' - - '3.10' - - '3.11' - - pypy - -matrix: - exclude: - - arch: ppc64le - python: pypy - - arch: arm64 - python: pypy - - env: - - DEPEENDENCIES="flask==1.1" - -env: -- DEPEENDENCIES="flask==0.10.1 werkzeug==0.16.1" # pin werkzeug for Flask 10, 10.1 since Flask does not pin it itself. -- DEPEENDENCIES="flask==0.10 werkzeug==0.16.1" -- DEPEENDENCIES="flask==1.0" -- DEPEENDENCIES="flask==1.1" -- DEPEENDENCIES="flask==2.3.2" - -install: - - pip install -U setuptools pep8 coverage docutils pygments packaging $DEPEENDENCIES - -script: - - coverage erase - - nosetests --with-coverage --cover-package=flask_cors - - python setup.py clean build install - -after_success: - - pep8 flask_cors.py - -deploy: - provider: pypi - user: CoryDolphin - password: - secure: c/z1OYmniNlJ7F7G+TipOlJfVLCEz0F09JCJJ4+TPB/DTxajxarMEygX/LrvBOLvbe1EvAKO9p/SOagAul00YXU/rb2i1k1tJnKF2A6KKSLOsZbTcGWNcInOaLKql4Cv8Ts1cOfMiTVHBQLR+1FCw+IuZ44N+KhF0tsFOejEmRc= - distributions: "sdist bdist_wheel" - on: - tags: true - repo: corydolphin/flask-cors diff --git a/flask_cors/extension.py b/flask_cors/extension.py index 1d2d938..c00cbff 100644 --- a/flask_cors/extension.py +++ b/flask_cors/extension.py @@ -160,7 +160,7 @@ def init_app(self, app, **kwargs): for (pattern, opts) in resources ] - # Create a human readable form of these resources by converting the compiled + # Create a human-readable form of these resources by converting the compiled # regular expressions into strings. resources_human = {get_regexp_pattern(pattern): opts for (pattern,opts) in resources} LOG.debug("Configuring CORS with resources: %s", resources_human) diff --git a/setup.py b/setup.py index b10bd39..56fb7db 100644 --- a/setup.py +++ b/setup.py @@ -33,10 +33,10 @@ platforms='any', install_requires=install_requires, tests_require=[ - 'nose', + 'pytest', 'packaging' ], - test_suite='nose.collector', + test_suite='tests', classifiers=[ 'Environment :: Web Environment', 'Intended Audience :: Developers',