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

Feature/poetry: Add poetry build and publish process whenever a release is tagged #15

Merged
merged 24 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
343583d
feat: Update project to use poetry for build and wheel packaging
Apr 17, 2023
e82bb2a
Merge branch 'main' into feature/poetry
Apr 17, 2023
9e5c9d4
ci: Updated tests yaml to run pytests on a gamut of python versions
Apr 21, 2023
0b047a5
CI: Download and install pythonwheel artifact
Apr 21, 2023
7540eb3
CI: Update tests to install wheel and poetry dependencies
Apr 21, 2023
9b9683a
CI: Run dist wheel build for each version of python and test as well
Apr 21, 2023
53ebc67
CI: Disable interactive publish
Apr 21, 2023
0375667
test: Attempting to update CI
May 24, 2023
069c87c
test: Attempting to update CI
May 24, 2023
054923a
Merge branch 'main' into feature/poetry
May 24, 2023
0c64eec
fix: Update setup python in tests workflow
May 24, 2023
ca7aa7f
ci: Update tests workflow back to run gcovr and python tests
May 24, 2023
e77f5fc
fix: Fix pyproject to properly include pythonmonkey.so
May 24, 2023
8291aa9
ci: Update matrix to include 3.10 and 3.11
May 24, 2023
02f2fbf
fix: 3.11 is broken, removed from matrix
May 24, 2023
ead2fd6
fix: Update publish to match test build process
May 24, 2023
391fe61
ci: Make sure publish doesn't die if existing published version is al…
May 24, 2023
5e8ea67
Merge main into branch
May 25, 2023
390479e
ci: Merge test and publish yamls and only run publish on success and tag
May 29, 2023
737fe50
Merge branch 'main' into feature/poetry
May 29, 2023
8ca6c49
CI: Fix if statement for running poetry publish. Should only run on t…
May 29, 2023
3bfb967
Update .github/workflows/test-and-publish.yaml
Hamada-Distributed May 29, 2023
e091a73
CI: Run workflow only on main, pr's or tags
May 29, 2023
6f54c23
Merge branch 'feature/poetry' of github.com:Kings-Distributed-Systems…
May 29, 2023
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
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
name: 'Testing Suite'
name: 'Test and Publish Suite'

on:
push:
Hamada-Distributed marked this conversation as resolved.
Show resolved Hide resolved
branches:
- main
tags:
- '*'
workflow_call:
workflow_dispatch:
pull_request:

jobs:
test-suite:
test-and-publish:
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest' ] # , 'windows-latest', 'macos-latest' ]
python_version: [ '3.9', '3.10', '3.11' ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Setup Poetry
uses: snok/install-poetry@v1
- name: Setup cmake
run: |
sudo apt-get install -y cmake doxygen graphviz gcovr llvm python3-dev python3-pytest
pip install pytest
echo "Installing Dependencies"
sudo apt-get update -y
sudo apt-get install -y cmake doxygen graphviz gcovr llvm
echo "Installing python deps"
poetry install --no-root
echo "Installed Dependencies"
- name: Cache spidermonkey build
id: cache-spidermonkey
uses: actions/cache@v3
Expand All @@ -35,17 +44,28 @@ jobs:
key: ${{ runner.os }}-spidermonkey
- name: Build-Library
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
run: ./setup.sh && ./build_script.sh
run: ./setup.sh #&& ./build_script.sh
- name: Build wheel
run: |
echo $(poetry run python --version)
poetry build --format=wheel
ls -lah ./dist/
- name: google-tests
run: |
cd build
make && make tests
gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage.xml
cd tests && ctest
cd ../src
python -m pytest ../../tests/python
cd ../../
poetry run python -m pip install ./dist/*.whl
poetry run python -m pytest tests/python
- name: google-tests-artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}-${{ github.run_id }}-${{ github.sha }}
path: ./build/coverage.xml
- name: Buid and Publish package
if: ${{ success() && github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
run: |
echo $(poetry run python --version)
poetry publish --no-interaction --skip-existing --build --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ tests/__pycache__/*
tests/python/__pycache__/*
Testing/Temporary
_spidermonkey_install
__pycache__
dist
*.so
25 changes: 25 additions & 0 deletions build.py
Xmader marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import subprocess
import os, sys

dir_path = os.path.dirname( os.path.realpath(__file__) )


def execute(cmd: str):
popen = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT,
shell = True, text = True )
for stdout_line in iter(popen.stdout.readline, ""):
sys.stdout.write(stdout_line)
sys.stdout.flush()

popen.stdout.close()
return_code = popen.wait()
if return_code:
raise subprocess.CalledProcessError(return_code, cmd)

def build():
build_script_sh = os.path.join( dir_path, 'build_script.sh' )
execute(f"bash {build_script_sh}")
execute(f"cp ./build/src/pythonmonkey.so ./python/pythonmonkey/pythonmonkey.so")
Xmader marked this conversation as resolved.
Show resolved Hide resolved

if __name__ == "__main__":
build()
158 changes: 158 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.poetry]
name = "pythonmonkey"
version = "0.1.0"
description = ""
authors = ["Caleb Aikens <caleb@distributive.network>", "Tom Tang <xmader@distributive.network>"]
readme = "README.md"
packages = [
{ include = "pythonmonkey", from = "python" },
]
include = [ "python/pythonmonkey/pythonmonkey.so" ]
Xmader marked this conversation as resolved.
Show resolved Hide resolved


[tool.poetry.dependencies]
python = "^3.9"


[tool.poetry.build]
script = "build.py"
generate-setup-file = false


[tool.poetry.group.dev.dependencies]
pytest = "^7.3.1"
pip = "^23.1.2"
Xmader marked this conversation as resolved.
Show resolved Hide resolved
numpy = "^1.24.3"

[build-system]
requires = ["poetry-core>=1.0.0a9"]
build-backend = "poetry.core.masonry.api"

1 change: 1 addition & 0 deletions python/pythonmonkey/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .pythonmonkey import *
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/
echo "Installing dependencies"
sudo apt-get update --yes
sudo apt-get upgrade --yes
sudo apt-get install cmake python3-dev python3-pytest doxygen graphviz gcovr llvm g++ pkg-config m4 --yes
sudo apt-get install cmake doxygen graphviz gcovr llvm g++ pkg-config m4 --yes
sudo curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh -s -- -y #install rust compiler
echo "Done installing dependencies"

Expand Down