ci.yml 5.0 KB

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