diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml new file mode 100644 index 00000000..36326de8 --- /dev/null +++ b/.github/actions/install/action.yml @@ -0,0 +1,29 @@ +name: Install +description: Install dependencies + +inputs: + python-version: + description: Python version for installing dependencies + required: true + +runs: + using: composite + steps: + - name: Checkout the source code + uses: actions/checkout@v2 + + - name: Set the python version + uses: actions/setup-python@v3 + with: + python-version: ${{ inputs.python-version }} + + - name: Set up pip package caching + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: ${{ runner.os }}-pip- + + - name: Install dependencies + shell: bash + run: pip install -r requirements/ci.txt diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c9d69041..61251419 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: Publish on: push: - tags: + tags: - "*.*.*" jobs: @@ -13,17 +13,21 @@ jobs: - name: Checkout the source code uses: actions/checkout@v2 - - name: Set the python version - uses: actions/setup-python@v2 - # This is the version of python used to package the code. The unit - # tests will have run against python 3.6, 3.7 etc ensuring + # tests will have run against python 3.6, 3.7 etc ensuring # compatibility with those runtimes. # https://github.com/axnsan12/drf-yasg/pull/741#discussion_r713297594 + - name: Set the python version + uses: actions/setup-python@v3 + with: + python-version: 3.8 + + - name: Install dependencies + uses: ./.github/actions/install with: python-version: 3.8 - - name: Install pip dependencies + - name: Install builders for publishing run: pip install -r requirements/publish.txt - name: Build the distributions diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index d03495c0..9f456e82 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -11,23 +11,27 @@ jobs: python: [3.6, 3.7, 3.8, 3.9] steps: - - name: Set up pip package caching - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: ${{ runner.os }}-pip- - - name: Checkout the source code uses: actions/checkout@v2 - name: Set the python version - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python }} + + - name: Install dependencies + uses: ./.github/actions/install with: python-version: ${{ matrix.python }} - - name: Install pip dependencies - run: pip install -r requirements/ci.txt + - name: Run tests + env: + PYTHON_VERSION: ${{ matrix.python }} + run: tox -e $(tox -l | grep py${PYTHON_VERSION//.} | paste -sd "," -) - - name: Run unit tests - run: tox + - name: Check for incompatibilities with publishing to PyPi + if: ${{ matrix.python == 3.8 }} + run: | + pip install -r requirements/publish.txt + python setup.py sdist + twine check dist/* diff --git a/README.rst b/README.rst index 369d167c..acd4ff7f 100644 --- a/README.rst +++ b/README.rst @@ -360,26 +360,29 @@ provided out of the box - if you have ``djangorestframework-recursive`` installe :trim: drf-extra-fields -=============================== -Integration with `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. +================= + +Integration with `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. .. code:: python -class PDFBase64FileField(Base64FileField): - ALLOWED_TYPES = ['pdf'] - - class Meta: - swagger_schema_fields = { - 'type': 'string', - 'title': 'File Content', - 'description': 'Content of the file base64 encoded', - 'read_only': False # <-- FIX - } - - def get_file_extension(self, filename, decoded_file): - try: - PyPDF2.PdfFileReader(io.BytesIO(decoded_file)) - except PyPDF2.utils.PdfReadError as e: - logger.warning(e) - else: - return 'pdf' + class PDFBase64FileField(Base64FileField): + ALLOWED_TYPES = ['pdf'] + + class Meta: + swagger_schema_fields = { + 'type': 'string', + 'title': 'File Content', + 'description': 'Content of the file base64 encoded', + 'read_only': False # <-- FIX + } + + def get_file_extension(self, filename, decoded_file): + try: + PyPDF2.PdfFileReader(io.BytesIO(decoded_file)) + except PyPDF2.utils.PdfReadError as e: + logger.warning(e) + else: + return 'pdf' diff --git a/docs/changelog.rst b/docs/changelog.rst index 8ccb0cee..c301ea3b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,14 @@ Changelog ######### +********** +**1.21.2** +********** + +*Release date: Jul 17, 2022* + +**FIXED:** Fixed code block rst syntax in ``README.rst`` + ********** **1.21.1** ********** diff --git a/requirements/publish.txt b/requirements/publish.txt index 9f84aec3..ade35d85 100644 --- a/requirements/publish.txt +++ b/requirements/publish.txt @@ -1,2 +1,3 @@ setuptools-scm==7.0.5 +twine==4.0.1 wheel>=0.37.0