Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ indent_size = 2
[*.md]
trim_trailing_whitespace = false

# Painel Vue (panel/): convenção do ecossistema JavaScript.
[panel/**.{ts,mts,mjs,js,vue,css,html}]
indent_size = 2

[*.cs]
# Namespaces and usings
csharp_style_namespace_declarations = file_scoped:warning
Expand Down
59 changes: 57 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ jobs:
# The integration tests build the psrunner wheel and create real Python environments with uv.
- uses: astral-sh/setup-uv@v10.3.0

# The Release build embeds the Vue panel (npm ci + npm run build in panel/; D-155).
- uses: actions/setup-node@v7
with:
node-version-file: panel/.nvmrc
cache: npm
cache-dependency-path: panel/package-lock.json

- name: Restore
run: dotnet restore

Expand All @@ -46,12 +53,25 @@ jobs:
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b fonts-dejavu-core

# The persistence, queue and worker tests start PostgreSQL 16, RabbitMQ 3.13 and Mailpit with Testcontainers
# (Docker); GitHub's Windows runners cannot run Linux containers, so Windows runs the Core tests only.
# The panel E2E tests drive Chromium with Playwright (spec 008; D-149, D-156).
- name: Install Chromium
if: runner.os == 'Linux'
run: pwsh tests/PythonScriptRunner.Panel.E2E.Tests/bin/Release/net10.0/playwright.ps1 install --with-deps chromium

# The persistence, queue, worker, dashboard and panel tests start PostgreSQL 16, RabbitMQ 3.13 and Mailpit with
# Testcontainers (Docker); GitHub's Windows runners cannot run Linux containers, so Windows runs the Core tests only.
- name: Test
if: runner.os == 'Linux'
run: dotnet test --no-build --configuration Release

- name: Upload Playwright traces
if: failure() && runner.os == 'Linux'
uses: actions/upload-artifact@v7
with:
name: playwright-traces
path: tests/PythonScriptRunner.Panel.E2E.Tests/bin/Release/net10.0/TestResults/traces/
if-no-files-found: ignore

- name: Test (Core)
if: runner.os == 'Windows'
run: dotnet test --no-build --configuration Release --project tests/PythonScriptRunner.Core.Tests
Expand All @@ -69,6 +89,41 @@ jobs:
- name: Verify formatting
run: dotnet format --verify-no-changes

panel:
name: Panel (Vue)
runs-on: ubuntu-latest
defaults:
run:
working-directory: panel
steps:
- uses: actions/checkout@v7

- uses: actions/setup-node@v7
with:
node-version-file: panel/.nvmrc
cache: npm
cache-dependency-path: panel/package-lock.json

- name: Install
run: npm ci --no-audit --no-fund

- name: Lint
run: npm run lint

- name: Type check
run: npm run typecheck

# The TypeScript types are generated from the versioned OpenAPI snapshot of the Dashboard tests (D-137).
- name: API types up to date
run: npm run api:check

- name: Test
run: npm test

# vue-tsc + vite build + the initial bundle budget (≤ 500 KB gzip; spec 008).
- name: Build
run: npm run build

python-sdk:
name: psrunner (${{ matrix.os }}, Python ${{ matrix.python }})
strategy:
Expand Down
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Cronos" Version="0.13.0" />
<PackageVersion Include="Deque.AxeCore.Playwright" Version="4.13.0" />
<PackageVersion Include="JsonSchema.Net" Version="9.4.1" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.13" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.13" />
Expand All @@ -25,6 +26,7 @@
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.13" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.13" />
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="10.11.0" />
<PackageVersion Include="Microsoft.Playwright" Version="1.63.0" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.3" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.20.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.20.1" />
Expand Down
1 change: 1 addition & 0 deletions PythonScriptRunner.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Project Path="tests/PythonScriptRunner.Core.Tests/PythonScriptRunner.Core.Tests.csproj" />
<Project Path="tests/PythonScriptRunner.Dashboard.Tests/PythonScriptRunner.Dashboard.Tests.csproj" />
<Project Path="tests/PythonScriptRunner.EntityFrameworkCore.Tests/PythonScriptRunner.EntityFrameworkCore.Tests.csproj" />
<Project Path="tests/PythonScriptRunner.Panel.E2E.Tests/PythonScriptRunner.Panel.E2E.Tests.csproj" />
<Project Path="tests/PythonScriptRunner.RabbitMQ.Tests/PythonScriptRunner.RabbitMQ.Tests.csproj" />
<Project Path="tests/PythonScriptRunner.Worker.Tests/PythonScriptRunner.Worker.Tests.csproj" />
</Folder>
Expand Down
39 changes: 35 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ cron e painel Vue opcional.

> Projeto em desenvolvimento. Esta versão entrega o **Core Runner** (execução síncrona de Stages e de
> trilhas), o SDK Python **`psrunner`**, a **persistência em PostgreSQL** (catálogo versionado e histórico), a
> **execução assíncrona** com RabbitMQ, worker e agendamento cron e o **painel embutível** (API, tempo real e acesso
> configurável; a interface Vue chega numa próxima versão).
> **execução assíncrona** com RabbitMQ, worker e agendamento cron e o **painel embutível** (interface Vue, API, tempo
> real e acesso configurável).

## Como funciona

Expand Down Expand Up @@ -159,7 +159,12 @@ O host `hosts/PythonScriptRunner.WorkerHost` é um worker pronto, configurado po
## Painel (Dashboard)

Com `PythonScriptRunner.Dashboard`, o painel é embutido na sua aplicação, no estilo do Hangfire: API interna, atualizações
em tempo real (SignalR) e a interface servida no prefixo escolhido. Sem `MapPythonScriptRunnerDashboard` não existe painel.
em tempo real (SignalR) e a interface Vue servida no prefixo escolhido. Sem `MapPythonScriptRunnerDashboard` não existe painel.

A interface (em pt-BR, tema claro/escuro) cobre a visão geral, Etapas (editor Monaco com construtor de campos, testar
pela fila e publicar), Trilhas (editor visual com *handles* tipados, ou lista editável, testar e publicar), execuções ao
vivo (fluxo por status, logs, arquivos, linha do tempo, cancelar e reprocessar), agendamentos com prévia do cron,
auditoria e administração. Ela vai dentro do pacote: não há nada para hospedar à parte.

```csharp
builder.Services
Expand Down Expand Up @@ -222,6 +227,7 @@ O host `hosts/PythonScriptRunner.DashboardHost` é um painel pronto: login fixo
- .NET 10 SDK
- [uv](https://docs.astral.sh/uv/) no PATH (cria e cacheia um ambiente Python por conjunto de dependências)
- PostgreSQL 16+ apenas para o pacote de persistência e RabbitMQ 3.13+ para a fila (os testes usam Docker/Testcontainers)
- Node.js 24 só para compilar em Release ou empacotar o `PythonScriptRunner.Dashboard` (o build embute o painel de `panel/`)

## Estrutura

Expand All @@ -233,11 +239,12 @@ O host `hosts/PythonScriptRunner.DashboardHost` é um painel pronto: login fixo
| `src/PythonScriptRunner.RabbitMQ` | topologia, relay do outbox, `IRunQueue`, comando público, eventos e assinaturas |
| `src/PythonScriptRunner.Worker` | execução dos passos enfileirados, *lease*, retry, cancelamento, cron |
| `src/PythonScriptRunner.Dashboard` | painel embutível: API interna, hub SignalR, modos de acesso (login fixo, filtro, host, local) |
| `panel` | interface do painel: Vue 3, Vuetify 4, Vue Flow e Monaco (TypeScript, Vite, Vitest) |
| `src/PythonScriptRunner.Tool` | dotnet tool `psr` (`psr hash-password`) |
| `hosts` | `WorkerHost`, `DashboardHost` e `ServiceDefaults` (Serilog, OpenTelemetry, health checks) |
| `python/psrunner` | SDK Python (`@stage`, `Context`, `File`, `StageError`, `psrunner.testing`, CLI) |
| `schemas` | JSON Schemas do `stage.json`, do `*.pipeline.json` e das mensagens públicas |
| `tests` | testes .NET (unitários e de integração com Python real) e fixtures de trilha |
| `tests` | testes .NET (unitários, de integração com Python real e E2E do painel com Playwright) e fixtures de trilha |

## Desenvolvimento

Expand All @@ -254,6 +261,30 @@ uv sync
uv run pytest
```

O painel fica em `panel/` (Node 24). Os builds em Debug embutem uma página provisória; em Release (ou com
`-p:PsrBuildPanel=true`) o MSBuild roda `npm ci` e `npm run build` e embute `panel/dist`.

```bash
cd panel
npm ci
npm run dev # Vite em http://localhost:5173/; /api e /hubs vão para o DashboardHost em PSR_DASHBOARD_URL (padrão http://localhost:5080, prefixo /psr)
npm test # Vitest
npm run lint # ESLint + Prettier
npm run build # checagem de tipos, build e orçamento do bundle inicial (≤ 500 KB gzip)
npm run api # regera src/api/schema.d.ts a partir do snapshot OpenAPI
```

Os testes E2E do painel sobem o `DashboardHost` com 4 usuários de login fixo, um worker, PostgreSQL e RabbitMQ e dirigem
o Chromium com Playwright (precisam de Docker e do painel embutido):

```bash
dotnet build tests/PythonScriptRunner.Panel.E2E.Tests -p:PsrBuildPanel=true
dotnet test --project tests/PythonScriptRunner.Panel.E2E.Tests --no-build # PSR_E2E_HEADED=1 mostra o navegador
```

Quando um teste falha, o *trace* do Playwright fica em `TestResults/traces` ao lado do assembly de testes
(`npx playwright show-trace <arquivo>.zip`).

O teste de desempenho do painel usa ~200 mil execuções; `PSR_PERF_RUNS_PER_DAY=50000` roda o volume médio completo (90 dias).
O documento OpenAPI do painel é comparado com `tests/PythonScriptRunner.Dashboard.Tests/Snapshots/openapi-v1.verified.json`;
depois de revisar uma mudança intencional, `PSR_ACCEPT_SNAPSHOTS=1` atualiza o snapshot.
Expand Down
2 changes: 2 additions & 0 deletions panel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
1 change: 1 addition & 0 deletions panel/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
4 changes: 4 additions & 0 deletions panel/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
node_modules
src/api/schema.d.ts
package-lock.json
7 changes: 7 additions & 0 deletions panel/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 130,
"endOfLine": "lf",
"tabWidth": 2
}
16 changes: 16 additions & 0 deletions panel/eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pluginVue from 'eslint-plugin-vue'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import prettier from 'eslint-config-prettier'

export default defineConfigWithVueTs(
{ ignores: ['dist/**', 'node_modules/**', 'src/api/schema.d.ts'] },
pluginVue.configs['flat/recommended'],
vueTsConfigs.recommended,
prettier,
{
rules: {
'vue/multi-word-component-names': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
},
},
)
14 changes: 14 additions & 0 deletions panel/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="pt-BR">
<head>
<base href="/" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<title>PythonScriptRunner</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
Loading
Loading