forked from mapillary/mapillary_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (103 loc) · 4.3 KB
/
python-package.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [ main ]
tags:
- 'v*.*.*'
pull_request:
branches: [ main ]
jobs:
build:
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
platform: ['ubuntu-latest', 'macos-latest', 'windows-latest']
architecture: ['x64']
include:
- architecture: 'x86'
platform: 'windows-latest'
python-version: 3.11
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- name: Setup FFmpeg
uses: FedericoCarboni/setup-ffmpeg@v2
- name: Set up ${{ matrix.architecture }} Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# optional x64 or x86. Defaults to x64 if not specified
architecture: ${{ matrix.architecture }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install -r requirements-dev.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Lint with black
run: |
black --check mapillary_tools tests
- name: Sort imports with usort
run: |
usort diff mapillary_tools/
- name: Type check with mypy
run: |
mypy mapillary_tools
- name: Test with pytest
run: |
mapillary_tools --version
pytest tests
env:
MAPILLARY_TOOLS_EXECUTABLE: mapillary_tools
- name: Build and test with Pyinstaller on MacOS (Python 3.11 only)
# Enable for Python3.11 only because it often fails at codesign (subprocess timeout)
if: matrix.platform == 'macos-latest' && startsWith(github.ref, 'refs/tags/') && matrix.python-version == 3.11
run: |
# see https://github.com/mapillary/mapillary_tools/issues/566
# TODO: move it to extras in setup.py
python3 -m pip install pysocks
./script/build_osx
# Could run full integration tests with the binary (it might be slow)
pytest tests/integration
env:
MAPILLARY_TOOLS_EXECUTABLE: ./dist/osx/mapillary_tools
- name: Build and test with Pyinstaller on Ubuntu (Python 3.11 only)
if: matrix.platform == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/') && matrix.python-version == 3.11
run: |
# see https://github.com/mapillary/mapillary_tools/issues/566
# TODO: move it to extras in setup.py
python3 -m pip install pysocks
./script/build_linux
# Could run full integration tests with the binary (it might be slow)
pytest tests/integration
env:
MAPILLARY_TOOLS_EXECUTABLE: ./dist/linux/mapillary_tools
- name: Build and test with Pyinstaller on Windows (Python 3.11 only)
if: matrix.platform == 'windows-latest' && startsWith(github.ref, 'refs/tags/') && matrix.python-version == 3.11
run: |
# see https://github.com/mapillary/mapillary_tools/issues/566
# TODO: move it to extras in setup.py
python3 -m pip install pysocks
./script/build_bootloader.ps1
./script/build_win.ps1
# Could run full integration tests with the binary (it might be slow)
cp ./dist/win/mapillary_tools.exe mapillary_tools_WINDOWS_VERY_HARD_TO_FIND_YOU_IN_ANOTHER_DIR_SO_I_MOVE_YOU_HERE.exe
pytest tests/integration
env:
MAPILLARY_TOOLS_EXECUTABLE: mapillary_tools_WINDOWS_VERY_HARD_TO_FIND_YOU_IN_ANOTHER_DIR_SO_I_MOVE_YOU_HERE.exe
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && matrix.python-version == 3.11
with:
draft: true
generate_release_notes: true
fail_on_unmatched_files: false
files: |
./dist/releases/*