Giter Club home page Giter Club logo

tabia's Introduction

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.

  • ID
  • Name
  • Description
  • URL
  • SSHURL
  • Owner
  • Visibility
  • CreatedAt
  • UpdatedAt
  • PushedAt
  • Topics

The following functions are available.

  • func (RepositoryFilterEnv) Contains(s, substr string) bool
  • func (Repository) IsPublic() bool
  • func (Repository) IsInternal() bool
  • func (Repository) IsPrivate() bool
  • func (Repository) HasTopic(topic string) bool
  • func (Repository) CreatedSince(date string) bool
  • func (Repository) UpdatedSince(date string) bool
  • func (Repository) PushedSince(date string) bool
$ 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.

  • ID
  • Login
  • Name
  • Organization
  • SamlIdentity
    • ID

The following functions are available.

  • func (MemberFilterEnv) Contains(s, substr string) bool

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)
...
...
..

tabia's People

Contributors

bartgolsteijn avatar dependabot[bot] avatar jeroenknoops avatar johnmanjiro13 avatar marcofranssen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tabia's Issues

Include external collaborators in "github members"

External collaborators in an organization should be included in the members overview.
For each member in this overview it should be clear that the member is a external collaborator using a boolean field.

Include github forks

To be able to fetch github forks the query has to be adjusted.

From:
{"query":"org:philips-forks archived:false","repoCursor":null}

To:
{"query":"org:philips-forks archived:false fork: true","repoCursor":null}

Furthermore it would be good to include this in the table output to indicate which repo is a fork.

Also include filter capability to show only forks, both or non-forks.

Github format json is wrongly serializing the visibility

Currently:

$ tabia github repositories -O philips-labs -F json
[
  {
    "name": "tabia",
    "id": "MDEwOlJlcG9zaXRvcnkyNjUzMDYzNzU=",
    "url": "https://github.com/philips-labs/tabia",
    "ssh_url": "[email protected]:philips-labs/tabia.git",
    "owner": "philips-labs",
    "created_at": "2020-05-19T16:50:46Z",
    "updated_at": "2020-07-20T13:31:06Z",
    "pushed_at": "2020-07-20T13:32:18Z"
  },
  {
    "name": "internal-example",
    "id": "MDEwOlJlcG9zaXRvcnkyNjUzMDYzNzU=",
    "url": "https://github.com/philips-labs/internal-example",
    "ssh_url": "[email protected]:philips-labs/internal-example.git",
    "owner": "philips-labs",
    "is_private": 1,
    "created_at": "2020-05-19T16:50:46Z",
    "updated_at": "2020-07-20T13:31:06Z",
    "pushed_at": "2020-07-20T13:32:18Z"
  },
  {
    "name": "private-example",
    "id": "MDEwOlJlcG9zaXRvcnkyNjUzMDYzNzU=",
    "url": "https://github.com/philips-labs/private-example",
    "ssh_url": "[email protected]:philips-labs/private-example.git",
    "owner": "philips-labs",
    "is_private": 2,
    "created_at": "2020-05-19T16:50:46Z",
    "updated_at": "2020-07-20T13:31:06Z",
    "pushed_at": "2020-07-20T13:32:18Z"
  },
]

Expected:

See is_private is renamed to visibility and values are represented as string as opposed to integer.

$ tabia github repositories -O philips-labs -F json
[
  {
    "name": "tabia",
    "id": "MDEwOlJlcG9zaXRvcnkyNjUzMDYzNzU=",
    "url": "https://github.com/philips-labs/tabia",
    "ssh_url": "[email protected]:philips-labs/tabia.git",
    "owner": "philips-labs",
    "visibility": "Public",
    "created_at": "2020-05-19T16:50:46Z",
    "updated_at": "2020-07-20T13:31:06Z",
    "pushed_at": "2020-07-20T13:32:18Z"
  },
  {
    "name": "internal-example",
    "id": "MDEwOlJlcG9zaXRvcnkyNjUzMDYzNzU=",
    "url": "https://github.com/philips-labs/internal-example",
    "ssh_url": "[email protected]:philips-labs/internal-example.git",
    "owner": "philips-labs",
    "visibility": "Internal",
    "created_at": "2020-05-19T16:50:46Z",
    "updated_at": "2020-07-20T13:31:06Z",
    "pushed_at": "2020-07-20T13:32:18Z"
  },
  {
    "name": "private-example",
    "id": "MDEwOlJlcG9zaXRvcnkyNjUzMDYzNzU=",
    "url": "https://github.com/philips-labs/private-example",
    "ssh_url": "[email protected]:philips-labs/private-example.git",
    "owner": "philips-labs",
    "visibility": "Private",
    "created_at": "2020-05-19T16:50:46Z",
    "updated_at": "2020-07-20T13:31:06Z",
    "pushed_at": "2020-07-20T13:32:18Z"
  },
]

Repository list is limited to 1000 repositories.

Summary

When quering repositories, tabia only shows the first 1000 repositories.

Example

./bin/tabia github -t <token> repositories -O philips-internal -F templated -T tabia-repository.tmpl > repositories.txt

Add filter capabilities to bitbucket repositories cli

The tabia github repositories cli contains an option --filter with alias -f. Which allows to filter the list of repositories.

The same functionality can be added and documented for the tabia bitbucket repositories cli.

Add templated format to the bitbucket repositories cli

The tabia github repositories cli has an option to define a template for the output using --format templated and --template my-template-file.template which allows for example to output the contents in markdown or csv format.

The same feature can be added to bitbucket.

make build fails, exec: "stringer": executable file not found in $PATH

make build fails with the following error message:

$ make build
BIN_OUTPUT: bin/tabia
rm -rf bin/ cover.out
go generate ./...
go: downloading github.com/urfave/cli/v2 v2.2.0
go: downloading golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
go: downloading github.com/shurcooL/githubv4 v0.0.0-20200414012201-bbc966b061dd
go: downloading github.com/antonmedv/expr v1.8.8
go: downloading golang.org/x/net v0.0.0-20200602114024-627f9648deb9
go: downloading github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0
go: downloading github.com/russross/blackfriday/v2 v2.0.1
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
lib/github/github.go:32: running "stringer": exec: "stringer": executable file not found in $PATH
make: *** [generate] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.