summaryrefslogtreecommitdiff
path: root/README.md
blob: 62a877c10f41718b8a28b77a4d550f8a3dde50d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Squad-Client

`squad-client` is a tool for accessing data from a [SQUAD](https://github.com/Linaro/squad) instance through its API. We try to make it look as close as possible to SQUAD's [data model](https://squad.readthedocs.io/en/latest/intro.html#core-data-model), by using classes and methods that hopefully will be intuitive for any user familiar with SQUAD terms.

It is still in early development stages so please report bugs :)

# Use cases

The main purpose of this tool is to ease report customization based on one's specific needs. 

## Report generation

squad-client has a built-in feature that reads in a yaml file describing a basic report with simple data querying:

```yaml
squad_url: http://localhost:8000
reports:
    - name: Name of the report
      template: my_template.html.jinja2
      # output: generated_report.html  # will be printed to stdout if omitted
      context:
          # keys under this directive are going to be available in the template
          projects: # same as projects = Squad().projects(group__slug='lkft')
              type: Project
              filters:
                  group__slug: lkft  
```

Save that to a file named `my-report.yml`. Now write the report template:

```jinja2
{% for project_id, project in projects.items() %}
  {{ project.slug }}
{% endfor %}

```

Save that to `my_template.html.jinja2`. Now to generate that report described in `my-report.yml`, just run

```sh
./manage.py report --report-config my-report.yaml
```

The output of this command should look similar to:

```
    project: linaro-hikey-stable-rc-4.4-oe

    project: linux-developer-oe

    project: linux-mainline-oe

    project: linux-mainline-oe-sanity

    project: linux-next-oe

    project: linux-next-oe-new
    
    ...
```

#### Complex reports

More complex filtering and data retrieval are available. Here is an example of getting a specific build:

```python
from squad_client.core.api import SquadApi
from squad_client.core.models import Squad

SquadApi.configure(url='https://qa-reports.linaro.org/')

group = Squad().group('lkft')
project = group.project('linux-stable-rc-4.14-oe-sanity')
build = project.build('v4.14.74')

# or this could be a single chained line
build = Squad().group('lkft').project('linux-stable-rc-4.14-oe-sanity').build('v4.14.74')

# filtering is also available
finished_builds = Squad().group('lkft').project('linux-stable-rc-4.14-oe-sanity').builds(status__finished=True)
```

For more examples, see `examples` folder.