Skip to content

Commit a56e58c

Browse files
committed
updated docs and CI
1 parent 2b6b891 commit a56e58c

File tree

13 files changed

+346
-122
lines changed

13 files changed

+346
-122
lines changed

.github/file-filters.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This is used by the action https://github.com/dorny/paths-filter
2+
dependencies: &dependencies
3+
- 'pyproject.toml'
4+
5+
python: &python
6+
- added|modified: 'src/**'
7+
- added|modified: 'tests/**'
8+
- 'manage.py'
9+
10+
changelog:
11+
- added|modified: 'changes/**'
12+
- 'CHANGELOG.md'
13+
14+
mypy:
15+
- *python
16+
- 'mypy.ini'
17+
18+
run_tests:
19+
- *python
20+
- *dependencies
21+
- 'pytest.ini'
22+
- '.github/workflows/test.yml'
23+
- '.github/file-filters.yml'
24+
25+
lint:
26+
- *python
27+
- '.flake8'
28+
- 'pyproject.toml'
29+
- '.github/file-filters.yml'
30+
- '.github/workflows/lint.yml'

.github/workflows/lint.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- '**' # matches every branch
7+
8+
concurrency:
9+
group: "${{ github.workflow }}-${{ github.ref }}-lint"
10+
cancel-in-progress: true
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
permissions:
17+
id-token: write
18+
attestations: write
19+
20+
21+
jobs:
22+
changes:
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 1
25+
defaults:
26+
run:
27+
shell: bash
28+
outputs:
29+
lint: ${{steps.changes.outputs.lint }}
30+
steps:
31+
- name: Checkout code
32+
uses: actions/[email protected]
33+
- id: changes
34+
name: Check for file changes
35+
uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0
36+
with:
37+
base: ${{ github.ref }}
38+
token: ${{ github.token }}
39+
filters: .github/file-filters.yml
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
defaults:
44+
run:
45+
shell: bash
46+
needs: [ changes ]
47+
if: needs.changes.outputs.lint
48+
steps:
49+
- name: Checkout code
50+
uses: actions/[email protected]
51+
52+
- name: Set up Python
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: 3.12
56+
architecture: 'x64'
57+
- uses: yezz123/setup-uv@v4
58+
- name: lint
59+
if: needs.changes.outputs.lint
60+
run: |
61+
uv run isort src/ --check-only
62+
uv run flake8 src/

.github/workflows/test.yml

Lines changed: 108 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,113 @@
11
name: Test
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
- develop
8-
pull_request:
4+
push:
5+
branches:
6+
- '**' # matches every branch
7+
8+
concurrency:
9+
group: "${{ github.workflow }}-${{ github.ref }}-test"
10+
cancel-in-progress: true
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
permissions:
17+
id-token: write
18+
attestations: write
19+
920

1021
jobs:
11-
lint:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- uses: actions/checkout@v2
15-
- uses: actions/setup-python@v2
16-
17-
- name: Install dependencies
18-
run: |
19-
python -m pip install --upgrade pip flake8 isort
20-
- name: Lint with flake8
21-
run: |
22-
flake8 src
23-
isort -c src
24-
25-
test:
26-
# if: ${{github.event}} && ${{ !contains(github.event.head_commit.message, 'ci skip') }}
27-
runs-on: ubuntu-latest
28-
strategy:
29-
fail-fast: false
30-
matrix:
31-
python-version: [ "3.11", "3.12"]
32-
django-version: [ "4.2", "5.1"]
33-
env:
34-
PY_VER: ${{ matrix.python-version}}
35-
DJ_VER: ${{ matrix.django-version}}
36-
37-
steps:
38-
- uses: actions/checkout@v2
39-
40-
- name: Set up Python ${{ matrix.python-version }}
41-
uses: actions/setup-python@v2
42-
with:
43-
python-version: ${{ matrix.python-version }}
44-
45-
- name: Install dependencies
46-
run: python -m pip install tox
47-
48-
- name: Test with Tox
49-
run: tox -e d${DJ_VER//.}-py${PY_VER//.} -- --create-db --cov-report=xml --cov-report=term --junitxml=pytest.xml
50-
51-
- uses: codecov/codecov-action@v1
52-
with:
53-
# files: ./coverage1.xml,./coverage2.xml # optional
54-
# flags: unittests # optional
55-
# name: codecov-umbrella # optional
56-
# fail_ci_if_error: true # optional (default = false)
57-
verbose: true # optional (default = false)
22+
changes:
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 1
25+
defaults:
26+
run:
27+
shell: bash
28+
outputs:
29+
run_tests: ${{steps.changes.outputs.run_tests }}
30+
lint: ${{steps.changes.outputs.lint }}
31+
steps:
32+
- name: Checkout code
33+
uses: actions/[email protected]
34+
- id: changes
35+
name: Check for file changes
36+
uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0
37+
with:
38+
base: ${{ github.ref }}
39+
token: ${{ github.token }}
40+
filters: .github/file-filters.yml
41+
42+
ci:
43+
runs-on: ubuntu-latest
44+
name: Test py${{ matrix.python-version }}/dj${{matrix.django-version}}
45+
defaults:
46+
run:
47+
shell: bash
48+
strategy:
49+
max-parallel: 1
50+
matrix:
51+
python-version: [ "3.11", "3.12" ]
52+
django-version: [ "4.2", "5.1" ]
53+
fail-fast: true
54+
needs: [ changes ]
55+
# if: needs.changes.outputs.run_tests || needs.changes.outputs.lint
56+
steps:
57+
- name: Checkout code
58+
uses: actions/[email protected]
59+
- name: Set up Python ${{ matrix.python-version }}
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version: ${{ matrix.python-version }}
63+
architecture: 'x64'
64+
- name: Restore cached venv
65+
id: cache-venv-restore
66+
uses: actions/cache/restore@v4
67+
with:
68+
path: |
69+
.cache-uv/
70+
.venv/
71+
key: ${{ matrix.python-version }}-${{matrix.django-version}}-${{ hashFiles('pyproject.toml') }}-venv
72+
73+
- uses: yezz123/setup-uv@v4
74+
with:
75+
python: ${{ matrix.python-version }}
76+
77+
- name: Test
78+
# if: needs.changes.outputs.run_tests
79+
run: |
80+
uv add "django==${{ matrix.django-version }}.*"
81+
uv run --cache-dir .cache-uv/ \
82+
python -m pytest tests/ \
83+
--junit-xml junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml \
84+
--cov --cov-report xml
85+
- name: Cache venv
86+
if: steps.cache-venv-restore.outputs.cache-hit != 'true'
87+
id: cache-venv-save
88+
uses: actions/cache/save@v4
89+
with:
90+
path: |
91+
.cache-uv/
92+
.venv/
93+
key: ${{ matrix.python-version }}-${{matrix.django-version}}-${{ hashFiles('pyproject.toml') }}-venv
94+
95+
- name: Upload pytest test results
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: pytest-results-${{ matrix.python-version }}-${{matrix.django-version}}
99+
path: junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml
100+
if: ${{ always() }}
101+
102+
- name: Upload coverage to Codecov
103+
uses: codecov/codecov-action@v4
104+
if: matrix.python-version == 3.12
105+
continue-on-error: true
106+
with:
107+
env_vars: OS,PYTHON
108+
fail_ci_if_error: true
109+
flags: unittests
110+
files: ./coverage.xml
111+
verbose: false
112+
token: ${{ secrets.CODECOV_TOKEN }}
113+
name: codecov-${{env.GITHUB_REF_NAME}}

README.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,14 @@ provides decorators to easily add custom buttons to Django Admin pages and/or ad
1515
It allows easy creation of wizards, actions and/or links to external resources
1616
as well as api only views.
1717

18-
Three decorators are available:
18+
Four decorators are available:
1919

2020
- ``button()`` to mark a method as extra view and show related button
2121
- ``link()`` This is used for "external" link, where you don't need to invoke local views.
2222
- ``view()`` View only decorator, this adds a new url but do not render any button.
2323
- ``choice()`` Menu like button, can be used to group multiple @views().
2424

2525

26-
Install
27-
-------
28-
29-
pip install django-admin-extra-buttons
30-
31-
32-
After installation add it to ``INSTALLED_APPS``
33-
34-
INSTALLED_APPS = (
35-
...
36-
'admin_extra_buttons',
37-
)
38-
3926
How to use it
4027
-------------
4128

docs/contributing.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contributing
2+
3+
4+
Install [uv](https://docs.astral.sh/uv/)
5+
6+
7+
git clone ..
8+
uv venv .venv --python 3.12
9+
source .venv/bin/activate
10+
uv sync --extra docs
11+
pre-commit install
12+
13+
14+
15+
## Run tests
16+
pytests tests
17+
18+
19+
## Run demo app
20+
21+
tests/demoapp/manage.py migrate
22+
23+
tests/demoapp/manage.py runserver
24+
25+
!!! note
26+
27+
You can login in the demo application as superuser using any username/password

docs/install.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Install
2+
3+
4+
pip install django-admin-extra-buttons
5+
6+
7+
After installation add it to ``INSTALLED_APPS``
8+
9+
INSTALLED_APPS = (
10+
...
11+
'admin_extra_buttons',
12+
)

docs/requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)