Skip to content

Commit f4bf7ba

Browse files
Merge pull request #797 from axnsan12/prepublish
Add prepublish compatibility checks, a composite installation action and explicitly set tox targets
2 parents 124f2cd + a000102 commit f4bf7ba

File tree

6 files changed

+87
-38
lines changed

6 files changed

+87
-38
lines changed

.github/actions/install/action.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Install
2+
description: Install dependencies
3+
4+
inputs:
5+
python-version:
6+
description: Python version for installing dependencies
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Checkout the source code
13+
uses: actions/checkout@v2
14+
15+
- name: Set the python version
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: ${{ inputs.python-version }}
19+
20+
- name: Set up pip package caching
21+
uses: actions/cache@v2
22+
with:
23+
path: ~/.cache/pip
24+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
25+
restore-keys: ${{ runner.os }}-pip-
26+
27+
- name: Install dependencies
28+
shell: bash
29+
run: pip install -r requirements/ci.txt

.github/workflows/publish.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish
22

33
on:
44
push:
5-
tags:
5+
tags:
66
- "*.*.*"
77

88
jobs:
@@ -13,17 +13,21 @@ jobs:
1313
- name: Checkout the source code
1414
uses: actions/checkout@v2
1515

16-
- name: Set the python version
17-
uses: actions/setup-python@v2
18-
1916
# This is the version of python used to package the code. The unit
20-
# tests will have run against python 3.6, 3.7 etc ensuring
17+
# tests will have run against python 3.6, 3.7 etc ensuring
2118
# compatibility with those runtimes.
2219
# https://github.com/axnsan12/drf-yasg/pull/741#discussion_r713297594
20+
- name: Set the python version
21+
uses: actions/setup-python@v3
22+
with:
23+
python-version: 3.8
24+
25+
- name: Install dependencies
26+
uses: ./.github/actions/install
2327
with:
2428
python-version: 3.8
2529

26-
- name: Install pip dependencies
30+
- name: Install builders for publishing
2731
run: pip install -r requirements/publish.txt
2832

2933
- name: Build the distributions

.github/workflows/review.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,27 @@ jobs:
1111
python: [3.6, 3.7, 3.8, 3.9]
1212

1313
steps:
14-
- name: Set up pip package caching
15-
uses: actions/cache@v2
16-
with:
17-
path: ~/.cache/pip
18-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
19-
restore-keys: ${{ runner.os }}-pip-
20-
2114
- name: Checkout the source code
2215
uses: actions/checkout@v2
2316

2417
- name: Set the python version
25-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: ${{ matrix.python }}
21+
22+
- name: Install dependencies
23+
uses: ./.github/actions/install
2624
with:
2725
python-version: ${{ matrix.python }}
2826

29-
- name: Install pip dependencies
30-
run: pip install -r requirements/ci.txt
27+
- name: Run tests
28+
env:
29+
PYTHON_VERSION: ${{ matrix.python }}
30+
run: tox -e $(tox -l | grep py${PYTHON_VERSION//.} | paste -sd "," -)
3131

32-
- name: Run unit tests
33-
run: tox
32+
- name: Check for incompatibilities with publishing to PyPi
33+
if: ${{ matrix.python == 3.8 }}
34+
run: |
35+
pip install -r requirements/publish.txt
36+
python setup.py sdist
37+
twine check dist/*

README.rst

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -360,26 +360,29 @@ provided out of the box - if you have ``djangorestframework-recursive`` installe
360360
:trim:
361361

362362
drf-extra-fields
363-
===============================
364-
Integration with `drf-extra-fields <https://github.com/Hipo/drf-extra-fields>`_ has a problem with Base64 fields. The drf-yasg will generate Base64 file or image fields as Readonly and not required. Here is a workaround code for display the Base64 fields correctly.
363+
=================
364+
365+
Integration with `drf-extra-fields <https://github.com/Hipo/drf-extra-fields>`_ has a problem with Base64 fields.
366+
The drf-yasg will generate Base64 file or image fields as Readonly and not required. Here is a workaround code
367+
for display the Base64 fields correctly.
365368

366369
.. code:: python
367370
368-
class PDFBase64FileField(Base64FileField):
369-
ALLOWED_TYPES = ['pdf']
370-
371-
class Meta:
372-
swagger_schema_fields = {
373-
'type': 'string',
374-
'title': 'File Content',
375-
'description': 'Content of the file base64 encoded',
376-
'read_only': False # <-- FIX
377-
}
378-
379-
def get_file_extension(self, filename, decoded_file):
380-
try:
381-
PyPDF2.PdfFileReader(io.BytesIO(decoded_file))
382-
except PyPDF2.utils.PdfReadError as e:
383-
logger.warning(e)
384-
else:
385-
return 'pdf'
371+
class PDFBase64FileField(Base64FileField):
372+
ALLOWED_TYPES = ['pdf']
373+
374+
class Meta:
375+
swagger_schema_fields = {
376+
'type': 'string',
377+
'title': 'File Content',
378+
'description': 'Content of the file base64 encoded',
379+
'read_only': False # <-- FIX
380+
}
381+
382+
def get_file_extension(self, filename, decoded_file):
383+
try:
384+
PyPDF2.PdfFileReader(io.BytesIO(decoded_file))
385+
except PyPDF2.utils.PdfReadError as e:
386+
logger.warning(e)
387+
else:
388+
return 'pdf'

docs/changelog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
Changelog
33
#########
44

5+
**********
6+
**1.21.2**
7+
**********
8+
9+
*Release date: Jul 17, 2022*
10+
11+
**FIXED:** Fixed code block rst syntax in ``README.rst``
12+
513
**********
614
**1.21.1**
715
**********

requirements/publish.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
setuptools-scm==7.0.5
2+
twine==4.0.1
23
wheel>=0.37.0

0 commit comments

Comments
 (0)