ci.yml 4.7 KB
Newer Older
K
Kentaro Wada 已提交
1
name: ci
K
Kentaro Wada 已提交
2

K
Kentaro Wada 已提交
3 4 5 6 7
on:
  push:
    branches:
      - master
  pull_request:
K
Kentaro Wada 已提交
8 9 10 11 12 13 14

jobs:
  build:

    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
K
Kentaro Wada 已提交
15 16
        os: [macos-latest, ubuntu-latest, windows-latest]
        python-version: ['3.7', '2.7']
K
Kentaro Wada 已提交
17 18
        PYTEST_QT_API: [pyqt5, pyqt4v2, pyside2]
        exclude:
K
Kentaro Wada 已提交
19
          - os: macos-latest
K
Kentaro Wada 已提交
20
            PYTEST_QT_API: pyqt4v2
K
Kentaro Wada 已提交
21
          - os: macos-latest
K
Kentaro Wada 已提交
22
            PYTEST_QT_API: pyside2
K
Kentaro Wada 已提交
23 24 25 26 27 28
          - os: windows-latest
            PYTEST_QT_API: pyqt4v2
          - os: windows-latest
            PYTEST_QT_API: pyside2
          - python-version: '3.7'
            PYTEST_QT_API: pyqt4v2
K
Kentaro Wada 已提交
29 30 31 32

    steps:
    - uses: actions/checkout@v1

K
Kentaro Wada 已提交
33 34 35 36 37
    - uses: goanpeca/setup-miniconda@v1
      with:
        auto-update-conda: true
        python-version: ${{ matrix.python-version }}

K
Kentaro Wada 已提交
38
    - name: Update submodules
K
Kentaro Wada 已提交
39
      shell: bash -l {0}
K
Kentaro Wada 已提交
40 41 42 43
      run: |
        git submodule update --init --recursive

    - name: Install system dependencies
K
Kentaro Wada 已提交
44
      shell: bash -l {0}
K
Kentaro Wada 已提交
45 46 47 48
      run: |
        if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
          sudo apt-get install -y coreutils
          sudo apt-get install -y xvfb herbstluftwm
K
Kentaro Wada 已提交
49
        elif [ "${{ matrix.os }}" = "macos-latest" ]; then
K
Kentaro Wada 已提交
50 51 52 53 54
          brew install coreutils
          brew cask install xquartz
        fi

    - name: Set up Python
K
Kentaro Wada 已提交
55
      shell: bash -l {0}
K
Kentaro Wada 已提交
56 57 58 59 60 61 62 63 64
      env:
        PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
      run: |
        conda install -y python=$PYTHON_VERSION
        which python
        python --version
        pip --version

    - name: Install dependencies
K
Kentaro Wada 已提交
65
      shell: bash -l {0}
K
Kentaro Wada 已提交
66 67 68 69 70 71 72 73 74 75 76 77
      run: |
        if [ "${{ matrix.PYTEST_QT_API }}" = "pyside2" ]; then
          if [ "${{ matrix.PYTHON_VERSION }}" = "2.7" ]; then
            conda install -y 'pyside2!=5.12.4' -c conda-forge
          else
            conda install -y pyside2 -c conda-forge
          fi
        elif [ "${{ matrix.PYTEST_QT_API }}" = "pyqt4v2" ]; then
          conda install -y pyqt=4 -c conda-forge
        else  # pyqt5
          conda install -y pyqt=5
        fi
K
Kentaro Wada 已提交
78 79 80
        if [ "${{ matrix.os }}" != "windows-latest" ]; then
          conda install -y help2man
        fi
K
Kentaro Wada 已提交
81
        pip install hacking pytest pytest-qt
K
Kentaro Wada 已提交
82 83

    - name: Install main
K
Kentaro Wada 已提交
84
      shell: bash -l {0}
K
Kentaro Wada 已提交
85 86 87 88
      run: |
        pip install .

    - name: Lint with flake8
K
Kentaro Wada 已提交
89 90
      shell: bash -l {0}
      if: matrix.os != 'windows-latest'
K
Kentaro Wada 已提交
91 92 93 94
      run: |
        flake8 .

    - name: Test with pytest
K
Kentaro Wada 已提交
95 96
      shell: bash -l {0}
      if: matrix.os != 'windows-latest'
K
Kentaro Wada 已提交
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
      env:
        PYTEST_QT_API: ${{ matrix.PYTEST_QT_API }}
      run: |
        # open virtual display
        if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
          export DISPLAY=:99.0
          /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX +render -noreset
          (herbstluftwm )&
        else
          (sudo Xvfb :99 -ac -screen 0 1024x768x8 )&
        fi
        # run test
        MPLBACKEND='agg' pytest tests -m 'not gpu'

    - name: Run examples
K
Kentaro Wada 已提交
112 113
      shell: bash -l {0}
      if: matrix.os != 'windows-latest'
K
Kentaro Wada 已提交
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
      env:
        MPLBACKEND: agg
      run: |
        labelme --help
        labelme --version
        (cd examples/primitives && labelme_json_to_dataset primitives.json && rm -rf primitives_json)
        (cd examples/tutorial && rm -rf apc2016_obj3_json && labelme_json_to_dataset apc2016_obj3.json && python load_label_png.py && git checkout -- .)
        (cd examples/semantic_segmentation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
        (cd examples/instance_segmentation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
        (cd examples/video_annotation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)

        pip install lxml  # for bbox_detection/labelme2voc.py
        (cd examples/bbox_detection && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)

        pip install cython && pip install pycocotools  # for instance_segmentation/labelme2coco.py
        (cd examples/instance_segmentation && rm -rf data_dataset_coco && ./labelme2coco.py data_annotated data_dataset_coco --labels labels.txt && git checkout -- .)

    - name: Run pyinstaller
K
Kentaro Wada 已提交
132
      shell: bash -l {0}
133
      if: matrix.PYTEST_QT_API == 'pyqt5' && matrix.python-version == '3.7'
K
Kentaro Wada 已提交
134
      run: |
135 136 137 138 139
        # Build the standalone executable
        pip install 'pyinstaller!=3.4'
        pip install 'setuptools<45.0.0'
        pyinstaller labelme.spec
        dist/labelme --version