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

    steps:
K
Kentaro Wada 已提交
31 32 33
    - uses: actions/checkout@v2
      with:
        submodules: true
K
Kentaro Wada 已提交
34

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

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

    - name: Set up Python
K
Kentaro Wada 已提交
52
      shell: bash -l {0}
K
Kentaro Wada 已提交
53
      run: |
K
Kentaro Wada 已提交
54
        conda install -q -y python=${{ matrix.python-version }}
K
Kentaro Wada 已提交
55 56 57 58 59
        which python
        python --version
        pip --version

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

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

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

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

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