Skip to content

Commit 4b35f59

Browse files
committed
feat: init rabbitmq-watcher
1 parent 2549af2 commit 4b35f59

File tree

11 files changed

+520
-0
lines changed

11 files changed

+520
-0
lines changed

.github/semantic.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Always validate the PR title AND all the commits
2+
titleAndCommits: true

.github/workflows/build.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: build
2+
on:
3+
push:
4+
branches: [master]
5+
pull_request:
6+
branches: [master]
7+
8+
jobs:
9+
test:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
python-version: ['3.9', '3.10', '3.11']
15+
os: [ubuntu-latest]
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Set up Rabbitmq
27+
uses: nijel/rabbitmq-action@v1.0.0
28+
29+
- name: Install dependencies
30+
run: |
31+
pip install -r requirements.txt
32+
pip install coveralls
33+
34+
- name: Run tests
35+
run: coverage run -m unittest discover -s tests -t tests
36+
37+
- name: Upload coverage data to coveralls.io
38+
run: coveralls --service=github
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
COVERALLS_FLAG_NAME: ${{ matrix.os }} - ${{ matrix.python-version }}
42+
COVERALLS_PARALLEL: true
43+
44+
lint:
45+
name: Run Linters
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v2
50+
51+
- name: Super-Linter
52+
uses: github/super-linter@v4.2.2
53+
env:
54+
VALIDATE_PYTHON_BLACK: true
55+
DEFAULT_BRANCH: master
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
58+
coveralls:
59+
name: Indicate completion to coveralls.io
60+
needs: test
61+
runs-on: ubuntu-latest
62+
container: python:3-slim
63+
steps:
64+
- name: Finished
65+
run: |
66+
pip3 install --upgrade coveralls
67+
coveralls --finish
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
71+
release:
72+
name: Release
73+
runs-on: ubuntu-latest
74+
needs: [ test, coveralls ]
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v2
78+
with:
79+
fetch-depth: 0
80+
81+
- name: Setup Node.js
82+
uses: actions/setup-node@v2
83+
with:
84+
node-version: '18'
85+
86+
- name: Setup
87+
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
88+
89+
- name: Set up python
90+
uses: actions/setup-python@v2
91+
with:
92+
python-version: '3.10'
93+
94+
- name: Install setuptools
95+
run: python -m pip install --upgrade setuptools wheel twine
96+
97+
- name: Release
98+
env:
99+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
101+
run: npx semantic-release

.gitignore

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit tests / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# idea
81+
.idea
82+
83+
# IPython
84+
profile_default/
85+
ipython_config.py
86+
87+
# pyenv
88+
.python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
98+
__pypackages__/
99+
100+
# Celery stuff
101+
celerybeat-schedule
102+
celerybeat.pid
103+
104+
# SageMath parsed files
105+
*.sage.py
106+
107+
# Environments
108+
.env
109+
.venv
110+
env/
111+
venv/
112+
ENV/
113+
env.bak/
114+
venv.bak/
115+
116+
# Spyder project settings
117+
.spyderproject
118+
.spyproject
119+
120+
# Rope project settings
121+
.ropeproject
122+
123+
# mkdocs documentation
124+
/site
125+
126+
# mypy
127+
.mypy_cache/
128+
.dmypy.json
129+
dmypy.json
130+
131+
# Pyre type checker
132+
.pyre/

.releaserc.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"branches": "master",
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"semantic-release-pypi",
7+
"@semantic-release/github",
8+
[
9+
"@semantic-release/changelog",
10+
{
11+
"changelogFile": "CHANGELOG.md",
12+
"changelogTitle": "# Semantic Versioning Changelog"
13+
}
14+
],
15+
[
16+
"@semantic-release/git",
17+
{
18+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
19+
"assets": ["CHANGELOG.md", "setup.py", "setup.cfg"]
20+
}
21+
]
22+
]
23+
}

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# rabbitmq-watcher
2+
3+
[![tests](https://github.com/pycasbin/rabbitmq-watcher/actions/workflows/release.yml/badge.svg)](https://github.com/pycasbin/rabbitmq-watcher/actions/workflows/release.yml)
4+
[![Coverage Status](https://coveralls.io/repos/github/pycasbin/rabbitmq-watcher/badge.svg)](https://coveralls.io/github/pycasbin/rabbitmq-watcher)
5+
[![Version](https://img.shields.io/pypi/v/casbin-rabbitmq-watcher.svg)](https://pypi.org/project/casbin-rabbitmq-watcher/)
6+
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/casbin-rabbitmq-watcher.svg)](https://pypi.org/project/casbin-rabbitmq-watcher/)
7+
[![Download](https://img.shields.io/pypi/dm/casbin-rabbitmq-watcher.svg)](https://pypi.org/project/casbin-rabbitmq-watcher/)
8+
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/casbin/lobby)
9+
10+
Rabbitmq Watcher is the rabbitmq watcher for pycasbin. With this library, Casbin can synchronize the policy with the database in multiple enforcer instances.
11+
## Installation
12+
```bash
13+
pip install casbin-rabbitmq-watcher
14+
```
15+
16+
## Basic Usage Example
17+
18+
## Getting Help
19+
20+
- [Casbin](https://github.com/casbin/pycasbin)
21+
22+
## License
23+
24+
This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.

examples/rbac_model.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[request_definition]
2+
r = sub, obj, act
3+
4+
[policy_definition]
5+
p = sub, obj, act
6+
7+
[role_definition]
8+
g = _, _
9+
10+
[policy_effect]
11+
e = some(where (p.eft == allow))
12+
13+
[matchers]
14+
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

examples/rbac_policy.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
p, alice, data1, read
2+
p, bob, data2, write
3+
p, data2_admin, data2, read
4+
p, data2_admin, data2, write
5+
g, alice, data2_admin

rabbitmq_watcher/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)