Skip to content

Commit

Permalink
ci: fix CI regression issues
Browse files Browse the repository at this point in the history
- Update GHA on: to reflect updated default branch name
- Add python 3.11 to test matrix
- Use a container image for python 2.7 tests
- Update a no-longer-valid assertion about GIF attributes
- Provisional python 3.12 support
- update tox config for compatibility with v4
  • Loading branch information
fdintino committed Oct 26, 2023
1 parent 408cf84 commit 52da121
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/test.yml
Expand Up @@ -2,15 +2,15 @@ name: Test

on:
push:
branches: [master]
branches: [main]
pull_request:

jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-bin: ["python3"]
thumbor-version: ["7"]
include:
Expand All @@ -26,6 +26,8 @@ jobs:
python-version-desc: " (python 3.9)"
- python-version: "3.10"
python-version-desc: " (python 3.10)"
- python-version: "3.11"
python-version-desc: " (python 3.11)"

runs-on: ubuntu-latest
name: Thumbor ${{ matrix.thumbor-version }}${{ matrix.python-version-desc }}
Expand All @@ -34,14 +36,24 @@ jobs:
FFMPEG_BUILD_VER: 20210119-553eb07737
GIFSICLE_VER: 1.92

container:
image: ${{ matrix.python-version == '2.7' && 'python:2.7-buster' || null }}

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
if: matrix.python-version != '2.7'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install python 2.7 container- specific dependencies
if: matrix.python-version == '2.7'
run: |
apt-get update
apt-get install -y sudo
- name: Install ffmpeg
run: |
curl -sLo - \
Expand Down Expand Up @@ -82,11 +94,12 @@ jobs:
run: tox -e coverage-report

- name: Upload coverage
run: tox -e codecov
env:
CODECOV_NAME: ${{ github.workflow }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
name: ${{ github.workflow }}
token: ${{ secrets.CODECOV_TOKEN }}

report:
if: always()
needs: build
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
3 changes: 2 additions & 1 deletion setup.py
@@ -1,3 +1,4 @@
import sys
from setuptools import setup, find_packages
from os import path

Expand Down Expand Up @@ -47,5 +48,5 @@ def get_version():
],
packages=find_packages('src'),
package_dir={'': 'src'},
install_requires=['thumbor'],
install_requires=['thumbor<7' if sys.version_info[0] == '2' else 'thumbor'],
zip_safe=False)
5 changes: 1 addition & 4 deletions tests/engines/test_ffmpeg_transcode.py
Expand Up @@ -203,12 +203,9 @@ def test_alpha_transcode_to_gif(http_client, base_url, src_ext):
assert response.headers.get('content-type') == 'image/gif'

im = Image.open(BytesIO(response.body))

assert im.mode == 'P'
assert im.info['transparency'] == im.info['background']

assert has_transparency(im)

assert im.convert("RGBA").getchannel("A").getpixel((50, 50)) == 0
assert im.format == 'GIF'
assert im.is_animated is True
assert im.size == (200, 200)
16 changes: 11 additions & 5 deletions tox.ini
@@ -1,18 +1,22 @@
[tox]
envlist = py27,py37,py38,py39,py310
envlist = py27,py37,py38,py39,py310,py311
skipsdist=True

[gh-actions]
problem_matcher = False
python =
2.7: py27
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[testenv]
commands =
pytest --junitxml={toxinidir}/reports/test-{envname}.xml {posargs:--cov-report=xml}
{envpython} -m pip install -e . -v
pytest --junitxml={toxinidir}/reports/test-{envname}.xml {posargs:--cov-report term}
{envpython} -c "import os; os.path.exists('{toxworkdir}/coverage') or os.makedirs('{toxworkdir}/coverage')"
usedevelop = True
setenv =
COVERAGE_FILE={toxworkdir}/coverage/.coverage.{envname}
Expand All @@ -25,12 +29,14 @@ deps =
pytest-mock
pytest-tornado
pytest-cov
py27: thumbor<7
!py27: thumbor >= 7.0.0
!py27: git+https://github.com/fdintino/aws.git@9caa87ea2bdb88ec25d98cdae676c2e5b4be6b23#egg=tc_aws
py27: tc_aws
py27: tc_aws<7
boto
mirakuru
py27: moto[server] <= 2.1.0
py27: flask-cors<4
!py27: moto[server]
!py27: boto3==1.21.21
!py27: botocore==1.24.21
Expand All @@ -43,7 +49,7 @@ changedir = {toxworkdir}/coverage
commands =
coverage combine
coverage report
coverage xml
coverage xml -o {toxinidir}/coverage.xml

[testenv:codecov]
skip_install = true
Expand All @@ -52,4 +58,4 @@ depends = coverage-report
passenv = CODECOV_TOKEN
changedir = {toxinidir}
commands =
codecov --file {toxworkdir}/coverage/coverage.xml {posargs}
codecov --file {toxinidir}/coverage/coverage.xml {posargs}

0 comments on commit 52da121

Please sign in to comment.