ci.yml 4.9 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
      env:
        PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
      run: |
K
Kentaro Wada 已提交
59
        conda install -q -y python=$PYTHON_VERSION
K
Kentaro Wada 已提交
60 61 62 63 64
        which python
        python --version
        pip --version

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

94 95 96 97 98 99
    # - name: Black
    #   shell: bash -l {0}
    #   if: matrix.os != 'windows-latest' && matrix.python-version != '2.7'
    #   run: |
    #     pip install black
    #     black --check .
K
Kentaro Wada 已提交
100

K
Kentaro Wada 已提交
101
    - name: Test with pytest
K
Kentaro Wada 已提交
102 103
      shell: bash -l {0}
      if: matrix.os != 'windows-latest'
K
Kentaro Wada 已提交
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
      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 已提交
119 120
      shell: bash -l {0}
      if: matrix.os != 'windows-latest'
K
Kentaro Wada 已提交
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
      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 已提交
139
      shell: bash -l {0}
140
      if: matrix.PYTEST_QT_API == 'pyqt5' && matrix.python-version == '3.7'
K
Kentaro Wada 已提交
141
      run: |
142 143 144 145 146
        # Build the standalone executable
        pip install 'pyinstaller!=3.4'
        pip install 'setuptools<45.0.0'
        pyinstaller labelme.spec
        dist/labelme --version