Compare commits

..

1 Commits

Author SHA1 Message Date
Gergő Jedlicska 61cfa388ba chore: add github workflows 2025-02-26 12:43:20 +01:00
4 changed files with 14 additions and 106 deletions
-56
View File
@@ -1,56 +0,0 @@
name: "Specklepy test and build"
on:
pull_request:
branches:
- "v3-dev"
push:
branches:
- "v3-dev"
jobs:
ci:
name: continuous-integration
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:
- uses: actions/checkout@v4
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install the project
run: uv sync --all-extras --dev
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit/
key: ${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: uv run pre-commit run --all-files
# - name: Run Speckle Server
# run: docker compose up -d
# - name: Run tests
# run: uv run pytest --cov --cov-report xml:reports/coverage.xml --junitxml=reports/test-results.xml
# - uses: codecov/codecov-action@v5
# if: matrix.python-version == 3.13
# with:
# fail_ci_if_error: true # optional (default = false)
# files: ./reports/test-results.xml # optional
# token: ${{ secrets.CODECOV_TOKEN }}
- name: Minimize uv cache
run: uv cache prune --ci
-33
View File
@@ -1,33 +0,0 @@
# Publish a release to PyPI.
name: "Publish to PyPI"
on:
workflow_run:
workflows: ["Specklepy test and build"]
branches: [v3-dev]
types:
- completed
jobs:
pypi-publish:
name: Upload to PyPI
runs-on: ubuntu-latest
environment:
name: testpypi
permissions:
# For PyPI's trusted publishing.
id-token: write
steps:
- name: "Install uv"
uses: astral-sh/setup-uv@v5
- uses: actions/checkout@v4
with:
# This is necessary so that we have the tags.
fetch-depth: 0
- name: "Build artifacts"
run: uv build
- name: Publish to PyPi
run: uv publish --index test
- name: Test package install
run: uv run --index test --with specklepy --no-project -- python -c "import specklepy"
+13 -16
View File
@@ -332,7 +332,7 @@ class AutomationContext:
def attach_error_to_objects(
self,
category: str,
objects: Union[Base, List[Base]],
object_ids: Union[str, List[str]],
message: Optional[str] = None,
metadata: Optional[Dict[str, Any]] = None,
visual_overrides: Optional[Dict[str, Any]] = None,
@@ -351,7 +351,7 @@ class AutomationContext:
self.attach_result_to_objects(
ObjectResultLevel.ERROR,
category,
objects,
object_ids,
message,
metadata,
visual_overrides,
@@ -360,7 +360,7 @@ class AutomationContext:
def attach_warning_to_objects(
self,
category: str,
objects: Union[Base, List[Base]],
object_ids: Union[str, List[str]],
message: Optional[str] = None,
metadata: Optional[Dict[str, Any]] = None,
visual_overrides: Optional[Dict[str, Any]] = None,
@@ -369,7 +369,7 @@ class AutomationContext:
self.attach_result_to_objects(
ObjectResultLevel.WARNING,
category,
objects,
object_ids,
message,
metadata,
visual_overrides,
@@ -378,7 +378,7 @@ class AutomationContext:
def attach_success_to_objects(
self,
category: str,
objects: Union[Base, List[Base]],
object_ids: Union[str, List[str]],
message: Optional[str] = None,
metadata: Optional[Dict[str, Any]] = None,
visual_overrides: Optional[Dict[str, Any]] = None,
@@ -387,7 +387,7 @@ class AutomationContext:
self.attach_result_to_objects(
ObjectResultLevel.SUCCESS,
category,
objects,
object_ids,
message,
metadata,
visual_overrides,
@@ -396,7 +396,7 @@ class AutomationContext:
def attach_info_to_objects(
self,
category: str,
objects: Union[Base, List[Base]],
object_ids: Union[str, List[str]],
message: Optional[str] = None,
metadata: Optional[Dict[str, Any]] = None,
visual_overrides: Optional[Dict[str, Any]] = None,
@@ -405,7 +405,7 @@ class AutomationContext:
self.attach_result_to_objects(
ObjectResultLevel.INFO,
category,
objects,
object_ids,
message,
metadata,
visual_overrides,
@@ -415,22 +415,19 @@ class AutomationContext:
self,
level: ObjectResultLevel,
category: str,
objects: Union[Base, List[Base]],
object_ids: Union[str, List[str]],
message: Optional[str] = None,
metadata: Optional[Dict[str, Any]] = None,
visual_overrides: Optional[Dict[str, Any]] = None,
) -> None:
if isinstance(objects, list):
if len(objects) < 1:
if isinstance(object_ids, list):
if len(object_ids) < 1:
raise ValueError(
f"Need atleast one object_id to report a(n) {level.value.upper()}"
)
id_list = [o.id for o in objects]
application_ids = [o.applicationId for o in objects]
id_list = object_ids
else:
id_list = [objects.id]
application_ids = [objects.applicationId]
metadata["applicationIds"] = application_ids
id_list = [object_ids]
print(
f"Created new {level.value.upper()}"
f" category: {category} caused by: {message}"
@@ -133,7 +133,7 @@ def automate_function(
raise ValueError("Cannot operate on objects without their id's.")
automation_context.attach_error_to_objects(
"Forbidden speckle_type",
version_root_object,
version_root_object.id,
"This project should not contain the type: "
f"{function_inputs.forbidden_speckle_type}",
)