Skip to content

Commit

Permalink
Convert to multiplatform (#11)
Browse files Browse the repository at this point in the history
* update gradle v6.0.1 -> v6.6.1

* update kotlin v1.3.61 -> v1.4.21

* prepare buildSrc and gradle.properties to go multiplatform

* update gradle v6.6.1 -> v6.7.1

* converted to multiplatform with jvm and nodeJS targets

* configure 'com.github.ben-manes.versions' gradle plugin

* enabled strict 'explicitApi' mode for all modules

* use Kotlin DSL extension of 'tasks.named(...)' to avoid IDE errors

* increase mocha tests timeout to 10s

* add js browser target

* set jvm test target to 1.8 (default is 1.6)

* update kotlin v1.4.21 -> v.1.4.30

* remove js browser target and avoid setting jvmTarget for now

* remove *.gradle files from older multiplatform implementation

* update gradle v6.7.1 -> v6.8.1

* set jvm target to 1.8 (default is 1.6)

* added GitHub actions based ci

* config dependencyResolutionManagement in settings.gradle.kts

* define logging for all test tasks

* create root aggregate test report for all sub-modules

* amend github action workflows

* fix jacoco config

* remove unnecessary repo

* set GitHub credentials for deployment in workflow

* added 'maven-publish' plugin and config for GitHub Packages

* if build fails - bundle and upload build reports

* add a failing test to check ci build failure report

* remove failing test - now ci should pass

* added upload failed build reports to ci

* ci workflow - publish 'master-SNAPSHOT' versions to GitHub Packages

* fix GitHub Packages maven repo name that affects expected property names for credentials

* update README.md for multiplatform support

* make suer maven 'groupId' of published modules is in lowercase

* add CI badge to README.md

* add a github release workflow

* Update release.yml

* Update mpp-module.gradle.kts

* pass 'version' property to gradle when publishing

* pass 'version' system property to gradle when publishing

* fix names of workflows

* update gradle v6.8.1 -> v6.8.2

* update README.md
  • Loading branch information
Or Noyman authored Feb 21, 2021
1 parent a325530 commit a29443c
Show file tree
Hide file tree
Showing 34 changed files with 465 additions and 579 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Continuous Integration

env:
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=false -Dorg.gradle.vfs.watch=false -Dkotlin.compiler.execution.strategy=in-process'
JAVA_VERSION: 11
ORG_GRADLE_PROJECT_githubUsername: ${{ github.actor }}
ORG_GRADLE_PROJECT_githubPassword: ${{ github.token }}

on:
push:
branches:
- master
paths-ignore:
- '*.md'
- 'LICENSE'
- '.gitignore'

jobs:
build:
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}

- name: Cache gradle
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build project and run tests with Gradle
run: ./gradlew clean build --info

- name: Bundle the failed build report
if: failure()
run: find ./build -type d -name 'reports' | zip -@ -r build-reports.zip

- name: Upload the failed build report
if: failure()
uses: actions/upload-artifact@v2
with:
name: error-report
path: build-reports.zip
retention-days: 7

- name: Publish library with Gradle
run: ./gradlew publish -Dversion=master-SNAPSHOT
60 changes: 60 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Pull Request Check

env:
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=false -Dorg.gradle.vfs.watch=false -Dkotlin.compiler.execution.strategy=in-process'
JAVA_VERSION: 11

on:
pull_request:
branches:
- master
paths-ignore:
- '*.md'
- 'LICENSE'
- '.gitignore'

jobs:
build:
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}

- name: Cache gradle
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build project and run tests
run: ./gradlew clean build --info

- name: Bundle the failed build report
if: failure()
run: find ./build -type d -name 'reports' | zip -@ -r build-reports.zip

- name: Upload the failed build report
if: failure()
uses: actions/upload-artifact@v2
with:
name: error-report
path: build-reports.zip
retention-days: 7
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release

env:
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=false -Dorg.gradle.vfs.watch=false -Dkotlin.compiler.execution.strategy=in-process'
JAVA_VERSION: 11
ORG_GRADLE_PROJECT_githubUsername: ${{ github.actor }}
ORG_GRADLE_PROJECT_githubPassword: ${{ github.token }}

on:
release:
types: [published]

jobs:
build:
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}

- name: Cache gradle
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build project and run tests with Gradle
run: ./gradlew clean build --info

- name: Bundle the failed build report
if: failure()
run: find ./build -type d -name 'reports' | zip -@ -r build-reports.zip

- name: Upload the failed build report
if: failure()
uses: actions/upload-artifact@v2
with:
name: error-report
path: build-reports.zip
retention-days: 7

- name: Publish library with Gradle
run: |
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
./gradlew publish -Dversion=${NEW_VERSION}
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
![CI](https://github.com/komputing/KHex/workflows/Continuous%20Integration/badge.svg)
# What is it?
KHex is a Kotlin library to deal with hexadecimal encoding and decoding.

KHex is a Kotlin multiplatform library to deal with hexadecimal encoding and decoding.

It was incubated as part of [KEthereum](https://github.com/komputing/KEthereum) but then extracted as it can be useful
outside this context.


# Get it

## GitHub Packages

This library is available through GitHub Packages.

![badge][badge-js]
![badge][badge-jvm]

In order to use it, first include the GitHub Packages maven repository inside your project build.gradle.kts file:

```kotlin
repositories {
maven {
name = "komputing/KHex GitHub Packages"
url = uri("https://maven.pkg.github.com/komputing/KHex")
credentials {
username = "token"
password = "\u0039\u0032\u0037\u0034\u0031\u0064\u0038\u0033\u0064\u0036\u0039\u0061\u0063\u0061\u0066\u0031\u0062\u0034\u0061\u0030\u0034\u0035\u0033\u0061\u0063\u0032\u0036\u0038\u0036\u0062\u0036\u0032\u0035\u0065\u0034\u0061\u0065\u0034\u0032\u0062"
}
}
}
```
When 'username' could be anything and 'password' is an [encoded access token for public access](https://github.community/t/download-from-github-package-registry-without-authentication/14407/44).


## JitPack (JVM only!)

This library is available on Jitpack. The current version is:

[![](https://jitpack.io/v/komputing/khex.svg)](https://jitpack.io/#komputing/khex)
![badge][badge-jvm]

In order to use it, first of all include the Jitpack maven repository inside your project `build.gradle` file:
In order to use it, first include the Jitpack maven repository inside your project `build.gradle` file:

```groovy
repositories {
Expand Down Expand Up @@ -74,3 +104,6 @@ HexString("0xaa12456789bb").clean0xPrefix()

# License
MIT

[badge-js]: http://img.shields.io/badge/platform-js-yellow.svg?style=flat
[badge-jvm]: http://img.shields.io/badge/platform-jvm-orange.svg?style=flat
65 changes: 12 additions & 53 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,61 +1,20 @@
apply {
from("https://raw.githubusercontent.com/ligi/gradle-common/master/versions_plugin_stable_only.gradle")
plugins {
base
}

buildscript {
repositories {
jcenter()
}

dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
classpath("com.github.ben-manes:gradle-versions-plugin:${Versions.versionsPlugin}")
}

val testAggregateReport = tasks.register<TestReport>("testAggregateReport") {
group = "Reporting"
description = "Collect aggregate test reports of all sub-modules."
destinationDir = file("$buildDir/reports/tests")
reportOn(subprojects.map {
it.tasks.withType<AbstractTestTask>()
})
}

allprojects {

repositories {
jcenter()
maven("https://jitpack.io")
}

}


subprojects {
repositories {
jcenter()
maven("https://jitpack.io")
maven("https://kotlin.bintray.com/kotlinx")
}

apply(plugin = "jacoco")
apply(plugin = "maven")
apply(plugin = "kotlin")

tasks.withType<Test> {
useJUnitPlatform()
}

configure<JavaPluginExtension> {
withSourcesJar()
withJavadocJar()
}

afterEvaluate {

dependencies {
"implementation"("org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}")

"testImplementation"("org.assertj:assertj-core:3.14.0")
"testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.jupiter}")
"testRuntime"("org.junit.jupiter:junit-jupiter-engine:${Versions.jupiter}")

"testImplementation"("org.jetbrains.kotlin:kotlin-test")
tasks.withType<AbstractTestTask> {
finalizedBy(testAggregateReport)
}

}
}

}
6 changes: 6 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
idea
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}

repositories {
Expand All @@ -12,4 +13,9 @@ idea {
isDownloadJavadoc = false
isDownloadSources = false
}
}

dependencies {
implementation(kotlin("gradle-plugin", "${property("kgp")}"))
implementation("com.github.ben-manes", "gradle-versions-plugin", "${property("plugin.com.github.ben-manes.versions")}")
}
1 change: 1 addition & 0 deletions buildSrc/gradle.properties
5 changes: 2 additions & 3 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
object Versions {
const val kotlin = "1.3.61"
const val versionsPlugin = "0.27.0"
const val jupiter = "5.5.2"
const val jacocoPlugin = "0.8.5"
const val assertk = "0.23"
}
Loading

0 comments on commit a29443c

Please sign in to comment.