ci.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. name: ci
  2. on:
  3. push:
  4. branches:
  5. - master
  6. pull_request:
  7. jobs:
  8. build:
  9. runs-on: ${{ matrix.os }}
  10. strategy:
  11. matrix:
  12. os: [macos-latest, ubuntu-latest, windows-latest]
  13. python-version: ['3.7', '2.7']
  14. PYTEST_QT_API: [pyqt5, pyqt4v2, pyside2]
  15. exclude:
  16. - os: macos-latest
  17. PYTEST_QT_API: pyqt4v2
  18. - os: macos-latest
  19. PYTEST_QT_API: pyside2
  20. - os: windows-latest
  21. PYTEST_QT_API: pyqt4v2
  22. - os: windows-latest
  23. PYTEST_QT_API: pyside2
  24. - python-version: '3.7'
  25. PYTEST_QT_API: pyqt4v2
  26. steps:
  27. - uses: actions/checkout@v2
  28. with:
  29. submodules: true
  30. - uses: goanpeca/setup-miniconda@v1
  31. with:
  32. auto-update-conda: true
  33. python-version: ${{ matrix.python-version }}
  34. - name: Install system dependencies
  35. shell: bash -l {0}
  36. run: |
  37. if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
  38. sudo apt-get install -y coreutils
  39. sudo apt-get install -y xvfb herbstluftwm
  40. elif [ "${{ matrix.os }}" = "macos-latest" ]; then
  41. brew install coreutils
  42. brew cask install xquartz
  43. fi
  44. - name: Set up Python
  45. shell: bash -l {0}
  46. run: |
  47. conda install -q -y python=${{ matrix.python-version }}
  48. which python
  49. python --version
  50. pip --version
  51. - name: Install dependencies
  52. shell: bash -l {0}
  53. run: |
  54. if [ "${{ matrix.PYTEST_QT_API }}" = "pyside2" ]; then
  55. if [ "${{ matrix.python-version }}" = "2.7" ]; then
  56. conda install -q -y 'pyside2!=5.12.4' -c conda-forge
  57. else
  58. conda install -q -y pyside2 -c conda-forge
  59. fi
  60. elif [ "${{ matrix.PYTEST_QT_API }}" = "pyqt4v2" ]; then
  61. conda install -q -y pyqt=4 -c conda-forge
  62. else # pyqt5
  63. if [ "${{ matrix.python-version }}" = "2.7" ]; then
  64. conda install -q -y pyqt=5
  65. else
  66. pip install pyqt5
  67. fi
  68. fi
  69. if [ "${{ matrix.os }}" != "windows-latest" ]; then
  70. conda install -q -y help2man
  71. fi
  72. pip install hacking pytest pytest-qt
  73. - name: Install main
  74. shell: bash -l {0}
  75. run: |
  76. pip install .
  77. - name: Lint with flake8
  78. shell: bash -l {0}
  79. if: matrix.os != 'windows-latest'
  80. run: |
  81. flake8 .
  82. - name: Black
  83. shell: bash -l {0}
  84. if: matrix.os != 'windows-latest' && matrix.python-version != '2.7'
  85. run: |
  86. pip install black
  87. black --line-length 79 --check --diff labelme
  88. - name: Test with pytest
  89. shell: bash -l {0}
  90. if: matrix.os != 'windows-latest'
  91. env:
  92. PYTEST_QT_API: ${{ matrix.PYTEST_QT_API }}
  93. run: |
  94. # open virtual display
  95. if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
  96. export DISPLAY=:99.0
  97. /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
  98. (herbstluftwm )&
  99. else
  100. (sudo Xvfb :99 -ac -screen 0 1024x768x8 )&
  101. fi
  102. # run test
  103. MPLBACKEND='agg' pytest tests -m 'not gpu'
  104. - name: Run examples
  105. shell: bash -l {0}
  106. if: matrix.os != 'windows-latest'
  107. env:
  108. MPLBACKEND: agg
  109. run: |
  110. labelme --help
  111. labelme --version
  112. (cd examples/primitives && labelme_json_to_dataset primitives.json && rm -rf primitives_json)
  113. (cd examples/tutorial && rm -rf apc2016_obj3_json && labelme_json_to_dataset apc2016_obj3.json && python load_label_png.py && git checkout -- .)
  114. (cd examples/semantic_segmentation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  115. (cd examples/instance_segmentation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  116. (cd examples/video_annotation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  117. pip install lxml # for bbox_detection/labelme2voc.py
  118. (cd examples/bbox_detection && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  119. pip install cython && pip install pycocotools # for instance_segmentation/labelme2coco.py
  120. (cd examples/instance_segmentation && rm -rf data_dataset_coco && ./labelme2coco.py data_annotated data_dataset_coco --labels labels.txt && git checkout -- .)
  121. - name: Run pyinstaller
  122. shell: bash -l {0}
  123. if: matrix.PYTEST_QT_API == 'pyqt5' && matrix.python-version == '3.7'
  124. run: |
  125. # Build the standalone executable
  126. pip install pyinstaller
  127. pyinstaller labelme.spec
  128. dist/labelme --version