Repository: hhatto/pgmagick (language: python)

Issue:
migrate to GitHub Actions from TravisCI



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/python-macos.yml b/.github/workflows/python-macos.yml
new file mode 100644
index 0000000..3031150
--- /dev/null
+++ b/.github/workflows/python-macos.yml
@@ -0,0 +1,28 @@
+name: Python package on macOS
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+  schedule:
+    - cron: 0 15 * * *
+
+env:
+  PYTHON: python3
+
+jobs:
+  build:
+    runs-on: macos-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Install requirements on macOSX
+      run: |
+        HOMEBREW_NO_AUTO_UPDATE=1 brew install python@3.9 graphicsmagick boost-python3
+    - name: Install dependencies
+      run: |
+        python3 -m pip install --upgrade pip
+        python3 setup.py install
+    - name: Test
+      run: |
+        make test
diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml
new file mode 100644
index 0000000..b355d80
--- /dev/null
+++ b/.github/workflows/python.yml
@@ -0,0 +1,31 @@
+name: Python package
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+  schedule:
+    - cron: 0 15 * * *
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: ['3.6', '3.7', '3.8', '3.9']
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+    - name: Install requirements on Linux
+      run: sudo apt-get install libboost-python-dev libgraphicsmagick++1-dev
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        python setup.py install
+    - name: Test
+      run: |
+        make test
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 870fb14..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,54 +0,0 @@
-dist: trusty
-
-matrix:
-    include:
-        - os: osx
-          env: TARGET=macosx2
-        - os: osx
-          env: TARGET=macosx3
-        - python: "2.7"
-          language: python
-          env: TARGET=linux
-        - python: "3.5"
-          language: python
-          env: TARGET=linux
-          dist: xenial      # use python3.5
-    allow_failures:
-        - python: "3.2"
-
-addons:
-    apt:
-        packages:
-            - libboost-python-dev
-            - libgraphicsmagick++1-dev
-            - python3-setuptools
-            - gsfonts
-
-before_install:
-    - if [[ "$TARGET" == "macosx2" ]]; then
-          brew update;
-          brew install boost-python graphicsmagick;
-          brew outdated boost-python || brew upgrade boost-python;
-          brew outdated graphicsmagick || brew upgrade graphicsmagick;
-          brew outdated python@2 || brew upgrade python@2;
-      fi
-    - if [[ "$TARGET" == "macosx3" ]]; then
-          brew install python@3.8 boost-python3 graphicsmagick;
-          brew outdated boost-python3 || brew upgrade boost-python3;
-          brew outdated graphicsmagick || brew upgrade graphicsmagick;
-          brew outdated python@3.8 || brew upgrade python@3.8;
-      fi
-
-install:
-    - if [[ "$TRAVIS_PYTHON_VERSION" == "2."* ]]; then sudo /usr/bin/python setup.py install; fi
-    - if [[ "$TRAVIS_PYTHON_VERSION" == "3.4"* ]]; then sudo mkdir -p /usr/lib/python3.4/site-packages/ ; sudo /usr/bin/python3 setup.py install; fi
-    - if [[ "$TRAVIS_PYTHON_VERSION" == "3.5"* ]]; then sudo mkdir -p /usr/lib/python3.5/site-packages/ ; sudo /usr/bin/python3 setup.py install; fi
-    - if [[ "$TARGET" == "macosx2" ]]; then python setup.py install; fi
-    - if [[ "$TARGET" == "macosx3" ]]; then /usr/local/opt/python@3.8/bin/python3 setup.py install; fi
-
-script:
-    - if [[ "$TRAVIS_PYTHON_VERSION" == "2."* ]]; then PYTHON=/usr/bin/python make test; fi
-    - if [[ "$TRAVIS_PYTHON_VERSION" == "3."* ]]; then PYTHON=/usr/bin/python3 make test; fi
-    - if [[ "$TARGET" == "macosx2" ]]; then PYTHON=`which python` make test; fi
-    - if [[ "$TARGET" == "macosx3" ]]; then PYTHON=/usr/local/opt/python@3.8/bin/python3 make test; fi
-    - ls setup.py


Test patch:
diff --git a/test/test_cookbook.py b/test/test_cookbook.py
index 7fe8acd..9be3376 100644
--- a/test/test_cookbook.py
+++ b/test/test_cookbook.py
@@ -5,6 +5,8 @@
 from pgmagick import api
 from pgmagick import Image, Geometry, Blob
 
+from utils import MACOSX_FONT
+
 
 class TestCookbook(unittest.TestCase):
 
@@ -33,14 +35,14 @@ def test_gradient_png_image(self):
     def test_annotate(self):
         img = api.Image((300, 200))
         if sys.platform.lower() == 'darwin':
-            img.font("/Library/Fonts/Arial.ttf")
+            img.font(MACOSX_FONT)
         img.annotate('Hello World')
         img.write(self.tmp_filename_png)
 
     def test_annotate_with_angle45(self):
         img = api.Image((300, 200))
         if sys.platform.lower() == 'darwin':
-            img.font("/Library/Fonts/Arial.ttf")
+            img.font(MACOSX_FONT)
         img.annotate('Hello World', angle=45)
         img.write(self.tmp_filename_png)
 
diff --git a/test/test_pgmagick_api.py b/test/test_pgmagick_api.py
index 010ac6b..8db2d7d 100644
--- a/test/test_pgmagick_api.py
+++ b/test/test_pgmagick_api.py
@@ -6,6 +6,8 @@
 import pgmagick
 from pgmagick.api import Image, Draw
 
+from utils import MACOSX_FONT
+
 
 print(pgmagick.gminfo().version)
 LIBGM_VERSION = [int(v) for v in pgmagick.gminfo().version.split('.')]
@@ -49,7 +51,7 @@ def test_scale_with_filtertype(self):
         for k, v in testset.items():
             img = Image((600, 400), 'gradient:#ffffff-#000000')
             if sys.platform.lower() == 'darwin':
-                img.font("/Library/Fonts/Arial.ttf")
+                img.font(MACOSX_FONT)
             img.annotate("hello", (100, 100))
             if k != "None":
                 img.scale(0.6, k)
@@ -94,7 +96,7 @@ def test_fontpointsize(self):
         self.assertEqual(60, img.font_pointsize())
         self.assertEqual(float, type(img.font_pointsize()))
         if sys.platform.lower() == 'darwin':
-            img.font("/Library/Fonts/Arial.ttf")
+            img.font(MACOSX_FONT)
         img.annotate("hello", (100, 100))
         img.write('t.png')
 
diff --git a/test/utils.py b/test/utils.py
new file mode 100644
index 0000000..6f5a418
--- /dev/null
+++ b/test/utils.py
@@ -0,0 +1,1 @@
+MACOSX_FONT = "/System/Library/Fonts/Keyboard.ttf"