Skip to content

Commit 0a974a9

Browse files
authored
Merge branch 'main' into chore/format-and-style
2 parents c228038 + f56248e commit 0a974a9

20 files changed

Lines changed: 3582 additions & 2558 deletions

File tree

.github/linters/.isort.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[settings]
2+
line_length=120

.github/linters/.yaml-lint.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extends: default
2+
3+
rules:
4+
brackets:
5+
max-spaces-inside: 1
6+
comments-indentation: disable
7+
document-start: disable
8+
line-length: disable
9+
truthy: disable

.github/workflows/check-style.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Style Check
2+
3+
on:
4+
workflow_call:
5+
6+
concurrency:
7+
group: style-${{ github.head_ref || github.run_id }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
checks: write
12+
statuses: write
13+
contents: read
14+
15+
jobs:
16+
python-style:
17+
name: Python Style
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v6
23+
with:
24+
persist-credentials: false
25+
26+
- name: Check changed files
27+
id: changed-files
28+
uses: tj-actions/changed-files@v47
29+
with:
30+
files: |
31+
*
32+
.github/workflows/style.yml
33+
34+
- name: Setup UV and Python
35+
if: steps.changed-files.outputs.any_changed == 'true'
36+
uses: astral-sh/setup-uv@v7
37+
with:
38+
enable-cache: false
39+
python-version: "3.10"
40+
cache-dependency-glob: uv.lock
41+
42+
- name: Install dependencies
43+
if: steps.changed-files.outputs.any_changed == 'true'
44+
run: uv sync --dev --frozen
45+
46+
- name: Run Ruff Checks
47+
if: steps.changed-files.outputs.any_changed == 'true'
48+
run: uv run --dev ruff check

.github/workflows/main-ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Main CI Pipeline
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
push:
7+
branches: ["main"]
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
checks: write
13+
statuses: write
14+
15+
concurrency:
16+
group: main-ci-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
check-changes:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
code_changes: ${{ steps.changes.outputs.code_changes }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v6
27+
with:
28+
persist-credentials: false
29+
fetch-depth: 0
30+
- name: Check for file changes
31+
uses: dorny/paths-filter@v3
32+
id: changes
33+
with:
34+
base: ${{ github.base_ref || github.ref_name }}
35+
filters: |
36+
code_changes:
37+
- '*'
38+
- '**/*'
39+
# run-tests:
40+
# name: Run Tests
41+
# needs: check-changes
42+
# if: needs.check-changes.outputs.code_changes == 'true'
43+
# uses: ./.github/workflows/run-tests.yml
44+
45+
check-style:
46+
name: Style Check
47+
uses: ./.github/workflows/check-style.yml

.github/workflows/run-tests.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Run Tests
2+
3+
on:
4+
workflow_call:
5+
6+
concurrency:
7+
group: api-tests-${{ github.head_ref || github.run_id }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
pytest:
12+
name: Run All python tests
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
shell: bash
17+
strategy:
18+
matrix:
19+
python-version:
20+
- "3.10"
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v6
25+
with:
26+
persist-credentials: false
27+
28+
- name: Install system dependencies
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y cmake portaudio19-dev python3-pyaudio libgl1-mesa-dev libglu1-mesa-dev
32+
33+
- name: Setup UV and Python
34+
uses: astral-sh/setup-uv@v7
35+
with:
36+
enable-cache: true
37+
python-version: ${{ matrix.python-version }}
38+
cache-dependency-glob: uv.lock
39+
40+
- name: Check UV lockfile
41+
run: uv lock --check
42+
43+
- name: Install dependencies
44+
run: uv sync --dev --all-extras --frozen
45+
46+
- name: Run Tests
47+
env:
48+
DEBUG: true
49+
run: |
50+
uv run --dev pytest

examples/moss_agent.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ def run_moss_agent(container: Container):
7272
description="你的视觉通道, 通过这个通道你可以使用摄像头看见",
7373
address="tcp://localhost:5557",
7474
),
75-
# todo: 暂时未实装, 预计实装它.
76-
# "no_ppt": ZMQProxyConfig(
77-
# script="no_ppt_channel.py",
78-
# description="",
79-
# address="tcp://localhost:5558",
80-
# )
75+
"slide": ZMQProxyConfig(
76+
script="slide_app.py",
77+
description="可以打开你的slide studio gui,通过这个通道你可以呈现并讲述一个slide主题",
78+
),
8179
},
8280
),
8381
logger=logger,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sock
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
from os.path import join, dirname
3+
4+
from PyQt6.QtWidgets import QApplication
5+
from ghoshell_common.contracts import Workspace
6+
7+
from ghoshell_moss.transports.zmq_channel import ZMQChannelProvider
8+
from ghoshell_moss_contrib.channels.slide_studio import SlideStudio, SlideAssets
9+
from ghoshell_moss_contrib.example_ws import workspace_container
10+
11+
current_dir = dirname(__file__)
12+
workspace_dir = join(dirname(current_dir), ".workspace")
13+
14+
15+
if __name__ == "__main__":
16+
with workspace_container(workspace_dir) as _container:
17+
_app = QApplication(sys.argv)
18+
ws = _container.force_fetch(Workspace)
19+
studio_storage = ws.assets().sub_storage("slide_studio")
20+
studio = SlideStudio(SlideAssets(studio_storage), _container)
21+
provider = ZMQChannelProvider(
22+
address=f"ipc://{__file__}.sock",
23+
container=_container,
24+
)
25+
# Pyqt6 will block main process, so provider must run in thread.
26+
provider.run_in_thread(studio.as_channel())
27+
# Default show player viewer window.(will not be default soon)
28+
studio.player.viewer.show()
29+
sys.exit(_app.exec())

examples/scripts/__init__.py

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import sys
2+
3+
from PyQt6.QtWidgets import QApplication
4+
5+
from ghoshell_moss_contrib.gui.slide_studio_creator import PPTXConverterWindow
6+
from ghoshell_moss_contrib.example_ws import workspace_container
7+
from ghoshell_common.contracts import Workspace
8+
9+
10+
if __name__ == "__main__":
11+
import pathlib
12+
CURRENT_DIR = pathlib.Path(__file__).parent
13+
WORKSPACE_DIR = CURRENT_DIR.parent.joinpath(".workspace").absolute()
14+
with workspace_container(WORKSPACE_DIR) as _container:
15+
ws = _container.force_fetch(Workspace)
16+
storage = ws.assets().sub_storage("slide_studio")
17+
app = QApplication(sys.argv)
18+
window = PPTXConverterWindow(storage)
19+
window.show()
20+
sys.exit(app.exec())

0 commit comments

Comments
 (0)