Skip to content

Commit

Permalink
Merge pull request #236 from FabienArcellier/15-github-action-enforce…
Browse files Browse the repository at this point in the history
…-pr-continuous-integration-rules

github action enforce pr continuous integration rules
  • Loading branch information
ramedina86 authored Feb 12, 2024
2 parents 45d0ee0 + eca6ca3 commit faf8b55
Show file tree
Hide file tree
Showing 11 changed files with 268 additions and 3 deletions.
13 changes: 13 additions & 0 deletions .alfred.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[alfred]
# name = "" # name of a subproject, use the name of the directory if not set
# description = "" # inline documentation for a sub project
# subprojects = []

# [alfred.project]
# command = [ "alfred/*.py" ]
# python_path_project_root = true
# python_path_extends = []
# venv = "src/.."

# more info about project manifest
# into https://alfred-cli.readthedocs.io/en/latest/project.html#setting-up-a-project-with-alfred-toml
37 changes: 37 additions & 0 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ci-macos

on: [ push, pull_request ]

jobs:
build:
runs-on: macos-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: update package manager & install python3 environment
run: |
sudo pip install poetry
poetry install --with build
- name: install npm environment
run: |
cd ui
npm install
- name: run continuous integration pipeline
run: |
poetry run alfred ci
37 changes: 37 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ci-windows

on: [ push, pull_request ]

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: update package manager & install python3 environment
run: |
pip install poetry
poetry install --with build
- name: install npm environment
run: |
cd ui
npm install
- name: run continuous integration pipeline
run: |
poetry run alfred ci
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ci

on: [ push, pull_request ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: update package manager & install python3 environment
run: |
sudo pip install poetry
poetry install --with build
- name: install npm environment
run: |
cd ui
npm install
- name: run continuous integration pipeline
run: |
poetry run alfred ci
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## What is Streamsync?

[![PyPi](https://img.shields.io/pypi/v/streamsync.svg?label=Version)](https://pypi.org/project/streamsync/)
[![CI](https://github.com/streamsync-cloud/streamsync/actions/workflows/ci.yml/badge.svg)](https://github.com/streamsync-cloud/streamsync/actions/workflows/ci.yml)
[![Discord](https://img.shields.io/badge/discord-streamsync-sn677E3Pd3?logo=discord&logoColor=white)](https://discord.gg/sn677E3Pd3)
[![License](https://img.shields.io/pypi/l/streamsync)](LICENSE)

Streamsync is an open-source framework for creating data apps. Build user interfaces using a visual editor; write the backend code in Python.

![Streamsync Builder screenshot](https://raw.githubusercontent.com/streamsync-cloud/streamsync/master/docs/docs/public/sc1.png "Streamsync Builder screenshot")
Expand Down
33 changes: 33 additions & 0 deletions alfred/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os.path
import shutil

import alfred


@alfred.command("build", help="build apps package for pypi")
@alfred.option("--ignore-ci", is_flag=True, help="ignore continuous integration pipeline")
def build(ignore_ci: bool = False):
if not ignore_ci:
alfred.invoke_command("ci")
else:
alfred.invoke_command("npm.build")

alfred.invoke_command("build.app_provisionning")
alfred.invoke_command("build.poetry")

@alfred.command("build.app_provisionning", help="update app templates using ./apps", hidden=True)
def build_app_provisionning():
if os.path.isdir('src/streamsync/app_templates'):
shutil.rmtree('src/streamsync/app_templates')

shutil.copytree( 'apps/default', 'src/streamsync/app_templates/default')
shutil.copytree( 'apps/hello', 'src/streamsync/app_templates/hello')

@alfred.command("build.poetry", help="build python packages with poetry", hidden=True)
def build_poetry():
removed_directories = ['dist', 'build']
for directory in removed_directories:
if os.path.isdir(directory):
shutil.rmtree(directory)

alfred.run("poetry build")
21 changes: 21 additions & 0 deletions alfred/ci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os

import alfred


@alfred.command("ci", help="continuous integration pipeline")
def ci():
alfred.invoke_command("ci.mypy")
alfred.invoke_command("ci.pytest")
alfred.invoke_command("npm.build")


@alfred.command("ci.mypy", help="typing checking with mypy on ./src/streamsync")
def ci_mypy():
alfred.run("mypy ./src/streamsync --exclude app_templates/*")


@alfred.command("ci.pytest", help="run pytest on ./tests")
def ci_test():
os.chdir("tests")
alfred.run("pytest")
12 changes: 12 additions & 0 deletions alfred/npm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import alfred
import os

@alfred.command("npm.build", help="build ui code")
def npm_build():
os.chdir("ui")
alfred.run("npm run build")

@alfred.command("npm.build_custom_components", help="build custom components")
def ui_build_custom():
os.chdir("ui")
alfred.run("npm run custom.build")
69 changes: 68 additions & 1 deletion poetry.lock

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

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ repository = "https://www.github.com/streamsync-cloud/streamsync"
documentation = "https://www.streamsync.cloud/getting-started.html"
keywords = ["data apps", "gui", "ui"]
classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 4 - Beta"
]
packages = [
Expand Down Expand Up @@ -45,6 +49,7 @@ pytest-asyncio = ">= 0.23.4, < 1"
pytest = ">= 7.0.0, < 8"
altair = ">= 5.2.0, < 6"
httpx = ">=0.26.0, < 1"
alfred-cli = "^2.2.7"

[tool.poetry.extras]
ds = ["pandas", "pyarrow", "plotly"]
Expand Down
7 changes: 5 additions & 2 deletions src/streamsync/app_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import logging.handlers
from types import ModuleType
import json
from typing import Any, Callable, Dict, List, Optional
from typing import Any, Callable, Dict, List, Optional, cast

from watchdog.observers.polling import PollingObserver

Expand Down Expand Up @@ -748,7 +748,10 @@ def _start_app_process(self) -> None:
raise ValueError(
"Cannot start app process. Components haven't been set.")
self.is_app_process_server_ready.clear()
self.client_conn, self.server_conn = multiprocessing.Pipe(duplex=True)
client_conn, server_conn = multiprocessing.Pipe(duplex=True)
self.client_conn = cast(multiprocessing.connection.Connection, client_conn) # for mypy type checking on windows
self.server_conn = cast(multiprocessing.connection.Connection, server_conn) # for mypy type checking on windows

self.app_process = AppProcess(
client_conn=self.client_conn,
server_conn=self.server_conn,
Expand Down

0 comments on commit faf8b55

Please sign in to comment.