Skip to content

Commit

Permalink
Convert to multiplatform (#21)
Browse files Browse the repository at this point in the history
* update gradle v6.3 -> v6.7.1

* update khex v0.6 -> v1.0.0

* add build config to gradle.properties

* add symbolic link to gradle.properties under buildSrc

* add mpp-module.gradle.kts

* add khex as a commonTest dependency

* enable 'InlineClasses' language feature for all test sourcesets

* add common tests config to mpp-module.gradle.kts

* allow gradual conversion of submodules to MPP

* use 'mavenLocal' deployment of MPP khex temporarily

* increase tests timeout for nodeJS

* TODO: enable strict 'explicitApi'

* convert Keccak submodule to MPP (depend on com.ionspin.kotlin:bignum for MPP BigInteger)

* update kotlin v1.4.21 -> v.1.4.30

* update bignum v0.2.4-SNAPSHOT -> v0.2.4 (stable)

* convert ripemd160 module to multiplatform

* convert sha256 module to multiplatform

* convert sha512 module to multiplatform

* remove non-multiplatform subprojects config

* define dependency versions in Versions.kt

* enabled strict 'explicitApi' mode

* added compilation options for js

* update gradle v6.7.1 -> v6.8.1

* set jvm target to 1.8 (default is 1.6)

* simplify test tasks logging config

* fetch KHex from GitHub Packages

* config dependencyResolutionManagement in settings.gradle.kts

* add comment for the GitHub Packages public access workaround

* fix KHex dependency group name

* add aggregate test report task to root project

* fix KHex dependency groupId

* add GitHub Actions workflows

* swap names of workflows

* add 'maven-publish' with Github Packages config

* increase mocha test timeout to 300s

* update 'com.ionspin.kotlin:bignum' v0.2.4 -> v0.2.8

* use KHex from GitHub Packages of the origin repo

* update gradle v6.8.1 -> v6.8.2

* update KHex vmaster-SNAPSHOT -> v1.1.0

* update README.md

* remove 'version' from gradle.properties
  • Loading branch information
Or Noyman authored Feb 21, 2021
1 parent 6fe00e9 commit 9cfabe9
Show file tree
Hide file tree
Showing 48 changed files with 539 additions and 147 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}
58 changes: 56 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![](https://jitpack.io/v/komputing/khash.svg)](https://jitpack.io/#komputing/khash)
![CI](https://github.com/komputing/KHash/workflows/Continuous%20Integration/badge.svg)

# KHash

KHash is a Kotlin library implementing common hashing functions.
KHash is a Kotlin multiplatform library implementing common hashing functions.

A part from that, it also provides some useful [extensions functions](https://kotlinlang.org/docs/reference/extensions.html).

Expand All @@ -13,6 +13,57 @@ The implemented hashing functions are the following.
- Heavily based on this java implementation: [@romus/sha](https://github.com/romus/sha)
- Tested with [Nist test vectors](https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/sha3/sha-3bittestvectors.zip)

## 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/KHash GitHub Packages"
url = uri("https://maven.pkg.github.com/komputing/KHash")
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/khash.svg)](https://jitpack.io/#komputing/khash)
![badge][badge-jvm]

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

```kotlin
repositories {
maven { url="https://jitpack.io" }
}
```

## Set it up

Include the modules inside your project:

```kotlin
dependencies {
implementation("com.github.komputing.khash:<module>:<version>")
}
```

Where `<version>` can be either a [release](https://github.com/komputing/KHash/releases) or `<branch>-SNAPSHOT` such as `master-SNAPHOT`.

## Usage
### `keccak`
Expand Down Expand Up @@ -92,3 +143,6 @@ Also this code is not hardened against side channel attacks. Keep this in mind w

# 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
52 changes: 11 additions & 41 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,50 +1,20 @@
plugins {
id("com.github.ben-manes.versions").version(Versions.versions_plugin)
base
}

buildscript {
repositories {
mavenLocal()
jcenter()
maven("https://plugins.gradle.org/m2/")
}

dependencies {
classpath("com.github.ben-manes:gradle-versions-plugin:${Versions.versions_plugin}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
}
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>()
})
}



subprojects {
group = "org.komputing"

plugins.apply("kotlin")
plugins.apply("maven")

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

"testCompile"("org.junit.jupiter:junit-jupiter-api:${Versions.jupiter}")
"testCompile"("org.junit.jupiter:junit-jupiter-params:${Versions.jupiter}")
"testRuntime"("org.junit.jupiter:junit-jupiter-engine:${Versions.jupiter}")

"testImplementation"("org.jetbrains.kotlin:kotlin-test")

"testImplementation"("com.github.komputing:khex:0.6")
}

tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
afterEvaluate {
tasks.withType<AbstractTestTask> {
finalizedBy(testAggregateReport)
}
}

repositories {
jcenter()
maven("https://jitpack.io")
maven("https://kotlin.bintray.com/kotlinx")
}
}
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.71"
const val versions_plugin = "0.28.0"
const val jupiter = "5.6.1"
const val khex = "1.1.0"
const val bignum = "0.2.8"
}
Loading

0 comments on commit 9cfabe9

Please sign in to comment.