Skip to content

Commit

Permalink
Merge 4749df2 into 2576e2b
Browse files Browse the repository at this point in the history
  • Loading branch information
milosmns committed Oct 30, 2023
2 parents 2576e2b + 4749df2 commit 6cb0ba5
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 58 deletions.
105 changes: 62 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
[![Version](https://img.shields.io/github/v/release/milosmns/code-stats?label=Latest&color=green)](./releases)  
[![Build Status](https://img.shields.io/github/actions/workflow/status/milosmns/code-stats/build-ga.yaml?label=Build)](./actions/workflows/build-ga.yaml)  
[![License: NT-GPL v3](https://img.shields.io/badge/License-NTGPLv3-blue)](./LICENSE)  
[![Issues](https://img.shields.io/github/issues-raw/milosmns/code-stats?label=Issues&color=gold)](./issues)  
[![Discussions](https://img.shields.io/github/discussions/milosmns/code-stats?label=Discussions&color=pink)](./discussions)  
[![Version](https://img.shields.io/github/v/release/milosmns/code-stats?label=Latest&color=green)](https://github.com/milosmns/code-stats/releases)
 
[![Build Status](https://img.shields.io/github/actions/workflow/status/milosmns/code-stats/build-ga.yaml?label=Build)](https://github.com/milosmns/code-stats/actions/workflows/build-ga.yaml)
 
[![License: NT-GPL v3](https://img.shields.io/badge/License-NTGPLv3-blue)](./LICENSE)
 
[![Issues](https://img.shields.io/github/issues-raw/milosmns/code-stats?label=Issues&color=gold)](https://github.com/milosmns/code-stats/issues)
 
[![Discussions](https://img.shields.io/github/discussions/milosmns/code-stats?label=Discussions&color=pink)](https://github.com/milosmns/code-stats/discussions)
 

[//]: # (Inspired by https://github.com/othneildrew/Best-README-Template/blob/master/BLANK_README.md)

<br/>
<br/>
<div align="center">
<div style="text-align: center">
<!--suppress CheckImageSize -->
<img src="./readme/media/code-stats-logo-icon.png" alt="Logo" width="128" height="128">
<h3>Code Stats</h3>

Expand All @@ -18,25 +24,33 @@
Dive in and transform your team workflows!
<br/>
<br/>
<a href="./issues">Report a bug</a>
<a href="https://github.com/milosmns/code-stats/issues">Report a bug</a>
·
<a href="./issues">Request a feature</a>
<a href="https://github.com/milosmns/code-stats/issues">Request a feature</a>
·
<a href="./discussions">Meet & say thanks</a>
<a href="https://github.com/milosmns/code-stats/discussions">Meet & say thanks</a>
</p>
</div>

### Built using

[![Kotlin](https://img.shields.io/badge/kotlin-37F52FF.svg?style=for-the-badge&logo=kotlin&logoColor=white)](https://kotlinlang.org) &nbsp;
[![Ktor](https://img.shields.io/badge/ktor-07405E.svg?style=for-the-badge&logo=kotlin&logoColor=white)](https://ktor.io) &nbsp;
[![SQLDelight](https://img.shields.io/badge/SQL%20Delight-07405E.svg?style=for-the-badge&logo=kotlin&logoColor=white)](https://github.com/cashapp/sqldelight) &nbsp;
[![SQLite](https://img.shields.io/badge/sqlite-FF405E.svg?style=for-the-badge&logo=sqlite&logoColor=white)](https://www.sqlite.org) &nbsp;

[![HTML5](https://img.shields.io/badge/html5-E34F26.svg?style=for-the-badge&logo=html5&logoColor=white)](https://www.w3schools.com/html) &nbsp;
[![Bootstrap](https://img.shields.io/badge/bootstrap-8511FA.svg?style=for-the-badge&logo=bootstrap&logoColor=white)](https://getbootstrap.com) &nbsp;
[![JavaScript](https://img.shields.io/badge/javascript-323330.svg?style=for-the-badge&logo=javascript&logoColor=F7DF1E)](https://www.javascript.com) &nbsp;
[![Chart.js](https://img.shields.io/badge/chart.js-F5788D.svg?style=for-the-badge&logo=chart.js&logoColor=white)](https://www.chartjs.org) &nbsp;
[![Kotlin](https://img.shields.io/badge/kotlin-37F52FF.svg?style=for-the-badge&logo=kotlin&logoColor=white)](https://kotlinlang.org)
&nbsp;
[![Ktor](https://img.shields.io/badge/ktor-07405E.svg?style=for-the-badge&logo=kotlin&logoColor=white)](https://ktor.io)
&nbsp;
[![SQLDelight](https://img.shields.io/badge/SQL%20Delight-07405E.svg?style=for-the-badge&logo=kotlin&logoColor=white)](https://github.com/cashapp/sqldelight)
&nbsp;
[![SQLite](https://img.shields.io/badge/sqlite-FF405E.svg?style=for-the-badge&logo=sqlite&logoColor=white)](https://www.sqlite.org)
&nbsp;

[![HTML5](https://img.shields.io/badge/html5-E34F26.svg?style=for-the-badge&logo=html5&logoColor=white)](https://www.w3schools.com/html)
&nbsp;
[![Bootstrap](https://img.shields.io/badge/bootstrap-8511FA.svg?style=for-the-badge&logo=bootstrap&logoColor=white)](https://getbootstrap.com)
&nbsp;
[![JavaScript](https://img.shields.io/badge/javascript-323330.svg?style=for-the-badge&logo=javascript&logoColor=F7DF1E)](https://www.javascript.com)
&nbsp;
[![Chart.js](https://img.shields.io/badge/chart.js-F5788D.svg?style=for-the-badge&logo=chart.js&logoColor=white)](https://www.chartjs.org)
&nbsp;

#### Support

Expand All @@ -56,7 +70,8 @@ However, the GitHub page leaves a lot to be desired.
For example, have you ever wondered about your project's [Cycle Time](https://tulip.co/blog/cycle-vs-lead-vs-takt)?
Are you blocking each other, or things are moving smoothly through your development pipeline?
Have you wondered about the evolution of this metric over time?
This metric (and many more) can be computed using the raw contribution data available in code repositories and at GitHub.
This metric (and many more) can be computed using the raw contribution data available
in code repositories and at GitHub.

To make time theft more visible, Code Stats aims to provide an alternative interface to GitHub's insights pages.
Take a look at some of the examples below.
Expand All @@ -66,9 +81,10 @@ Take a look at some of the examples below.

## Getting Started

The project is build with [Kotlin/Native](https://kotlinlang.org/docs/native-overview.html) (supporting multi-platform native binaries).
The project is build with [Kotlin/Native](https://kotlinlang.org/docs/native-overview.html)
(supporting multi-platform native binaries).
However, due to complications with the automation pipelines and some issues with Kotlin's native compiler (Konan),
native binaries are <u>**temporarily** disabled</u>.
native binary outputs are <u>**temporarily** disabled</u>.

For the time being, you can still use the packages available for the Java Virtual Machine (JVM).

Expand All @@ -83,21 +99,22 @@ This is done by setting an environment variable called `GITHUB_TOKEN`.

To run the JVM flavor, you need:

* Java installed and available on the Path; OpenJDK is fine.
* Java installed and available on the Path; OpenJDK is fine.

### Prerequisites for building

##### JVM

To build the JVM flavor, you need:

* Java installed and available on the Path; OpenJDK is fine.
* Java installed and available on the Path; OpenJDK is fine.

## How to run

##### JVM

Simply download the latest version from [Releases](./releases) and run it using Java:
Simply download the latest version from [Releases](https://github.com/milosmns/code-stats/releases)
and run it using Java:

```console
$ java -jar codestats.jar --help
Expand All @@ -107,13 +124,15 @@ $ java -jar codestats.jar --help

##### JVM

Clone the project's repository to your local machine. Then, from the project's root directory run:
Clone the project's repository to your local machine.
Then, from the project's root directory run:

```console
$ ./gradlew shadowJar
```

Your output should be exactly the same as the [latest Release](./releases), and stored in `build/libs/codestats.jar`.
Your output should be exactly the same as the [latest Release](https://github.com/milosmns/code-stats/releases),
and stored in `build/libs/codestats.jar`.

## Usage

Expand All @@ -131,11 +150,11 @@ $ codestats --help

There are several modes that Code Stats can run in.

1. **Fetch** – fetches fresh contribution data and stores it locally for analysis
1. **Print** – calculates and prints all of the code stats (metrics) to `stdout`
1. **Report** – prints a short report on what data is available locally
1. **Serve** – launches a backend server locally, and prints the access URL for the web UI
1. **Purge** – deletes all locally stored data
1. **Fetch** – fetches fresh contribution data and stores it locally for analysis
1. **Print** – calculates and prints all the code stats (metrics) to `stdout`
1. **Report** – prints a short report on what data is available locally
1. **Serve** – launches a backend server locally, and prints the access URL for the web UI
1. **Purge** – deletes all locally stored data

To choose a mode, simply add a `--mode` modifier:

Expand All @@ -155,10 +174,10 @@ owner: nasa # GitHub repository owner
startDate: 2023-01-01 # no data before this date
endDate: 2023-03-15 # no data after this date

teams: # all teams you'd like to inspect
teams: # all teams you'd like to inspect
- title: Flight Team # GitHub user-friendly team name
name: nasa-flight # GitHub team ID
codeRepositories: # where the code lives
codeRepositories: # where the code lives
- openmct
- HyperCP
- cmr-stac
Expand All @@ -179,15 +198,15 @@ You can also refer to the [sample configuration file](./src/commonMain/resources

There are even more configuration options you can use as environment variables:

* <font color="red">`GITHUB_TOKEN`</font> – the (mandatory) authentication token for communicating with GitHub
* `GITHUB_URL` – a REST GitHub Enterprise URL; default is `api.github.com`
* `GITHUB_GRAPHQL_URL` – a GraphQL GitHub Enterprise URL; default is `api.github.com/graphql`
* `GITHUB_PAGING_LIMIT` – how many items to fetch per page (when paging); default is `100`
* `GITHUB_VERBOSE` – whether to print verbose update in the console; default is `false`
* `GITHUB_PRINT_PROGRESS` – whether to print progress updates for GitHub API fetch; default is `true`
* `GITHUB_RATE_LIMIT_DELAY_MILLIS` – a rate-limiting delay for requests to GitHub; default is `2.1s`
* `DATABASE_PATH` – which local database to use (file path); default is `code-stats.db`
* `STATS_PORT_API` – on which port to launch the server for the web UI; default is `8080`
* <font color="red">`GITHUB_TOKEN`</font> – the (mandatory) authentication token for communicating with GitHub
* `GITHUB_URL` – a REST GitHub Enterprise URL; default is `api.github.com`
* `GITHUB_GRAPHQL_URL` – a GraphQL GitHub Enterprise URL; default is `api.github.com/graphql`
* `GITHUB_PAGING_LIMIT` – how many items to fetch per page (when paging); default is `100`
* `GITHUB_VERBOSE` – whether to print verbose update in the console; default is `false`
* `GITHUB_PRINT_PROGRESS` – whether to print progress updates for GitHub API fetch; default is `true`
* `GITHUB_RATE_LIMIT_DELAY_MILLIS` – a rate-limiting delay for requests to GitHub; default is `2.1s`
* `DATABASE_PATH` – which local database to use (file path); default is `code-stats.db`
* `STATS_PORT_API` – on which port to launch the server for the web UI; default is `8080`

The executable will automatically read these variables and apply them before running.

Expand All @@ -200,5 +219,5 @@ To read the contributions guideline, go to [CONTRIBUTING](./CONTRIBUTING).

## License

Distributed under the Non-Toxic GNU GPL v3 License.
Distributed under the Non-Toxic GNU GPL v3 License.
See [LICENSE](./LICENSE) for more information about this particular license.
31 changes: 17 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.gradle.internal.impldep.org.joda.time.LocalDateTime
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinTargetContainerWithPresetFunctions
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmCompilation
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithHostTests

plugins {
application
Expand Down Expand Up @@ -97,20 +98,20 @@ kotlin {
}

// used by the 'getting' delegate
@Suppress("UNUSED_VARIABLE", "KotlinRedundantDiagnosticSuppress")
val macNativeMain by getting {
dependsOn(commonMain)
dependencies {
implementation("io.ktor:ktor-client-curl:2.3.+")
implementation("app.cash.sqldelight:native-driver:2.+")
}
}
// @Suppress("UNUSED_VARIABLE", "KotlinRedundantDiagnosticSuppress")
// val macNativeMain by getting {
// dependsOn(commonMain)
// dependencies {
// implementation("io.ktor:ktor-client-curl:2.3.+")
// implementation("app.cash.sqldelight:native-driver:2.+")
// }
// }

// used by the 'getting' delegate
@Suppress("UNUSED_VARIABLE", "KotlinRedundantDiagnosticSuppress")
val macNativeTest by getting {
dependsOn(commonTest)
}
// @Suppress("UNUSED_VARIABLE", "KotlinRedundantDiagnosticSuppress")
// val macNativeTest by getting {
// dependsOn(commonTest)
// }

}

Expand Down Expand Up @@ -409,9 +410,11 @@ class Configurator(private val env: Env, private val output: Output) {
println("Configured Kotlin target '$name'")
}

fun configureNativeTarget(container: KotlinTargetContainerWithPresetFunctions) =
@Suppress("USELESS_CAST", "UNUSED_PARAMETER")
fun configureNativeTarget(container: KotlinTargetContainerWithPresetFunctions): KotlinNativeTargetWithHostTests? =
when (env.currentPlatform) {
Env.Platform.MAC -> null // TODO – disabled temporarily until the build is fixed
// TODO – disabled temporarily until the build is fixed
Env.Platform.MAC -> null as? KotlinNativeTargetWithHostTests?
// when (env.currentArch) {
// Env.Arch.X86 -> container.macosX64(env.currentPlatform.targetName)
// Env.Arch.ARM -> container.macosArm64(env.currentPlatform.targetName)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ org.gradle.jvmargs=-Xmx4096m
# Project properties
config.group = xyz.marinkovic.milos
config.artifact = codestats
config.version = 0.8.0
config.version = 0.9.0
config.gitHubRepoOwner = milosmns
config.gitHubRepoName = code-stats

0 comments on commit 6cb0ba5

Please sign in to comment.