From 37375ba3b95cc462a45b85019f117f8660be1de8 Mon Sep 17 00:00:00 2001 From: SiuHui <127535046+siuhui@users.noreply.github.com> Date: Wed, 10 Apr 2024 22:41:13 +0800 Subject: [PATCH] feat: Replace Travis CI with GitHub Actions CI and add semantic-release (#3) --- .coveragerc | 2 - .github/semantic.yml | 2 + .github/workflows/build.yml | 90 +++++++++++++++++++++++++++++++++++++ .releaserc.json | 23 ++++++++++ .travis.yml | 24 ---------- README.md | 3 +- package.json | 8 ++++ pyproject.toml | 38 ++++++++++++++++ setup.py | 32 ------------- 9 files changed, 162 insertions(+), 60 deletions(-) delete mode 100644 .coveragerc create mode 100644 .github/semantic.yml create mode 100644 .github/workflows/build.yml create mode 100644 .releaserc.json delete mode 100644 .travis.yml create mode 100644 package.json create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 2c296eb..0000000 --- a/.coveragerc +++ /dev/null @@ -1,2 +0,0 @@ -[run] -include = casbin_sqlobject_adapter/* \ No newline at end of file diff --git a/.github/semantic.yml b/.github/semantic.yml new file mode 100644 index 0000000..96f9233 --- /dev/null +++ b/.github/semantic.yml @@ -0,0 +1,2 @@ +# Always validate the PR title AND all the commits +titleAndCommits: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..87164e0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,90 @@ +name: build +on: + push: + branches: [master] + pull_request: + branches: [master] +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12"] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Upgrade install tools + run: python -m pip install --upgrade setuptools wheel + + - name: Install dependencies + run: | + pip install -r requirements.txt + + - name: Run tests + run: | + python -m unittest discover -s tests -t tests + + coveralls: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + pip install -r requirements.txt + pip install coveralls + pip install coverage + + - name: Run tests + run: coverage run -m unittest discover -s tests -t tests + + - name: Upload coverage data to coveralls.io + run: coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + release: + name: Release + runs-on: ubuntu-latest + needs: [ tests, coveralls ] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: '20' + + - name: Setup + run: npm install -g semantic-release @semantic-release/github @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/git @semantic-release/release-notes-generator semantic-release-pypi + + - name: Set up python + uses: actions/setup-python@v2 + with: + python-version: 3.11 + + - name: Install setuptools + run: python -m pip install --upgrade setuptools wheel twine + + - name: Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: npx semantic-release diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..94e24cd --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,23 @@ +{ + "branches": "master", + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "semantic-release-pypi", + "@semantic-release/github", + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md", + "changelogTitle": "# Semantic Versioning Changelog" + } + ], + [ + "@semantic-release/git", + { + "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}", + "assets": ["CHANGELOG.md", "pyproject.toml"] + } + ] + ] +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 47aa2b7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: python -python: -- '3.4' -- '3.5' -- '3.6' -- '3.7' -- '3.8' -install: -- pip install -r requirements.txt -- pip install coveralls -script: -- coverage run -m unittest discover -s tests -t tests -after_success: -- coveralls -deploy: - provider: pypi - user: techlee - password: - secure: qoBLYrYCxU3qe9SP3tCdgqVEmqEQAdCFfC/h8ENeY3dD0cyBV/yaitjY92bQxLgialouDUojiyOpvEl4apl4XQSvVhywtIqBaY5w8h1SuRUNMOkCP8LiWQt5NbsVI6Liad9IRviknsiIkW3LTqOrS+zRWmhZ6Yz/wvc+QMFY4JX51EWLPwtFTSbuiG0VtJgN9s7LgX8Q6GvNW0Alp3mfJnVTqk/HCtJuHkQwd1EK5Zr2ePO+KwlLaTpvRrAAcQVEWuHysieriTNgz9GTXvVEoGAuP/meq8DIRGDQmqnMz4vjj7oxg+gaVioUfnhN35ZrTF0wggJaCeytkSjbbDCspIc47/zaK7041ZQO9r0A1eeErkSi1dUo3WH4yO3HWfWxg5HOLN+40CYPStlmC77/jG0vvYBdmdcD8h+cRmY0W426G8xf9aqnYNzI7VP8tVceO9ySVHgeKCdVPcGRht8nHQdsNHFxUijViThtzyhf+RKF1UXbIxlZUuWirwR2+rfGSY6oYdXIb0MUBXxLqwVVIPBrQJOuaMEZG4tAVxaa3K/YiRIN5rvTZp8Ru5YrPsAyGhINg3t2JrPoyU236JIlNKliQHPVvOUftGryD/kvhpDIl+kOKFkNoMCQnolbGMGEx+ZL7g4IBpR+iNkvJNEyV1KProPdGJR5ajUuGEAmdkM= - distributions: sdist bdist_wheel - skip_existing: true - on: - tags: true - python: '3.6' \ No newline at end of file diff --git a/README.md b/README.md index 0fb729f..58ea781 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ SQLObject Adapter for PyCasbin ==== - -[![Build Status](https://www.travis-ci.org/pycasbin/sqlobject-adapter.svg?branch=master)](https://www.travis-ci.org/pycasbin/sqlobject-adapter) +[![GitHub Action](https://github.com/pycasbin/sqlobject-adapter/workflows/build/badge.svg?branch=master)](https://github.com/pycasbin/sqlobject-adapter/actions) [![Coverage Status](https://coveralls.io/repos/github/pycasbin/sqlobject-adapter/badge.svg)](https://coveralls.io/github/pycasbin/sqlobject-adapter) [![Version](https://img.shields.io/pypi/v/casbin_sqlobject_adapter.svg)](https://pypi.org/project/casbin_sqlobject_adapter/) [![PyPI - Wheel](https://img.shields.io/pypi/wheel/casbin_sqlobject_adapter.svg)](https://pypi.org/project/casbin_sqlobject_adapter/) diff --git a/package.json b/package.json new file mode 100644 index 0000000..d533f02 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "@semantic-release/changelog": "^6.0.3", + "@semantic-release/git": "^10.0.1", + "semantic-release": "^22.0.5", + "semantic-release-pypi": "^3.0.0" + } +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a5bee7e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,38 @@ +[project] +name = "casbin_sqlobject_adapter" +version = "0.1.1" +authors = [ + {name = "TechLee", email = "techlee@qq.com"}, +] +description = "SQLObject Adapter for PyCasbin" +keywords=["casbin", "SQLObject", "casbin-adapter", "rbac", "access control", "abac", "acl", "permission"] +readme = "README.md" +dynamic = ["dependencies"] +requires-python = ">=3.4" +license = {text = "Apache 2.0"} +classifiers = [ + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "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.12", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", +] + +[project.urls] +"Home-page" = "https://github.com/pycasbin/sqlobject-adapter" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +exclude = ["tests", "tests.*"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 5802eb9..0000000 --- a/setup.py +++ /dev/null @@ -1,32 +0,0 @@ -import setuptools - -desc_file = "README.md" - -with open(desc_file, "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="casbin_sqlobject_adapter", - version="0.1.1", - author="TechLee", - author_email="techlee@qq.com", - description="SQLObject Adapter for PyCasbin", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/pycasbin/sqlobject-adapter", - keywords=["casbin", "SQLObject", "casbin-adapter", "rbac", "access control", "abac", "acl", "permission"], - packages=setuptools.find_packages(), - install_requires=['casbin>=0.8.4', 'SQLObject>=3.8.0'], - python_requires=">=3.4", - license="Apache 2.0", - classifiers=[ - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - ], - data_files=[desc_file], -) \ No newline at end of file