Skip to content

Commit 9cfabe9

Browse files
author
Or Noyman
authored
Convert to multiplatform (#21)
* 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
1 parent 6fe00e9 commit 9cfabe9

48 files changed

Lines changed: 539 additions & 147 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Continuous Integration
2+
3+
env:
4+
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=false -Dorg.gradle.vfs.watch=false -Dkotlin.compiler.execution.strategy=in-process'
5+
JAVA_VERSION: 11
6+
ORG_GRADLE_PROJECT_githubUsername: ${{ github.actor }}
7+
ORG_GRADLE_PROJECT_githubPassword: ${{ github.token }}
8+
9+
on:
10+
push:
11+
branches:
12+
- master
13+
paths-ignore:
14+
- '*.md'
15+
- 'LICENSE'
16+
- '.gitignore'
17+
18+
jobs:
19+
build:
20+
timeout-minutes: 15
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout the repo
25+
uses: actions/checkout@v2
26+
27+
- name: Validate Gradle Wrapper
28+
uses: gradle/wrapper-validation-action@v1
29+
30+
- name: Setup JDK ${{ env.JAVA_VERSION }}
31+
uses: actions/setup-java@v1
32+
with:
33+
java-version: ${{ env.JAVA_VERSION }}
34+
35+
- name: Cache gradle
36+
uses: actions/cache@v2
37+
with:
38+
path: |
39+
~/.gradle/caches
40+
~/.gradle/wrapper
41+
~/.konan
42+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
43+
restore-keys: |
44+
${{ runner.os }}-gradle-
45+
46+
- name: Grant execute permission for gradlew
47+
run: chmod +x gradlew
48+
49+
- name: Build project and run tests with Gradle
50+
run: ./gradlew clean build --info
51+
52+
- name: Bundle the failed build report
53+
if: failure()
54+
run: find ./build -type d -name 'reports' | zip -@ -r build-reports.zip
55+
56+
- name: Upload the failed build report
57+
if: failure()
58+
uses: actions/upload-artifact@v2
59+
with:
60+
name: error-report
61+
path: build-reports.zip
62+
retention-days: 7
63+
64+
- name: Publish library with Gradle
65+
run: ./gradlew publish -Dversion=master-SNAPSHOT

.github/workflows/pr-check.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Pull Request Check
2+
3+
env:
4+
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=false -Dorg.gradle.vfs.watch=false -Dkotlin.compiler.execution.strategy=in-process'
5+
JAVA_VERSION: 11
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- master
11+
paths-ignore:
12+
- '*.md'
13+
- 'LICENSE'
14+
- '.gitignore'
15+
16+
jobs:
17+
build:
18+
timeout-minutes: 15
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout the repo
23+
uses: actions/checkout@v2
24+
25+
- name: Validate Gradle Wrapper
26+
uses: gradle/wrapper-validation-action@v1
27+
28+
- name: Setup JDK ${{ env.JAVA_VERSION }}
29+
uses: actions/setup-java@v1
30+
with:
31+
java-version: ${{ env.JAVA_VERSION }}
32+
33+
- name: Cache gradle
34+
uses: actions/cache@v2
35+
with:
36+
path: |
37+
~/.gradle/caches
38+
~/.gradle/wrapper
39+
~/.konan
40+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
41+
restore-keys: |
42+
${{ runner.os }}-gradle-
43+
44+
- name: Grant execute permission for gradlew
45+
run: chmod +x gradlew
46+
47+
- name: Build project and run tests
48+
run: ./gradlew clean build --info
49+
50+
- name: Bundle the failed build report
51+
if: failure()
52+
run: find ./build -type d -name 'reports' | zip -@ -r build-reports.zip
53+
54+
- name: Upload the failed build report
55+
if: failure()
56+
uses: actions/upload-artifact@v2
57+
with:
58+
name: error-report
59+
path: build-reports.zip
60+
retention-days: 7

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Release
2+
3+
env:
4+
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=false -Dorg.gradle.vfs.watch=false -Dkotlin.compiler.execution.strategy=in-process'
5+
JAVA_VERSION: 11
6+
ORG_GRADLE_PROJECT_githubUsername: ${{ github.actor }}
7+
ORG_GRADLE_PROJECT_githubPassword: ${{ github.token }}
8+
9+
on:
10+
release:
11+
types: [published]
12+
13+
jobs:
14+
build:
15+
timeout-minutes: 15
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout the repo
20+
uses: actions/checkout@v2
21+
22+
- name: Validate Gradle Wrapper
23+
uses: gradle/wrapper-validation-action@v1
24+
25+
- name: Setup JDK ${{ env.JAVA_VERSION }}
26+
uses: actions/setup-java@v1
27+
with:
28+
java-version: ${{ env.JAVA_VERSION }}
29+
30+
- name: Cache gradle
31+
uses: actions/cache@v2
32+
with:
33+
path: |
34+
~/.gradle/caches
35+
~/.gradle/wrapper
36+
~/.konan
37+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
38+
restore-keys: |
39+
${{ runner.os }}-gradle-
40+
41+
- name: Grant execute permission for gradlew
42+
run: chmod +x gradlew
43+
44+
- name: Build project and run tests with Gradle
45+
run: ./gradlew clean build --info
46+
47+
- name: Bundle the failed build report
48+
if: failure()
49+
run: find ./build -type d -name 'reports' | zip -@ -r build-reports.zip
50+
51+
- name: Upload the failed build report
52+
if: failure()
53+
uses: actions/upload-artifact@v2
54+
with:
55+
name: error-report
56+
path: build-reports.zip
57+
retention-days: 7
58+
59+
- name: Publish library with Gradle
60+
run: |
61+
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
62+
./gradlew publish -Dversion=${NEW_VERSION}

README.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
[![](https://jitpack.io/v/komputing/khash.svg)](https://jitpack.io/#komputing/khash)
1+
![CI](https://github.com/komputing/KHash/workflows/Continuous%20Integration/badge.svg)
22

33
# KHash
44

5-
KHash is a Kotlin library implementing common hashing functions.
5+
KHash is a Kotlin multiplatform library implementing common hashing functions.
66

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

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

16+
## Get it
17+
18+
### GitHub Packages
19+
20+
This library is available through GitHub Packages.
21+
22+
![badge][badge-js]
23+
![badge][badge-jvm]
24+
25+
In order to use it, first include the GitHub Packages maven repository inside your project `build.gradle.kts` file:
26+
27+
```kotlin
28+
repositories {
29+
maven {
30+
name = "komputing/KHash GitHub Packages"
31+
url = uri("https://maven.pkg.github.com/komputing/KHash")
32+
credentials {
33+
username = "token"
34+
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"
35+
}
36+
}
37+
}
38+
```
39+
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).
40+
41+
### JitPack (JVM only!)
42+
43+
This library is available on Jitpack. The current version is:
44+
45+
[![](https://jitpack.io/v/komputing/khash.svg)](https://jitpack.io/#komputing/khash)
46+
![badge][badge-jvm]
47+
48+
In order to use it, first include the Jitpack maven repository inside your project `build.gradle.kts` file:
49+
50+
```kotlin
51+
repositories {
52+
maven { url="https://jitpack.io" }
53+
}
54+
```
55+
56+
## Set it up
57+
58+
Include the modules inside your project:
59+
60+
```kotlin
61+
dependencies {
62+
implementation("com.github.komputing.khash:<module>:<version>")
63+
}
64+
```
65+
66+
Where `<version>` can be either a [release](https://github.com/komputing/KHash/releases) or `<branch>-SNAPSHOT` such as `master-SNAPHOT`.
1667

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

93144
# License
94145
MIT
146+
147+
[badge-js]: http://img.shields.io/badge/platform-js-yellow.svg?style=flat
148+
[badge-jvm]: http://img.shields.io/badge/platform-jvm-orange.svg?style=flat

build.gradle.kts

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,20 @@
11
plugins {
2-
id("com.github.ben-manes.versions").version(Versions.versions_plugin)
2+
base
33
}
44

5-
buildscript {
6-
repositories {
7-
mavenLocal()
8-
jcenter()
9-
maven("https://plugins.gradle.org/m2/")
10-
}
11-
12-
dependencies {
13-
classpath("com.github.ben-manes:gradle-versions-plugin:${Versions.versions_plugin}")
14-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
15-
}
5+
val testAggregateReport = tasks.register<TestReport>("testAggregateReport") {
6+
group = "Reporting"
7+
description = "Collect aggregate test reports of all sub-modules."
8+
destinationDir = file("$buildDir/reports/tests")
9+
reportOn(subprojects.map {
10+
it.tasks.withType<AbstractTestTask>()
11+
})
1612
}
1713

18-
19-
2014
subprojects {
21-
group = "org.komputing"
22-
23-
plugins.apply("kotlin")
24-
plugins.apply("maven")
25-
26-
dependencies {
27-
"implementation"("org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}")
28-
29-
"testCompile"("org.junit.jupiter:junit-jupiter-api:${Versions.jupiter}")
30-
"testCompile"("org.junit.jupiter:junit-jupiter-params:${Versions.jupiter}")
31-
"testRuntime"("org.junit.jupiter:junit-jupiter-engine:${Versions.jupiter}")
32-
33-
"testImplementation"("org.jetbrains.kotlin:kotlin-test")
34-
35-
"testImplementation"("com.github.komputing:khex:0.6")
36-
}
37-
38-
tasks.withType<Test> {
39-
useJUnitPlatform()
40-
testLogging {
41-
events("passed", "skipped", "failed")
15+
afterEvaluate {
16+
tasks.withType<AbstractTestTask> {
17+
finalizedBy(testAggregateReport)
4218
}
4319
}
44-
45-
repositories {
46-
jcenter()
47-
maven("https://jitpack.io")
48-
maven("https://kotlin.bintray.com/kotlinx")
49-
}
5020
}

buildSrc/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
idea
33
`kotlin-dsl`
4+
`kotlin-dsl-precompiled-script-plugins`
45
}
56

67
repositories {
@@ -12,4 +13,9 @@ idea {
1213
isDownloadJavadoc = false
1314
isDownloadSources = false
1415
}
16+
}
17+
18+
dependencies {
19+
implementation(kotlin("gradle-plugin", "${property("kgp")}"))
20+
implementation("com.github.ben-manes", "gradle-versions-plugin", "${property("plugin.com.github.ben-manes.versions")}")
1521
}

buildSrc/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../gradle.properties
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
object Versions {
2-
const val kotlin = "1.3.71"
3-
const val versions_plugin = "0.28.0"
4-
const val jupiter = "5.6.1"
2+
const val khex = "1.1.0"
3+
const val bignum = "0.2.8"
54
}

0 commit comments

Comments
 (0)