Home

Awesome

Tabia

Go CI codecov

Tabia means characteristic in Swahili. Tabia is giving us insights on the characteristics of our code bases.

Setup

Copy .env.example to .env and fill out the bitbucket token. This environment variable is read by the CLI and tests. Also vscode will read the variable when running tests or starting debugger.

cp .env.example .env
source .env
env | grep TABIA

Install required tools:

make install-tools

Add your $GO_PATH/bin folder to your path to make the installed Go tools globally available.

export GO_PATH="$HOME/go"
export PATH="$GO_PATH/bin:$PATH"

Build

To build the CLI you can make use of the build target using make.

make build

Test

To run tests you can make use of the test target using make.

make test

Run

Bitbucket

To interact with Bitbucket tabia makes use of the Bitbucket 1.0 Rest API.

bin/tabia bitbucket --help
bin/tabia bitbucket projects --help
bin/tabia bitbucket repositories --help

Github

To interact with Github tabia makes use of the Github graphql API.

bin/tabia github --help
bin/tabia github repositories --help

Output - Grimoirelab

To expose the repositories in Grimoirelab projects.json format, you can optionally provide a json file to map repositories to projects. By default the project will be mapped to the owner of the repository. Anything not matching the rules will fall back to this default.

E.g.:

bin/tabia -O philips-labs -M github-projects.json -F grimoirelab > projects.json

Regexes should be defined in the following format.

{
  "rules": {
    "One Codebase": { "url": "tabia|varys|garo|^code\\-chars$" },
    "HSDP": { "url": "(?i)hsdp" },
    "iX": { "url": "(?i)ix\\-" },
    "Licensing Entitlement": { "url": "(?i)lem\\-" },
    "Code Signing": { "url": "(?i)^code\\-signing$|notary" }
  }
}

Output - using template

To generate the output for example in a markdown format you can use the option for a templated output format. This requires you to provide the path to a template file as well. Templates can be defined using the following template/text package syntax.

E.g.:

# Our repositories

Our repository overview. Private/Internal repositories are marked with a __*__

{{range .}}* [{{ .Name}}]({{ .URL }}) {{if .IsPrivate() }}__*__{{end}}
{{end}}

Using above template we can now easily generate a markdown file with this unordered list of repository links.

bin/tabia -O philips-labs -F templated -T markdown.tmpl > repositories.md

Filter

Repositories

The following repository fields can be filtered on.

The following functions are available.

$ bin/tabia github repositories -O philips-labs -f '{ !.IsPrivate() && !.IsInternal() && !Contains(.Name, "terraform") }'
      Name                                  Owner         Visibility  Clone
0001  helm2cf                               philips-labs  Public      https://github.com/philips-labs/helm2cf
0002  dct-notary-admin                      philips-labs  Public      https://github.com/philips-labs/dct-notary-admin
0003  notary                                philips-labs  Public      https://github.com/philips-labs/notary
0004  about-this-organization               philips-labs  Public      https://github.com/philips-labs/about-this-organization
0005  sonar-scanner-action                  philips-labs  Public      https://github.com/philips-labs/sonar-scanner-action
0006  medical-delivery-drone                philips-labs  Public      https://github.com/philips-labs/medical-delivery-drone
0007  dangerous-dave                        philips-labs  Public      https://github.com/philips-labs/dangerous-dave
0008  varys                                 philips-labs  Public      https://github.com/philips-labs/varys
0009  garo                                  philips-labs  Public      https://github.com/philips-labs/garo
..........
...........
........
Members

The following member fields can be filtered on.

The following functions are available.

Download contents

bin/tabia github contents --repo philips-labs/tabia --file README.md --output downloads/tabia/README.md
$ cat downloads/tabia/README.md
# Tabia

[![Go CI](https://github.com/philips-labs/tabia/workflows/Go%20CI/badge.svg)](https://github.com/philips-labs/tabia/actions)
[![codecov](https://codecov.io/gh/philips-labs/tabia/branch/develop/graph/badge.svg?token=K2R9WOXNBm)](https://codecov.io/gh/philips-labs/tabia)
...
...
..