.github: Add Action to run pytest #534
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check and PyPi Upload | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- '*' | |
jobs: | |
pytest: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] # [macos-latest, ubuntu-latest, windows-latest] | |
python: ['3.9', '3.x'] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- run: pip install --upgrade pip | |
- run: pip install -r requirements.txt -r requirements-dev.txt -r requirements-test.txt | |
- run: pytest | |
ubuntu22: | |
name: Ubuntu 22.04 x86_64 | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
tags: true | |
fetch-depth: 0 | |
- name: Install pip | |
run: sudo apt-get install -y python3-pip | |
- name: Check style | |
run: | | |
python3 -m pip install pycodestyle | |
export PATH=$PATH:$HOME/.local/bin | |
pycodestyle examples/* | |
- name: Install prerequisites | |
run: | | |
python3 -m pip install -r requirements.txt -r requirements-dev.txt -r requirements-docs.txt | |
python3 -m pip install auditwheel twine | |
- name: Create wheel | |
run: | | |
python3 setup.py bdist_wheel | |
mkdir wheelhouse | |
export PATH=$PATH:$HOME/.local/bin | |
auditwheel repair --plat manylinux2014_x86_64 dist/*.whl | |
- name: Check the artifacts | |
run: | | |
ls -lh "wheelhouse/" | |
- name: Create docs | |
run: | | |
export PATH=$PATH:$HOME/.local/bin | |
make -C mavsdk html | |
- name: Upload to PyPi | |
env: | |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
TWINE_NON_INTERACTIVE: 1 | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
export PATH=$PATH:$HOME/.local/bin | |
twine upload wheelhouse/*.whl | |
- name: Upload docs | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
export PATH=$PATH:$HOME/.local/bin | |
other/tools/upload_docs.sh | |
ubuntu22-other: | |
name: Ubuntu 22.04 ${{ matrix.arch }} | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
include: | |
- arch: armv6l | |
pypi_arch: linux_armv6l | |
- arch: armv7l | |
pypi_arch: linux_armv7l | |
- arch: aarch64 | |
pypi_arch: manylinux2014_aarch64 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
tags: true | |
fetch-depth: 0 | |
- name: Install pip | |
run: sudo apt-get install -y python3-pip | |
- name: Install prerequisites | |
run: | | |
python3 -m pip install -r requirements.txt -r requirements-dev.txt | |
python3 -m pip install twine | |
- name: Create wheel | |
run: | | |
export MAVSDK_SERVER_ARCH=${{ matrix.arch }} | |
python3 setup.py bdist_wheel | |
ls dist/*any.whl | sed -e 'p;s/any/${{ matrix.pypi_arch }}/' | xargs -n2 mv | |
- name: Check the artifacts | |
run: | | |
ls -lh "dist/" | |
- name: Upload to PyPi | |
env: | |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
TWINE_NON_INTERACTIVE: 1 | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
export PATH=$PATH:$HOME/.local/bin | |
twine upload dist/*.whl | |
macOS: | |
name: macOS ${{ matrix.arch }} | |
runs-on: ${{ matrix.runs_on }} | |
strategy: | |
matrix: | |
include: | |
- arch: x64 | |
wheel_arch: 10_9_x86_64 | |
runs_on: macos-13 | |
- arch: arm64 | |
wheel_arch: 11_0_arm64 | |
runs_on: macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
tags: true | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Install prerequisites | |
run: | | |
python -m pip install -r requirements.txt | |
python -m pip install twine wheel | |
python -m pip install --user delocate | |
- name: Create wheel | |
run: | | |
python setup.py bdist_wheel | |
export PATH="$(python -m site --user-base)/bin:$PATH" | |
delocate-wheel -w wheelhouse -v dist/*.whl | |
ls wheelhouse/*any.whl | sed -e 'p;s/any/macosx_${{ matrix.wheel_arch }}/' | xargs -n2 mv | |
- name: Check the artifacts | |
run: | | |
ls -lh "wheelhouse/" | |
- name: Upload to PyPi | |
env: | |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
TWINE_NON_INTERACTIVE: 1 | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
export PATH=$PATH:$HOME/.local/bin | |
twine upload wheelhouse/*.whl | |
Windows: | |
name: Windows (${{ matrix.arch }}) | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
include: | |
- arch: x86 | |
wheel_arch: win32 | |
- arch: x64 | |
wheel_arch: win_amd64 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
tags: true | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
architecture: ${{ matrix.arch }} | |
- name: Install prerequisites | |
run: | | |
python3 -m pip install -r requirements.txt -r requirements-dev.txt | |
python3 -m pip install twine wheel | |
- name: Create wheel | |
run: | | |
python3 setup.py bdist_wheel | |
Dir "dist/" | rename-item -NewName {$_.name -replace '-any.whl','-${{ matrix.wheel_arch }}.whl'} | |
- name: Check the artifacts | |
run: | | |
ls "dist/" | |
- name: Upload to PyPi | |
env: | |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
TWINE_NON_INTERACTIVE: 1 | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
twine upload dist/*.whl |