Skip to content

Commit

Permalink
Big update
Browse files Browse the repository at this point in the history
  • Loading branch information
vint21h committed Feb 19, 2022
1 parent e6f714c commit c108a94
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 168 deletions.
116 changes: 6 additions & 110 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,122 +13,18 @@ on:
branches:
- "*"
workflow_dispatch:
workflow_call:
env:
NAME: "mcadmin"
DEFAULT_PYTHON_VERSION: "3.10"
jobs:
check-requirements:
uses: "./.github/workflows/check-requirements.yml"
check:
name: "${{ matrix.toxenv }}"
runs-on: "ubuntu-latest"
strategy:
matrix:
toxenv: ["check", "check-build"]
steps:
- name: "Git clone"
id: "git-clone"
uses: "actions/checkout@v2"
- name: "Set up Python ${{ env.DEFAULT_PYTHON_VERSION }}"
id: "set-up-python"
uses: "actions/setup-python@v2"
with:
python-version: "${{ env.DEFAULT_PYTHON_VERSION }}"
- name: "Pip cache"
id: "pip-cache"
uses: "actions/cache@v2"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ matrix.toxenv }}-${{ hashFiles('setup.cfg') }}"
restore-keys: |
"${{ runner.os }}-pip-${{ matrix.toxenv }}-"
"${{ runner.os }}-pip-"
- name: "Pre-commit cache"
id: "pre-commit-cache"
uses: "actions/cache@v2"
with:
path: "~/.cache/pre-commit"
key: "${{ runner.os }}-pre-commit-${{ matrix.toxenv }}-${{ hashFiles('.pre-commit-config.yaml') }}"
restore-keys: |
"${{ runner.os }}-pre-commit-${{ matrix.toxenv }}-"
"${{ runner.os }}-pre-commit-"
- name: "Install requirements"
id: "install-requirements"
run: "make install"
- name: "Run ${{ matrix.toxenv }}"
id: "run"
run: "tox -e ${{ matrix.toxenv }}"
uses: "./.github/workflows/check.yml"
test:
name: "${{ matrix.python-version }}"
runs-on: "ubuntu-latest"
if: success()
uses: "./.github/workflows/test.yml"
needs: ["check"]
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
steps:
- name: "Git clone"
id: "git-clone"
uses: "actions/checkout@v2"
- name: "Set up Python ${{ matrix.python-version }}"
id: "set-up-python"
uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "Pip cache"
id: "pip-cache"
uses: "actions/cache@v2"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}"
restore-keys: |
"${{ runner.os }}-pip-${{ matrix.python-version }}-"
"${{ runner.os }}-pip-"
- name: "Temporarily save coverage statistics"
id: "temporarily-save-coverage-statistics"
uses: "actions/cache@v2"
with:
path: ".coverage"
key: ".coverage-${{ github.run_id }}-${{ github.run_number }}"
- name: "Install requirements"
id: "install-requirements"
run: "make install"
- name: "Run tests"
id: "run-tests"
env:
PLATFORM: "${{ matrix.platform }}"
run: "make tox"
coveralls:
name: "coveralls"
runs-on: "ubuntu-latest"
if: success()
uses: "./.github/workflows/coveralls.yml"
needs: ["test", "check"]
steps:
- name: "Git clone"
id: "git-clone"
uses: "actions/checkout@v2"
- name: "Set up Python ${{ env.DEFAULT_PYTHON_VERSION }}"
id: "set-up-python"
uses: "actions/setup-python@v2"
with:
python-version: "${{ env.DEFAULT_PYTHON_VERSION }}"
- name: "Pip cache"
id: "pip-cache"
uses: "actions/cache@v2"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}"
restore-keys: |
"${{ runner.os }}-pip-"
- name: "Temporarily save coverage statistics"
id: "temporarily-save-coverage-statistics"
uses: "actions/cache@v2"
with:
path: ".coverage"
key: ".coverage-${{ github.run_id }}-${{ github.run_number }}"
- name: "Install requirements"
id: "install-requirements"
run: "make install"
- name: "Upload coverage report to Coveralls"
id: "upload-coverage-report-to-coveralls"
env:
COVERALLS_REPO_TOKEN: "${{ secrets.COVERALLS_REPO_TOKEN }}"
run: "make coveralls"
11 changes: 1 addition & 10 deletions .github/workflows/check-requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@

name: "check-requirements"
on:
push:
branches:
- "*"
tags:
- "*"
pull_request:
branches:
- "*"
schedule:
- cron: "0 3 * * *"
workflow_dispatch:
workflow_call:
env:
DEFAULT_PYTHON_VERSION: "3.10"
jobs:
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# django-mcadmin
# .github/workflows/check.yml


name: "check"
on:
workflow_dispatch:
workflow_call:
env:
NAME: "mcadmin"
DEFAULT_PYTHON_VERSION: "3.10"
jobs:
check:
name: "${{ matrix.toxenv }}"
runs-on: "ubuntu-latest"
strategy:
matrix:
toxenv: ["check", "check-build"]
steps:
- name: "Git clone"
id: "git-clone"
uses: "actions/checkout@v2"
- name: "Set up Python ${{ env.DEFAULT_PYTHON_VERSION }}"
id: "set-up-python"
uses: "actions/setup-python@v2"
with:
python-version: "${{ env.DEFAULT_PYTHON_VERSION }}"
- name: "Pip cache"
id: "pip-cache"
uses: "actions/cache@v2"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ matrix.toxenv }}-${{ hashFiles('setup.cfg') }}"
restore-keys: |
"${{ runner.os }}-pip-${{ matrix.toxenv }}-"
"${{ runner.os }}-pip-"
- name: "Pre-commit cache"
id: "pre-commit-cache"
uses: "actions/cache@v2"
with:
path: "~/.cache/pre-commit"
key: "${{ runner.os }}-pre-commit-${{ matrix.toxenv }}-${{ hashFiles('.pre-commit-config.yaml') }}"
restore-keys: |
"${{ runner.os }}-pre-commit-${{ matrix.toxenv }}-"
"${{ runner.os }}-pre-commit-"
- name: "Install requirements"
id: "install-requirements"
run: "make install"
- name: "Run ${{ matrix.toxenv }}"
id: "run"
run: "tox -e ${{ matrix.toxenv }}"
46 changes: 46 additions & 0 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# django-mcadmin
# .github/workflows/coveralls.yml


name: "coveralls"
on:
workflow_dispatch:
workflow_call:
env:
NAME: "mcadmin"
DEFAULT_PYTHON_VERSION: "3.10"
jobs:
coveralls:
name: "coveralls"
runs-on: "ubuntu-latest"
steps:
- name: "Git clone"
id: "git-clone"
uses: "actions/checkout@v2"
- name: "Set up Python ${{ env.DEFAULT_PYTHON_VERSION }}"
id: "set-up-python"
uses: "actions/setup-python@v2"
with:
python-version: "${{ env.DEFAULT_PYTHON_VERSION }}"
- name: "Pip cache"
id: "pip-cache"
uses: "actions/cache@v2"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}"
restore-keys: |
"${{ runner.os }}-pip-"
- name: "Temporarily save coverage statistics"
id: "temporarily-save-coverage-statistics"
uses: "actions/cache@v2"
with:
path: ".coverage"
key: ".coverage-${{ github.run_id }}-${{ github.run_number }}"
- name: "Install requirements"
id: "install-requirements"
run: "make install"
- name: "Upload coverage report to Coveralls"
id: "upload-coverage-report-to-coveralls"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: "coveralls --service=github"
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# django-mcadmin
# .github/workflows/test.yml


name: "test"
on:
workflow_dispatch:
workflow_call:
env:
NAME: "mcadmin"
jobs:
test:
name: "${{ matrix.python-version }}"
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- name: "Git clone"
id: "git-clone"
uses: "actions/checkout@v2"
- name: "Set up Python ${{ matrix.python-version }}"
id: "set-up-python"
uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "Pip cache"
id: "pip-cache"
uses: "actions/cache@v2"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}"
restore-keys: |
"${{ runner.os }}-pip-${{ matrix.python-version }}-"
"${{ runner.os }}-pip-"
- name: "Temporarily save coverage statistics"
id: "temporarily-save-coverage-statistics"
uses: "actions/cache@v2"
with:
path: ".coverage"
key: ".coverage-${{ github.run_id }}-${{ github.run_number }}"
- name: "Install requirements"
id: "install-requirements"
run: "make install"
- name: "Run tests"
id: "run-tests"
env:
PLATFORM: "${{ matrix.platform }}"
run: "make tox"
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ repos:
files: '\.env*'
exclude: ".envrc"
- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v4.0.1"
rev: "v4.1.0"
hooks:
- id: "check-added-large-files"
- id: "check-ast"
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10.0
3.10.2
2 changes: 1 addition & 1 deletion mcadmin/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DjangoDjversionAppConf(AppConf):
)
UPLOADS_PATH: str = getattr(settings, "MCADMIN_UPLOADS_PATH", settings.MEDIA_ROOT)
MODULE_NAME: str = getattr(settings, "MCADMIN_MODULE_NAME", "mcommands")
USE_PERMISSIONS: str = getattr(settings, "MCADMIN_USE_PERMISSIONS", False)
USE_PERMISSIONS: bool = getattr(settings, "MCADMIN_USE_PERMISSIONS", False)

class Meta:
"""Config settings."""
Expand Down
4 changes: 2 additions & 2 deletions mcadmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ def filter_by_permissions( # noqa: CFQ004,CCR001
Dict[str, Union[ManagementCommandAdmin, None]],
] = {}
groups_permissions = (
request.user.commands_groups_permissions.all() # type: ignore
request.user.commands_groups_permissions.all()
.values_list("group", flat=True)
.distinct()
)
commands_permissions = (
request.user.commands_permissions.all() # type: ignore
request.user.commands_permissions.all()
.values_list("command__command", flat=True)
.distinct()
)
Expand Down

0 comments on commit c108a94

Please sign in to comment.