ci.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.9']
  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.9'
  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. conda install -q -y pyside2 -c conda-forge
  52. elif [ "${{ matrix.PYTEST_QT_API }}" = "pyqt4v2" ]; then
  53. conda install -q -y pyqt=4 -c conda-forge
  54. else # pyqt5
  55. if [ "${{ matrix.os }}" = "macos-latest" -a "${{ matrix.python-version }}" = "3.9" ]; then
  56. pip install pyqt5
  57. else
  58. conda install -q -y pyqt=5
  59. fi
  60. fi
  61. if [ "${{ matrix.os }}" != "windows-latest" ]; then
  62. conda install -q -y help2man
  63. fi
  64. pip install pytest 'pytest-qt<4'
  65. - name: Install main
  66. shell: bash -l {0}
  67. run: |
  68. pip install .
  69. - name: Lint with flake8
  70. shell: bash -l {0}
  71. if: matrix.os != 'windows-latest'
  72. run: |
  73. pip install hacking==4.1.0
  74. flake8 .
  75. - name: Black
  76. shell: bash -l {0}
  77. if: matrix.os != 'windows-latest'
  78. run: |
  79. pip install black==22.1.0
  80. black --line-length 79 --check --diff labelme/
  81. - name: Test with pytest
  82. shell: bash -l {0}
  83. if: matrix.os != 'windows-latest'
  84. env:
  85. PYTEST_QT_API: ${{ matrix.PYTEST_QT_API }}
  86. run: |
  87. # open virtual display
  88. if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
  89. export DISPLAY=:99.0
  90. /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
  91. (herbstluftwm )&
  92. else
  93. (sudo Xvfb :99 -ac -screen 0 1024x768x8 )&
  94. fi
  95. # run test
  96. MPLBACKEND='agg' pytest tests/
  97. - name: Run examples
  98. shell: bash -l {0}
  99. if: matrix.os != 'windows-latest'
  100. env:
  101. MPLBACKEND: agg
  102. run: |
  103. labelme --help
  104. labelme --version
  105. (cd examples/primitives && labelme_json_to_dataset primitives.json && rm -rf primitives_json)
  106. (cd examples/tutorial && rm -rf apc2016_obj3_json && labelme_json_to_dataset apc2016_obj3.json && python load_label_png.py && git checkout -- .)
  107. (cd examples/semantic_segmentation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  108. (cd examples/instance_segmentation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  109. (cd examples/video_annotation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  110. pip install lxml # for bbox_detection/labelme2voc.py
  111. (cd examples/bbox_detection && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  112. pip install cython && pip install pycocotools # for instance_segmentation/labelme2coco.py
  113. (cd examples/instance_segmentation && rm -rf data_dataset_coco && ./labelme2coco.py data_annotated data_dataset_coco --labels labels.txt && git checkout -- .)
  114. - name: Run pyinstaller
  115. shell: bash -l {0}
  116. if: matrix.PYTEST_QT_API == 'pyqt5' && matrix.python-version == '3.9'
  117. run: |
  118. # Build the standalone executable
  119. pip install PyQt5 -I --use-feature=2020-resolver # https://stackoverflow.com/a/68784578
  120. pip install pyinstaller
  121. pyinstaller labelme.spec
  122. dist/labelme --version