main.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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]
  13. PYTEST_QT_API: [pyqt5, pyqt4v2, pyside2]
  14. PYTHON_VERSION: ['2.7', '3.6']
  15. exclude:
  16. - os: macOS-latest
  17. PYTEST_QT_API: pyqt4v2
  18. - os: macOS-latest
  19. PYTEST_QT_API: pyside2
  20. - PYTHON_VERSION: '3.6'
  21. PYTEST_QT_API: pyqt4v2
  22. steps:
  23. - uses: actions/checkout@v1
  24. - name: Update submodules
  25. run: |
  26. git submodule update --init --recursive
  27. - name: Install system dependencies
  28. run: |
  29. if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
  30. sudo apt-get install -y coreutils
  31. sudo apt-get install -y xvfb herbstluftwm
  32. else
  33. brew install coreutils
  34. brew cask install xquartz
  35. fi
  36. - name: Set up Miniconda
  37. run: |
  38. if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
  39. curl -L -o miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
  40. else
  41. curl -L -o miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
  42. fi
  43. bash miniconda.sh -b -p $HOME/miniconda
  44. rm -f miniconda.sh
  45. export PATH="$HOME/miniconda/bin:$PATH"
  46. conda config --set always_yes yes --set changeps1 no
  47. conda update -q conda
  48. conda info -a
  49. - name: Set up Python
  50. env:
  51. PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
  52. run: |
  53. export PATH="$HOME/miniconda/bin:$PATH"
  54. conda install -y python=$PYTHON_VERSION
  55. which python
  56. python --version
  57. pip --version
  58. - name: Install dependencies
  59. run: |
  60. export PATH="$HOME/miniconda/bin:$PATH"
  61. if [ "${{ matrix.PYTEST_QT_API }}" = "pyside2" ]; then
  62. if [ "${{ matrix.PYTHON_VERSION }}" = "2.7" ]; then
  63. conda install -y 'pyside2!=5.12.4' -c conda-forge
  64. else
  65. conda install -y pyside2 -c conda-forge
  66. fi
  67. elif [ "${{ matrix.PYTEST_QT_API }}" = "pyqt4v2" ]; then
  68. conda install -y pyqt=4 -c conda-forge
  69. else # pyqt5
  70. conda install -y pyqt=5
  71. fi
  72. conda install -y help2man
  73. pip install flake8 pytest pytest-qt
  74. - name: Install main
  75. run: |
  76. export PATH="$HOME/miniconda/bin:$PATH"
  77. pip install .
  78. - name: Lint with flake8
  79. run: |
  80. export PATH="$HOME/miniconda/bin:$PATH"
  81. flake8 .
  82. - name: Test with pytest
  83. env:
  84. PYTEST_QT_API: ${{ matrix.PYTEST_QT_API }}
  85. run: |
  86. # open virtual display
  87. if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
  88. export DISPLAY=:99.0
  89. /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
  90. (herbstluftwm )&
  91. else
  92. (sudo Xvfb :99 -ac -screen 0 1024x768x8 )&
  93. fi
  94. # run test
  95. export PATH="$HOME/miniconda/bin:$PATH"
  96. MPLBACKEND='agg' pytest tests -m 'not gpu'
  97. - name: Run examples
  98. env:
  99. MPLBACKEND: agg
  100. run: |
  101. export PATH="$HOME/miniconda/bin:$PATH"
  102. labelme --help
  103. labelme --version
  104. (cd examples/primitives && labelme_json_to_dataset primitives.json && rm -rf primitives_json)
  105. (cd examples/tutorial && rm -rf apc2016_obj3_json && labelme_json_to_dataset apc2016_obj3.json && python load_label_png.py && git checkout -- .)
  106. (cd examples/semantic_segmentation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  107. (cd examples/instance_segmentation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  108. (cd examples/video_annotation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  109. pip install lxml # for bbox_detection/labelme2voc.py
  110. (cd examples/bbox_detection && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
  111. pip install cython && pip install pycocotools # for instance_segmentation/labelme2coco.py
  112. (cd examples/instance_segmentation && rm -rf data_dataset_coco && ./labelme2coco.py data_annotated data_dataset_coco --labels labels.txt && git checkout -- .)
  113. - name: Run pyinstaller
  114. run: |
  115. if [ "${{ matrix.PYTEST_QT_API }}" = "pyqt5" -a "${{ matrix.PYTHON_VERSION }}" = "3.6" ]; then
  116. export PATH="$HOME/miniconda/bin:$PATH"
  117. # Build the standalone executable
  118. pip install 'pyinstaller!=3.4' # 3.4 raises error
  119. pyinstaller labelme.spec
  120. dist/labelme --version
  121. fi