Skip to content

Commit

Permalink
fix: migrate from travis-ci to Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekotoxin committed Jul 30, 2022
1 parent e53d75b commit 1799eab
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
include = casbin_adapter/*
omit = *migrations*, *tests*
2 changes: 2 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Always validate the PR title AND all the commits
titleAndCommits: true
104 changes: 104 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: build
on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
os: [ubuntu-18.04, macOS-latest, windows-latest]

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: Install dependencies
run: |
pip install -r requirements_dev.txt
pip install coveralls
pip install pytest
- name: Run tests
run: coverage run -m django test --settings=tests.settings

- name: Upload coverage data to coveralls.io
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.os }} - ${{ matrix.python-version }}
COVERALLS_PARALLEL: true

lint:
name: Run Linters
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Super-Linter
uses: github/[email protected]
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_PYTHON_BLACK: true
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: /
PYTHON_BLACK_CONFIG_FILE: pyproject.toml

coveralls:
name: Indicate completion to coveralls.io
needs: test
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install --upgrade coveralls
coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
runs-on: ubuntu-latest
needs: [ test, coveralls ]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'

- 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.8

- 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
23 changes: 23 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -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", "setup.py", "setup.cfg"]
}
]
]
}
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.black]
line-length = 120
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
casbin
django
casbin==1.16.10
Django

3 changes: 3 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r requirements.txt
setuptools==60.2.0
simpleeval==0.9.12
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
version = 1.0.0
9 changes: 3 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

setuptools.setup(
name="casbin-django-orm-adapter",
version="0.0.1",
author="Yang Luo",
author_email="[email protected]",
description="Django's ORM adapter for PyCasbin",
Expand All @@ -17,15 +16,13 @@
keywords=["casbin", "adapter", "storage-driver", "django", "orm", "django-orm", "access-control", "authorization"],
packages=setuptools.find_packages(exclude=("tests",)),
install_requires=["casbin", "django"],
python_requires=">=3.3",
python_requires=">=3.7",
license="Apache 2.0",
classifiers=[
"Programming Language :: Python :: 3.3",
"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",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
Expand Down
4 changes: 2 additions & 2 deletions tests/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_enforcer():
CasbinRule(ptype='g', v0='alice', v1='data2_admin'),
])

return casbin.Enforcer(get_fixture('rbac_model.conf'), adapter, True)
return casbin.Enforcer(get_fixture('rbac_model.conf'), adapter)


class TestConfig(TestCase):
Expand All @@ -37,7 +37,7 @@ def test_enforcer_basic(self):

def test_add_policy(self):
adapter = Adapter()
e = casbin.Enforcer(get_fixture('rbac_model.conf'), adapter, True)
e = casbin.Enforcer(get_fixture('rbac_model.conf'), adapter)

try:
self.assertFalse(e.enforce('alice', 'data1', 'read'))
Expand Down

0 comments on commit 1799eab

Please sign in to comment.