Metadata-Version: 2.3
Name: tringa
Version: 0.2.0
Summary: A tool for querying test output across multiple CI builds on GitHub
Requires-Python: >=3.12
Requires-Dist: duckdb>=1.0.0
Requires-Dist: humanize>=4.10.0
Requires-Dist: ipython>=8.26.0
Requires-Dist: junitparser>=3.1.2
Requires-Dist: pandas>=2.2.2
Requires-Dist: pytest>=8.3.2
Requires-Dist: rich>=13.8.0
Requires-Dist: textual-dev>=1.6.1
Requires-Dist: textual-serve>=1.1.1
Requires-Dist: textual>=0.79.1
Requires-Dist: typer>=0.12.5
Requires-Dist: xdg-base-dirs>=6.0.1
Description-Content-Type: text/markdown

`tringa` is a tool for querying test output across multiple CI builds on GitHub.
It is in early development and not ready for use.

------------------------
- [Install](#install)
- [Example usage](#example-usage)
  - [TUI](#tui)
  - [SQL REPL](#sql-repl)
- [Required changes to GitHub Actions workflows](#required-changes-to-github-actions-workflows)
------------------------


### Install

Use [uv](https://docs.astral.sh/uv/):

```
$ uv tool install git+https://github.com/dandavison/tringa
```

And log in with [gh](https://cli.github.com/).
```
$ gh auth login
```

### Example usage

```
$ tringa --help
```

<img width="1295" alt="image" src="https://github.com/user-attachments/assets/218442ce-7109-47c2-8824-4f482e8e3923">

Some commands print to the terminal, some bring up a TUI, and some bring up a SQL REPL for interactive queries.
By default the database is `duckdb` and persists across invocations.
The REPL can be a traditional SQL REPL, or a Python session using the [DuckDB Python API](https://duckdb.org/docs/api/python/overview.html).

#### Repo overview

```
$ tringa repo show
```

<img width="1295" alt="image" src="https://github.com/user-attachments/assets/64092fb9-36d6-4b10-9889-ef0314570a36">


#### PR overview

```
$ tringa pr show
```

<img width="1295" alt="image" src="https://github.com/user-attachments/assets/2efbca87-d91f-4487-bb41-9b83f36961e8">



#### TUI

```
$ tringa pr tui
```

<img width="1295" alt="image" src="https://github.com/user-attachments/assets/765bd3f3-f333-4c23-8ecf-0326097469dd">

#### SQL REPL

The DB has one table, named `test`.

```
$ tringa pr repl
```

```
D select artifact, name from test
  where passed = false and skipped = false and repo = 'temporalio/cli';
┌───────────────────────────────────────────┬─────────────────────────────────────────────────────────┐
│               artifact                    │                          name                           │
│                  varchar                  │                         varchar                         │
├───────────────────────────────────────────┼─────────────────────────────────────────────────────────┤
│ junit-xml--10631569269--1--ubuntu-latest  │ TestSharedServerSuite/TestWorkflow_Update_Execute       │
│ junit-xml--10631569269--1--ubuntu-latest  │ TestSharedServerSuite/TestWorkflow_Update_Start         │
│ junit-xml--10631569269--1--ubuntu-latest  │ TestSharedServerSuite                                   │
│ junit-xml--10884926916--1--windows-latest │ TestServer_StartDev_ConcurrentStarts                    │
│ junit-xml--10885937402--1--ubuntu-arm     │ TestSharedServerSuite/TestActivity_Complete             │
│ junit-xml--10885937402--1--ubuntu-arm     │ TestSharedServerSuite/TestWorkflow_Reset_ReapplyExclude │
│ junit-xml--10885937402--1--ubuntu-arm     │ TestSharedServerSuite                                   │
└───────────────────────────────────────────┴─────────────────────────────────────────────────────────┘

D SELECT name, type FROM pragma_table_info('test');
┌─────────────────┬───────────┐
│      name       │   type    │
│     varchar     │  varchar  │
├─────────────────┼───────────┤
│ artifact        │ VARCHAR   │
│ repo            │ VARCHAR   │
│ branch          │ VARCHAR   │
│ run_id          │ VARCHAR   │
│ sha             │ VARCHAR   │
│ file            │ VARCHAR   │
│ suite           │ VARCHAR   │
│ suite_time      │ TIMESTAMP │
│ suite_duration  │ FLOAT     │
│ name            │ VARCHAR   │
│ classname       │ VARCHAR   │
│ duration        │ FLOAT     │
│ passed          │ BOOLEAN   │
│ skipped         │ BOOLEAN   │
│ flaky           │ BOOLEAN   │
│ message         │ VARCHAR   │
│ text            │ VARCHAR   │
├─────────────────┴───────────┤
│ 17 rows           2 columns │
└─────────────────────────────┘
```

### Required changes to GitHub Actions workflows

For `tringa` to find output from a CI workflow run, at least one job in the run must upload an artifact containing a directory of junit-xml format files (named uniquely for that job).
For example, the following fragment of GitHub Actions workflow yaml creates a directory containing junit-xml output from two different test suite runs, and uploads the directory as an artifact.
You must ensure that the artifact name is unique within the repository (so you'll probably want to use `${{github.run_id}}` at least)

```yaml
- run: mkdir junit-xml
- run: my-test-command --test-suite-variant=something --junit-xml=junit-xml/${{ matrix.python }}-${{ matrix.os }}-something.xml
- run: my-test-command --test-suite-variant=something-else --junit-xml=junit-xml/${{ matrix.python }}-${{ matrix.os }}-something-else.xml
- name: "Upload junit-xml artifacts"
uses: actions/upload-artifact@v4
if: always()
with:
    name: junit-xml--${{github.run_id}}--${{github.run_attempt}}--${{ matrix.python }}--${{ matrix.os }}
    path: junit-xml
    retention-days: 30
```
