ci.yml 4.3 KB

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