Skip to content

Commit

Permalink
Add JUnit support (#1)
Browse files Browse the repository at this point in the history
* Add JUNit support

* a

* test

* asd

* fix

* Fix unit tests and code

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* Update README.md

Signed-off-by: Joel Dickson <[email protected]>

---------

Signed-off-by: Joel Dickson <[email protected]>
Co-authored-by: Joel Dickson <[email protected]>
  • Loading branch information
joeldickson and dicko2 authored Aug 29, 2024
1 parent 56bdb7e commit 2ebf78f
Show file tree
Hide file tree
Showing 13 changed files with 879 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Java CI with Gradle and Maven Central Upload

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build
continue-on-error: true

- name: Run tests
run: ./gradlew test

- name: Upload Test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-report
path: build/reports

- name: Publish to Maven Central
if: github.event_name == 'release'
run: |
./gradlew publish
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
GPG_SIGNING_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
GPG_SIGNING_PASSWORD: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
/.gradle/
/build/
2 changes: 2 additions & 0 deletions .gradle/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ossrhUsername=your_username
ossrhPassword=your_password
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
# java-local-metrics
# Developer Experience Metrics Library

## Overview

The Developer Experience Metrics Library is an open-source Java tool designed to measure and improve the developer experience on local workstations. By providing insights into test execution, build times, and system resource usage, this library helps development teams identify bottlenecks, optimize workflows, and enhance overall productivity.

## Features

- **Test Execution Metrics**: Capture detailed information about JUnit test runs, including execution time, pass/fail status, and system resource usage during tests.

## Requirements

Minimum Java Version 11

## Installation

### Maven

Add the following dependency to your `pom.xml`:

```xml
<dependency>
<groupId>io.agodadev.testmetrics</groupId>
<artifactId>dev-experience-metrics</artifactId>
<version>1.0.0</version>
</dependency>
```

### Gradle

Add the following to your `build.gradle`:

```gradle
implementation 'io.agodadev.testmetrics:dev-experience-metrics:1.0.0'
```

## Quick Start


### 1. Configure JUnit Listener

Add the following VM option to your JUnit run configuration:

```
-Djunit.runner.addListeners=io.agodadev.testmetrics.LocalCollectionTestRunListener
```

## Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for more details.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Thanks to all the contributors who have helped shape this project.
- Special thanks to the JUnit team for their excellent testing framework.

---

Happy coding, and may your development experience be ever improving!
89 changes: 89 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
plugins {
id 'java'
id 'maven-publish'
id 'signing'
}

group = 'io.agodadev'
version = '1.0.0'

sourceCompatibility = '11'
targetCompatibility = '11'

repositories {
mavenCentral()
}

dependencies {
implementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.12.4'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
}

java {
withJavadocJar()
withSourcesJar()
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java

pom {
name = 'testmetrics'
description = 'A library for measuring and improving developer experience on local workstations.'
url = 'https://github.com/agodadev/testmetrics'

licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
name = 'Joel Dickson'
email = '[email protected]'
organization = 'agoda'
organizationUrl = 'http://www.agoda.com'
}
}

scm {
connection = 'scm:[email protected]:agoda-com/java-local-metrics.git'
developerConnection = 'scm:git:ssh://github.com:agoda-com/java-local-metrics.git'
url = 'https://github.com/agoda-com/java-local-metrics/tree/main'
}
}
}
}
repositories {
maven {
name = "OSSRH"
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = project.hasProperty('ossrhUsername') ? ossrhUsername : "dummy"
password = project.hasProperty('ossrhPassword') ? ossrhPassword : "dummy"
}
}
}
}


signing {
def signingKey = System.getenv("GPG_SIGNING_KEY")
def signingPassword = System.getenv("GPG_SIGNING_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}


javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 2ebf78f

Please sign in to comment.