From 0ec7f897d6ae75886d13ad78e6d66abe362b5624 Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Mon, 18 Jul 2022 13:35:46 +0100 Subject: [PATCH 1/8] Add prepublish twine check --- .github/actions/install/action.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/publish.yml | 16 ++++++++++------ .github/workflows/review.yml | 23 ++++++++++++----------- 3 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 .github/actions/install/action.yml diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml new file mode 100644 index 00000000..e7319cd9 --- /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..9c3df108 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -11,23 +11,24 @@ 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 pip dependencies - run: pip install -r requirements/ci.txt + - name: Install dependencies + uses: ./.github/actions/install + with: + python-version: ${{ matrix.python }} - - name: Run unit tests + - name: Run tests run: tox + + - name: Check for incompatibilities with publishing to PyPi + if: ${{ matrix.python }} == 3.8 + run: | + python setup.py sdist + twine check dist/* From deb39940cc63d4774a112a3614fd80bf06c56010 Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Mon, 18 Jul 2022 13:57:51 +0100 Subject: [PATCH 2/8] Fix action version syntax --- .github/actions/install/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml index e7319cd9..36326de8 100644 --- a/.github/actions/install/action.yml +++ b/.github/actions/install/action.yml @@ -15,7 +15,7 @@ runs: - name: Set the python version uses: actions/setup-python@v3 with: - python-version: ${{ inputs.python-version }}. + python-version: ${{ inputs.python-version }} - name: Set up pip package caching uses: actions/cache@v2 From 8b76535e6279c7e404f665e0b06406eabdab9cd7 Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Mon, 18 Jul 2022 14:12:45 +0100 Subject: [PATCH 3/8] Fix indentation in README.rst code blocks --- .github/workflows/review.yml | 1 + README.rst | 43 +++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index 9c3df108..5c71cefe 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -30,5 +30,6 @@ jobs: - 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' From 3972472e9540261dda1e98bf445b8027b0639a3f Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Mon, 18 Jul 2022 14:22:55 +0100 Subject: [PATCH 4/8] Add twine to publish dependencies --- requirements/publish.txt | 1 + 1 file changed, 1 insertion(+) 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 From fe53426497e341fefa3bd028501abbd489b6d63f Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Mon, 18 Jul 2022 14:57:12 +0100 Subject: [PATCH 5/8] Specify toxenv explicitly --- .github/workflows/review.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index 5c71cefe..98eb5207 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -25,11 +25,13 @@ jobs: python-version: ${{ matrix.python }} - name: Run tests - run: tox + env: + TOXENV: ${{ matrix.python }} + run: tox -e py${TOXENV//.} - name: Check for incompatibilities with publishing to PyPi - if: ${{ matrix.python }} == 3.8 + if: ${{ matrix.python == 3.8 }} run: | - pip install -r requirements/publish.txt - python setup.py sdist - twine check dist/* + pip install -r requirements/publish.txt + python setup.py sdist + twine check dist/* From 822f66d70cb65cfa6cb37e14ff37aa543fbcff16 Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Mon, 18 Jul 2022 15:10:38 +0100 Subject: [PATCH 6/8] Specify all tox targets --- .github/workflows/review.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index 98eb5207..b0220e72 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -26,8 +26,8 @@ jobs: - name: Run tests env: - TOXENV: ${{ matrix.python }} - run: tox -e py${TOXENV//.} + PYTHON_VERSION: ${{ matrix.python }} + run: tox -e $(tox -l | grep ${PYTHON_VERSION//.} | paste -sd "," -) - name: Check for incompatibilities with publishing to PyPi if: ${{ matrix.python == 3.8 }} From d7314b622ec57268ff442c19fe345a352c2d8386 Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Mon, 18 Jul 2022 15:33:27 +0100 Subject: [PATCH 7/8] Add py prefix to toxenvs --- .github/workflows/review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index b0220e72..9f456e82 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -27,7 +27,7 @@ jobs: - name: Run tests env: PYTHON_VERSION: ${{ matrix.python }} - run: tox -e $(tox -l | grep ${PYTHON_VERSION//.} | paste -sd "," -) + run: tox -e $(tox -l | grep py${PYTHON_VERSION//.} | paste -sd "," -) - name: Check for incompatibilities with publishing to PyPi if: ${{ matrix.python == 3.8 }} From a000102d82569868b1f0cfff7d39981a6daeaf37 Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Mon, 18 Jul 2022 15:37:30 +0100 Subject: [PATCH 8/8] Update changelog --- docs/changelog.rst | 8 ++++++++ 1 file changed, 8 insertions(+) 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** **********