Skip to content

Commit

Permalink
Merge pull request #589 from hexagonkt/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jaguililla committed Dec 30, 2022
2 parents 14f03e4 + 440b360 commit 8bcf792
Show file tree
Hide file tree
Showing 43 changed files with 105 additions and 147 deletions.
19 changes: 9 additions & 10 deletions .github/actions/gradle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,30 @@ inputs:
required: true
default: "17"

java_distribution:
description: Java distribution used to run Gradle.
required: true
default: temurin

tasks:
description: Gradle tasks to execute.
required: true
default: build

token:
description: Token used to install GraalVM.
required: true

runs:
using: composite
steps:

# SET UP
- uses: graalvm/setup-graalvm@v1
- uses: actions/setup-java@v3
with:
version: latest
java-version: ${{ inputs.java }}
github-token: ${{ inputs.token }}
components: native-image,llvm
distribution: ${{ inputs.java_distribution }}
cache: gradle

# PROCESS
- run: ./gradlew -Pagent ${{ inputs.tasks }}
- run: ./gradlew ${{ inputs.tasks }}
shell: bash
- if: failure()
run: ./gradlew --info --stacktrace -Pagent ${{ inputs.tasks }}
run: ./gradlew --info --stacktrace ${{ inputs.tasks }}
shell: bash
9 changes: 0 additions & 9 deletions .github/agent_filter.json

This file was deleted.

38 changes: 3 additions & 35 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ on:
- cron: "59 23 * * *"

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v6
with:
exempt-issue-labels: pinned
include-only-assigned: true
days-before-stale: 90
days-before-close: 14
days-before-pr-close: -1
stale-pr-message: This PR is stale because it has been open 45 days with no activity.
stale-issue-message:
"This issue is stale because it has been open 90 days with no activity. Remove stale
label or comment or this will be closed in 14 days."
close-issue-message:
"This issue was closed because it has been stalled for 14 days with no activity."

build:
defaults:
run: { shell: bash }
Expand All @@ -39,8 +22,6 @@ jobs:
with: { ref: develop }
- name: Build Project
uses: ./.github/actions/gradle
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check Build
run: ls -AlF core/build

Expand All @@ -61,7 +42,6 @@ jobs:
- name: Create Sample Keystores
uses: ./.github/actions/gradle
with:
token: ${{ secrets.GITHUB_TOKEN }}
tasks: createCa createIdentities

build_site:
Expand All @@ -87,8 +67,6 @@ jobs:
# PROCESS
- name: Build Project
uses: ./.github/actions/gradle
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Site
run: |
./gradlew --info -x build buildSite
Expand All @@ -108,17 +86,7 @@ jobs:
- name: Check Out
uses: actions/checkout@v3
with: { ref: develop }
- name: Install Java
uses: graalvm/setup-graalvm@v1
with:
version: latest
java-version: 17
github-token: ${{ secrets.GITHUB_TOKEN }}
components: native-image,llvm
cache: gradle

- name: Test Publishing
run: |
./gradlew --info -x test -Pagent build
[[ $graalvm_metadata == true ]] && ./gradlew --info -x test metadataCopy
./gradlew --info -x test publishToMavenLocal
uses: ./.github/actions/gradle
with:
tasks: publishToMavenLocal -x test
29 changes: 14 additions & 15 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ on:
- pull_request

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v3
- name: Build Project
uses: ./.github/actions/gradle
- name: Check Build
run: ls -AlF core/build

sample_keystores:
name: Sample Keystores
runs-on: ubuntu-latest
Expand All @@ -14,7 +25,6 @@ jobs:
- name: Create Sample Keystores
uses: ./.github/actions/gradle
with:
token: ${{ secrets.GITHUB_TOKEN }}
tasks: createCa createIdentities

build_site:
Expand All @@ -39,8 +49,6 @@ jobs:
# PROCESS
- name: Build Project
uses: ./.github/actions/gradle
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Site
run: |
./gradlew --info -x build buildSite
Expand All @@ -52,16 +60,7 @@ jobs:
steps:
- name: Check Out
uses: actions/checkout@v3
- name: Install Java
uses: graalvm/setup-graalvm@v1
with:
version: latest
java-version: 17
github-token: ${{ secrets.GITHUB_TOKEN }}
components: native-image,llvm
cache: gradle
- name: Test Publishing
run: |
./gradlew --info -x test -Pagent build
[[ $graalvm_metadata == true ]] && ./gradlew --info -x test metadataCopy
./gradlew --info -x test publishToMavenLocal
uses: ./.github/actions/gradle
with:
tasks: publishToMavenLocal -x test
2 changes: 0 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ jobs:
uses: actions/checkout@v3
- name: Build Project
uses: ./.github/actions/gradle
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check Build
run: ls -AlF core/build
15 changes: 1 addition & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
push:
branches: [ master ]

env:
graalvm_metadata: false

jobs:
sample_keystores:
name: Sample Keystores
Expand All @@ -18,7 +15,6 @@ jobs:
- name: Create Sample Keystores
uses: ./.github/actions/gradle
with:
token: ${{ secrets.GITHUB_TOKEN }}
tasks: createCa createIdentities

publish:
Expand All @@ -30,14 +26,6 @@ jobs:
# SET UP
- name: Check Out
uses: actions/checkout@v3
- name: Install Java
uses: graalvm/setup-graalvm@v1
with:
version: latest
java-version: 17
github-token: ${{ secrets.GITHUB_TOKEN }}
components: native-image,llvm
cache: gradle
- name: Install ImageMagick
uses: ./.github/actions/image_magick
- name: Restore Cache
Expand All @@ -59,7 +47,7 @@ jobs:
git config --global user.email "juanjoaguililla@gmail.com"
git config --global user.name "jaguililla"
git clone "$REMOTE" --branch gh-pages build/gh-pages
./gradlew --info -Pagent build
./gradlew --info build
./gradlew --info -x build buildSite
ls -AlF site/build/site
Expand All @@ -70,7 +58,6 @@ jobs:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
run: |
[[ $graalvm_metadata == true ]] && ./gradlew --info --no-daemon -x test metadataCopy
./gradlew --info --no-daemon -x test release
- name: Publish Site
Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/release_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
push:
branches: [ release/** ]

env:
graalvm_metadata: false

jobs:
sample_keystores:
name: Sample Keystores
Expand All @@ -18,7 +15,6 @@ jobs:
- name: Create Sample Keystores
uses: ./.github/actions/gradle
with:
token: ${{ secrets.GITHUB_TOKEN }}
tasks: createCa createIdentities

publish:
Expand All @@ -30,14 +26,6 @@ jobs:
# SET UP
- name: Check Out
uses: actions/checkout@v3
- name: Install Java
uses: graalvm/setup-graalvm@v1
with:
version: latest
java-version: 17
github-token: ${{ secrets.GITHUB_TOKEN }}
components: native-image,llvm
cache: gradle
- name: Install ImageMagick
uses: ./.github/actions/image_magick
- name: Restore Cache
Expand All @@ -58,7 +46,7 @@ jobs:
git remote set-url origin "$REMOTE"
git config --global user.email "juanjoaguililla@gmail.com"
git config --global user.name "jaguililla"
./gradlew --info -Pagent build
./gradlew --info build
./gradlew --info -x build buildSite
- name: Publish Packages
Expand All @@ -68,5 +56,4 @@ jobs:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
run: |
[[ $graalvm_metadata == true ]] && ./gradlew --info --no-daemon -x test metadataCopy
./gradlew --info --no-daemon -x test release
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ plugins {
id("com.github.jk1.dependency-license-report") version("2.1")
id("io.gitlab.arturbosch.detekt") version("1.22.0") apply(false)
id("me.champeau.jmh") version("0.6.8") apply(false)
id("org.graalvm.buildtools.native") version("0.9.19") apply(false)
}

apply(from = "gradle/certificates.gradle")
Expand Down
1 change: 0 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ apply(from = "../gradle/kotlin.gradle")
apply(from = "../gradle/publish.gradle")
apply(from = "../gradle/dokka.gradle")
apply(from = "../gradle/detekt.gradle")
apply(from = "../gradle/native.gradle")

description = "Hexagon core utilities. Includes serialization and logging helpers."

Expand Down
34 changes: 24 additions & 10 deletions core/src/main/kotlin/com/hexagonkt/core/Jvm.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.hexagonkt.core

import java.lang.management.ManagementFactory
import java.lang.management.ManagementFactory.getMemoryMXBean
import java.lang.management.ManagementFactory.getRuntimeMXBean
import java.lang.management.MemoryUsage
import java.lang.management.RuntimeMXBean
import java.net.InetAddress
import java.nio.charset.Charset
import java.util.*
Expand Down Expand Up @@ -30,8 +32,11 @@ object Jvm {
/** The IP address of the machine running this program. */
val ip: String by lazy { InetAddress.getLocalHost().hostAddress }

/** ID representing the running Java virtual machine */
val id: String by lazy { ManagementFactory.getRuntimeMXBean().name }
/**
* ID representing the running Java virtual machine. If the 'java.management' module is not
* available returns `N/A`.
*/
val id: String by lazy { runtime?.name ?: "N/A" }

/** Name of the JVM running this program. For example: OpenJDK 64-Bit Server VM. */
val name: String by lazy { System.getProperty("java.vm.name") }
Expand All @@ -51,28 +56,31 @@ object Jvm {
}

/**
* Amount of memory in kilobytes that the JVM initially requests from the operating system.
* Amount of memory in kilobytes that the JVM initially requests from the operating system. If
* the 'java.management' module is not available returns `N/A`.
*
* @return Initial amount of memory in kilobytes.
*/
fun initialMemory(): String =
"%,d".format(heap.init / 1024)
heap?.let { "%,d".format(it.init / 1024) } ?: "N/A"

/**
* Amount of used memory in kilobytes.
* Amount of used memory in kilobytes. If the 'java.management' module is not available returns
* `N/A`.
*
* @return Used memory in kilobytes.
*/
fun usedMemory(): String =
"%,d".format(heap.used / 1024)
heap?.let { "%,d".format(it.used / 1024) } ?: "N/A"

/**
* Uptime of the Java virtual machine in seconds.
* Uptime of the Java virtual machine in seconds. If the 'java.management' module is not
* available returns `N/A`.
*
* @return JVM uptime in seconds.
*/
fun uptime(): String =
"%01.3f".format(ManagementFactory.getRuntimeMXBean().uptime / 1e3)
runtime?.let { "%01.3f".format(it.uptime / 1e3) } ?: "N/A"

/**
* Retrieve a setting by name by looking in the JVM system properties first and in OS
Expand Down Expand Up @@ -116,7 +124,13 @@ object Jvm {
inline fun <reified T: Any> systemSetting(name: String): T =
systemSetting(T::class, name)

private val heap: MemoryUsage by lazy { ManagementFactory.getMemoryMXBean().heapMemoryUsage }
private val heap: MemoryUsage? by lazy {
try { getMemoryMXBean().heapMemoryUsage } catch (_: NoClassDefFoundError) { null }
}

private val runtime: RuntimeMXBean? by lazy {
try { getRuntimeMXBean() } catch (_: NoClassDefFoundError) { null }
}

private fun systemSettingRaw(name: String): String? {
require(name.isNotBlank()) { "Setting name can not be blank" }
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.warning.mode=all
org.gradle.console=plain

# Gradle
version=2.3.0
version=2.3.1
group=com.hexagonkt
description=The atoms of your platform

Expand Down

0 comments on commit 8bcf792

Please sign in to comment.