Skip to content

Video editing with Python

Add Linux test to GitHub actions (#1287)

Tom Burrowsb1f62d2eee2c
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index bf126a35..00000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-name: Code Format Check
-
-on: [pull_request]
-
-jobs:
- lint:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v2
- - name: Black Code Formatter
- uses: lgeiger/[email protected]
- with:
- args: "--check --diff --target-version py36 $GITHUB_WORKSPACE"
diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.yml
new file mode 100644
index 00000000..a785b014
--- /dev/null
+++ b/.github/workflows/format_check.yml
@@ -0,0 +1,45 @@
+name: Code Format Check
+
+on: [push, pull_request]
+
+
+jobs:
+ black:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Black
+ uses: lgeiger/[email protected]
+ with:
+ args: "--check --diff --target-version py36 $GITHUB_WORKSPACE"
+ flake8:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.x'
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install .
+ pip install flake8
+ - name: Flake8
+ run: |
+ # stop the build if there are Python syntax errors or undefined names
+ flake8 . --count --select=E901,E999,F821,F822,F823,W605 --show-source --statistics
+ # Some warning codes are ignored because they conflict with black's formatting, or are
+ # incompatible with MoviePy's structure
+ # E203: whitespace before ':'
+ # E302: expected 2 blank lines, found 0
+ # E402: module level import not at top of file
+ # W291: trailing whitespace
+ # W293: blank line contains whitespace
+ # W503: line break before binary operator
+ flake8 moviepy --ignore=E203,E302,E402,W291,W293,W503 --max-complexity=10 --max-line-length=127 --statistics --count --exit-zero
+ # Check examples and tests with slightly relaxed rules to allow 'star' imports
+ # F403 'from moviepy.editor import *' used; unable to detect undefined names
+ # F405 'name' may be undefined, or defined from star imports: moviepy.editor
+ flake8 . --ignore=E203,E302,E402,W291,W293,W503,F403,F405 --exclude moviepy/ --max-complexity=10 --max-line-length=127 --statistics --count --exit-zero
diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml
deleted file mode 100644
index c7bed2d4..00000000
--- a/.github/workflows/pythonpackage.yml
+++ /dev/null
@@ -1,75 +0,0 @@
-# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
-# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
-
-name: Python package
-
-on:
- push:
- branches:
- - '**'
- pull_request:
- branches: [ master ]
-
-jobs:
- # Uses Python Framework build because on macos matplotlib requires it
- macos:
- runs-on: macos-latest
- strategy:
- matrix:
- python-version: [3.7]
- steps:
- - uses: actions/checkout@v2
- - uses: s-weigand/setup-conda@v1
- with:
- activate-conda: true
- # TODO: fix adding the different versions
- # Pick the installation of Python Framework build from conda, because they do not support versioning
- # https://anaconda.org/anaconda/python.app/files
- #- name: Install conda python version 3.6
- # if: matrix.python-version == '3.6'
- # run: conda install http://repo.continuum.io/pkgs/main/osx-64/python.app-2-py36_10.tar.bz2
- #- name: Install conda python version 3.7
- # if: matrix.python-version == '3.7'
- # run: conda install http://repo.continuum.io/pkgs/main/osx-64/python.app-2-py37_10.tar.bz2
- #- name: Install conda python version 3.8
- # if: matrix.python-version == '3.8'
- # run: conda install http://repo.continuum.io/pkgs/main/osx-64/python.app-2-py38_10.tar.bz2
- - name: install pythonw
- run: conda install python.app
- - name: Python version
- run: |
- pythonw --version
- which python
- pythonw -m site --user-site
- echo $PYTHONPATH
- echo $PYTHONHOME
- - name: Install dependencies
- run: |
- brew install imagemagick
- # needed for installing matplotlib
- brew install pkg-config
- pythonw -m pip install -e ".[optional, test, doc]"
- pythonw -m pip install flake8
- pythonw -m pip install --upgrade setuptools
- pythonw -m pip install --upgrade pytest-cov
-
- - name: Lint with flake8
- run: |
- # stop the build if there are Python syntax errors or undefined names
- flake8 . --count --select=E901,E999,F821,F822,F823,W605 --show-source --statistics
- # Some warning codes are ignored because they conflict with black's formatting, or are
- # incompatible with MoviePy's structure
- # E203: whitespace before ':'
- # E302: expected 2 blank lines, found 0
- # E402: module level import not at top of file
- # W291: trailing whitespace
- # W293: blank line contains whitespace
- # W503: line break before binary operator
- flake8 moviepy --ignore=E203,E302,E402,W291,W293,W503 --max-complexity=10 --max-line-length=127 --statistics --count --exit-zero
- # Check examples and tests with slightly relaxed rules to allow 'star' imports
- # F403 'from moviepy.editor import *' used; unable to detect undefined names
- # F405 'name' may be undefined, or defined from star imports: moviepy.editor
- flake8 . --ignore=E203,E302,E402,W291,W293,W503,F403,F405 --exclude moviepy/ --max-complexity=10 --max-line-length=127 --statistics --count --exit-zero
- - name: Test with pytest
- run: |
- pythonw -m pytest tests/ --doctest-modules -v
diff --git a/.github/workflows/test_suite.yml b/.github/workflows/test_suite.yml
new file mode 100644
index 00000000..66fe8e94
--- /dev/null
+++ b/.github/workflows/test_suite.yml
@@ -0,0 +1,158 @@
+# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
+# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
+
+name: Run Test Suite
+
+on:
+ push:
+ branches:
+ - '**'
+ pull_request:
+ branches:
+ - '**'
+ schedule:
+ # Run once a week
+ - cron: '* * */7 * *'
+
+jobs:
+ # Uses Python Framework build because on macos matplotlib requires it
+ macos:
+ runs-on: macos-latest
+ strategy:
+ matrix:
+ python-version: [3.7]
+ steps:
+ - uses: actions/checkout@v2
+ - uses: s-weigand/setup-conda@v1
+ with:
+ activate-conda: true
+ # TODO: fix adding the different versions
+ # Pick the installation of Python Framework build from conda, because they do not support versioning
+ # https://anaconda.org/anaconda/python.app/files
+ #- name: Install conda python version 3.6
+ # if: matrix.python-version == '3.6'
+ # run: conda install http://repo.continuum.io/pkgs/main/osx-64/python.app-2-py36_10.tar.bz2
+ #- name: Install conda python version 3.7
+ # if: matrix.python-version == '3.7'
+ # run: conda install http://repo.continuum.io/pkgs/main/osx-64/python.app-2-py37_10.tar.bz2
+ #- name: Install conda python version 3.8
+ # if: matrix.python-version == '3.8'
+ # run: conda install http://repo.continuum.io/pkgs/main/osx-64/python.app-2-py38_10.tar.bz2
+ - name: Install pythonw
+ run: conda install python.app
+ - name: Python Version Info
+ run: |
+ pythonw --version
+ which python
+ pythonw -m site --user-site
+ echo $PYTHONPATH
+ echo $PYTHONHOME
+ - name: Install dependencies
+ run: |
+ brew install imagemagick
+ # needed for installing matplotlib
+ brew install pkg-config
+ python -m pip install --upgrade wheel
+ python -m pip install --upgrade setuptools
+ python -m pip install ".[test]"
+
+ - name: Test with pytest
+ run: |
+ pythonw -m pytest tests/ --doctest-modules -v
+
+
+# TODO Re-enable when ImageMagick is fixed or removed
+# windows:
+# runs-on: windows-latest
+# strategy:
+# matrix:
+# python-version: [3.6, 3.7, 3.8]
+# fail-fast: false
+# steps:
+# - uses: actions/checkout@v2
+# - name: Set up Python ${{ matrix.python-version }}
+# uses: actions/setup-python@v2
+# with:
+# python-version: ${{ matrix.python-version }}
+# - name: Python Version Info
+# shell: cmd
+# run: |
+# python --version
+# which python
+# python -m site --user-site
+#
+# - name: Install Dependencies
+# shell: cmd
+# run: |
+# python find_latest_imagemagick_version.py > temp.txt
+# set /p IMAGE_MAGICK_VERSION=<temp.txt
+#
+# echo %IMAGE_MAGICK_VERSION%
+# echo https://imagemagick.org/download/binaries/ImageMagick-%IMAGE_MAGICK_VERSION%-%ARCH%-static.exe
+# :: Download ImageMagick installer (which also installs ffmpeg.)
+# :: From http://ftp.fifi.org/ImageMagick/binaries/
+# :: Might need to be updated from time to time
+# :: Versions >=7.0 have problems - executables changed names.
+# :: Assume 64-bit. Need to change to x86 for 32-bit.
+# curl https://imagemagick.org/download/binaries/ImageMagick-%IMAGE_MAGICK_VERSION%-x64-static.exe -o ImageMagick.exe
+#
+# :: Install ImageMagick, telling InnoSetup to not open a window and change default install dir
+# ImageMagick.exe /SILENT /SP /DIR="%IMAGE_MAGICK_INSTALL_DIR%"
+#
+# :: Inspect contents and set env vars
+# dir "%IMAGE_MAGICK_INSTALL_DIR%"
+# set IMAGEMAGICK_BINARY="%IMAGE_MAGICK_INSTALL_DIR%//convert.exe"
+# echo %IMAGEMAGICK_BINARY%
+# set FMPEG_BINARY="%IMAGE_MAGICK_INSTALL_DIR%//ffmpeg.exe"
+# echo %FMPEG_BINARY%
+#
+# python -m pip install --upgrade wheel
+# python -m pip install --upgrade setuptools
+# python -m pip install ".[test]"
+#
+# - name: PyTest
+# run: |
+# pytest
+
+ linux:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version: [3.6, 3.7, 3.8]
+ fail-fast: false
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - name: Python Version Info
+ run: |
+ python --version
+ which python
+ python -m site --user-site
+
+ - name: Install Dependencies
+ run: |
+ python -m pip install --upgrade wheel
+ python -m pip install --upgrade setuptools
+ python -m pip install ".[test, optional, doc]"
+ cat /etc/ImageMagick-6/policy.xml | sed 's/none/read,write/g' | sudo tee /etc/ImageMagick-6/policy.xml
+
+ - name: PyTest
+ run: |
+ pytest tests/ --doctest-modules -v --cov moviepy --cov-report term-missing
+
+ - name: Test pip installation
+ run: |
+ pip install -e .
+ pip install -e .[optional]
+ pip install -e .[test]
+ pip install -e .[doc]
+
+ - name: Coveralls
+ env:
+ COVERALLS_REPO_TOKEN: w480ZQkQQ8I9wZECi8kA3m2SqqTjNis0Y
+ run: |
+ coveralls
diff --git a/tests/test_examples.py b/tests/test_examples.py
index 4e516198..e9948cd2 100644
--- a/tests/test_examples.py
+++ b/tests/test_examples.py
@@ -15,8 +15,9 @@ except ImportError:
matplotlib = None
[email protected](True, reason="testing on github actions")
@pytest.mark.skipif(not matplotlib, reason="no mpl")
[email protected](PYTHON_VERSION == "3.5" and TRAVIS, reason="travis py35")
[email protected](PYTHON_VERSION == "3.5", reason="travis py35")
def test_matplotlib():
# for now, python 3.5 installs a version of matplotlib that complains
# about $DISPLAY variable, so lets just ignore for now.