Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change build to use poetry #606

Merged
merged 8 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,29 @@ jobs:
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Python 3
uses: actions/setup-python@v1
uses: actions/setup-python@v5
- name: Uninstall meshtastic
run: |
pip3 uninstall meshtastic
pip3 uninstall -y meshtastic
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install poetry
- name: Install meshtastic from local
run: |
pip3 install .
which meshtastic
meshtastic --version
poetry install
poetry run meshtastic --version
- name: Run pylint
run: pylint meshtastic examples/ --ignore-patterns ".*_pb2.pyi?$"
run: poetry run pylint meshtastic examples/ --ignore-patterns ".*_pb2.pyi?$"
- name: Check types with mypy
run: mypy meshtastic/
run: poetry run mypy meshtastic/
- name: Run tests with pytest
run: pytest --cov=meshtastic
run: poetry run pytest --cov=meshtastic
- name: Generate coverage report
run: |
pytest --cov=meshtastic --cov-report=xml
poetry run pytest --cov=meshtastic --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand All @@ -62,11 +61,12 @@ jobs:
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Python 3
uses: actions/setup-python@v1
uses: actions/setup-python@v5
- name: Install meshtastic from local
run: |
pip3 install .
which meshtastic
meshtastic --version
python -m pip install --upgrade pip
pip3 install poetry
poetry install
poetry run meshtastic --version
69 changes: 29 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,36 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip3 install poetry

- name: Bump version
run: >-
bin/bump_version.py
poetry version patch

- name: Commit updated version.py
- name: Commit updated version.
id: commit_updated
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add setup.py
git add pyproject.toml
git commit -m "bump version" && git push || echo "No changes to commit"
git log -n 1 --pretty=format:"%H" | tail -n 1 | awk '{print "::set-output name=sha::"$0}'

- name: Get version
id: get_version
run: >-
bin/show_version.py
poetry version

- name: Create GitHub release
uses: actions/create-release@v1
Expand All @@ -47,26 +57,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install pypa/build
run: >-
python -m
pip install
build
--user

- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
poetry build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
Expand All @@ -79,14 +72,14 @@ jobs:
# needs: release_create
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# uses: actions/checkout@v4
# with:
# ref: ${{ needs.release_create.outputs.new_sha }}

# - name: Set up Python 3.9
# uses: actions/setup-python@v2
# uses: actions/setup-python@v5
# with:
# python-version: 3.9
# python-version: "3.9"

# - name: Setup code signing
# env:
Expand Down Expand Up @@ -125,21 +118,19 @@ jobs:
needs: release_create
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ needs.release_create.outputs.new_sha }}

- name: Set up Python 3.9
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.9"

- name: Build
run: |
pip install pyinstaller
pip install -r requirements.txt
pip install .
pyinstaller -F -n meshtastic --collect-all meshtastic meshtastic/__main__.py
pip install poetry
bin/build-bin.sh

- name: Add ubuntu to release
uses: actions/upload-release-asset@v1
Expand All @@ -166,21 +157,19 @@ jobs:
needs: release_create
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ needs.release_create.outputs.new_sha }}

- name: Set up Python 3.9
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.9"

- name: Build
run: |
pip install pyinstaller
pip install -r requirements.txt
pip install .
pyinstaller -F -n meshtastic --collect-all meshtastic meshtastic/__main__.py
pip install poetry
bin/build-bin.sh

- name: Add windows to release
uses: actions/upload-release-asset@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_protobufs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: true

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ __pycache__
examples/__pycache__
meshtastic.spec
.hypothesis/
coverage.xml
9 changes: 9 additions & 0 deletions bin/build-bin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

echo Building ubuntu binary
poetry install
source $(poetry env info --path)/bin/activate
pyinstaller -F -n meshtastic --collect-all meshtastic meshtastic/__main__.py

30 changes: 0 additions & 30 deletions bin/bump_version.py

This file was deleted.

20 changes: 12 additions & 8 deletions bin/prerelease-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ set -e
# You may consider running: "pytest -m smoke1" instead of this test.

echo "Running (crude) prerelease tests to verify sanity"

# Use the python environment created by poetry
source $(poetry env info --path)/bin/activate

echo running hello
python3 tests/hello_world.py
# bin/run.sh --help
# meshtastic --help
echo toggling router
bin/run.sh --set is_router true
bin/run.sh --set is_router false
meshtastic --set is_router true
meshtastic --set is_router false
# TODO: This does not seem to work.
echo setting channel
bin/run.sh --seturl "https://www.meshtastic.org/c/#GAMiENTxuzogKQdZ8Lz_q89Oab8qB0RlZmF1bHQ="
meshtastic --seturl "https://www.meshtastic.org/c/#GAMiENTxuzogKQdZ8Lz_q89Oab8qB0RlZmF1bHQ="
echo setting owner
bin/run.sh --set-owner "Test Build"
meshtastic --set-owner "Test Build"
echo setting position
bin/run.sh --setlat 32.7767 --setlon -96.7970 --setalt 1337
meshtastic --setlat 32.7767 --setlon -96.7970 --setalt 1337
echo dumping info
bin/run.sh --info
meshtastic run meshtastic --info
echo sending closing message
bin/run.sh --sendtext "Sanity complete"
meshtastic --sendtext "Sanity complete"
11 changes: 11 additions & 0 deletions bin/run-ci-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# This script lets you run github ci actions locally
# You need to have act installed. You can get it at https://nektosact.com/

# by default it simulates a push event
# other useful options
# -j build-and-publish-ubuntu

# also: we only run one of the 4 matrix tests, because otherwise it absolutely hammers the CPU (so many containers and threads)
act -P ubuntu-latest=-self-hosted --matrix "python-version:3.8" "$@"
2 changes: 0 additions & 2 deletions bin/run.sh

This file was deleted.

20 changes: 0 additions & 20 deletions bin/show_version.py

This file was deleted.

6 changes: 2 additions & 4 deletions bin/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ set -e

bin/regen-docs.sh
pandoc --from=markdown --to=rst --output=README README.md
python3 setup.py sdist bdist_wheel
python3 -m twine check dist/*
# test the upload
python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*

poetry publish -r test-pypi --build
echo "view the upload at https://test.pypi.org/ it it looks good upload for real"
7 changes: 5 additions & 2 deletions bin/upload-release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
rm dist/*
set -e

python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*
poetry build
poetry run pytest
poetry publish
#python3 setup.py sdist bdist_wheel
#python3 -m twine upload dist/*
Loading
Loading