Compare commits

..

2 commits

Author SHA1 Message Date
27070dc3d9
Add OS matrix for Ubuntu, Windows and macOS 2025-03-26 01:01:18 -07:00
686174b9cb
Add debug logging 2025-03-26 00:49:27 -07:00
7 changed files with 53 additions and 11 deletions

View file

@ -9,12 +9,13 @@ env:
jobs: jobs:
build-bld-project: build-bld-project:
runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
java-version: [17, 21, 24] java-version: [17, 21, 24]
kotlin-version: [1.9.25, 2.1.20] kotlin-version: [1.9.25, 2.1.20]
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout source repository - name: Checkout source repository
@ -28,6 +29,24 @@ jobs:
distribution: "zulu" distribution: "zulu"
java-version: ${{ matrix.java-version }} java-version: ${{ matrix.java-version }}
- name: Download dependencies [bld example]
working-directory: examples/bld
run: ./bld download
- name: Compile and run [bld examples]
working-directory: examples/bld
run: |
./bld compile run
./bld run-java
- name: Run example [bld examples]
working-directory: examples/gradle
if: matrix.java-version != '24'
run: |
./gradlew run
./gradlew runJava
- name: Download dependencies - name: Download dependencies
run: ./bld download run: ./bld download
@ -39,11 +58,12 @@ jobs:
- name: Remove pom.xml - name: Remove pom.xml
if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN
run: rm -rf pom.xml run: rm -rf pom.xmlAdd debug logging
- name: SonarCloud Scan - name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master uses: sonarsource/sonarcloud-github-action@master
if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN
&& martix.os == 'unbuntu-latest'
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

View file

@ -1,7 +1,7 @@
bld.downloadExtensionJavadoc=false bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true bld.downloadExtensionSources=true
bld.downloadLocation= bld.downloadLocation=
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.4 bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories= bld.sourceDirectories=
bld.version=2.2.1 bld.version=2.2.1

View file

@ -15,7 +15,7 @@ repositories {
} }
dependencies { dependencies {
implementation("net.thauvin.erik:cryptoprice:1.0.2") implementation("net.thauvin.erik:cryptoprice:1.0.3-SNAPSHOT")
implementation("org.json:json:20240303") implementation("org.json:json:20240303")
} }

View file

@ -1,10 +1,10 @@
bld.downloadExtensionJavadoc=false bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true bld.downloadExtensionSources=true
bld.downloadLocation= bld.downloadLocation=
bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.9 bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.10-SNAPSHOT
bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.3 bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.4-SNAPSHOT
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.9 bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10-SNAPSHOT
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.4 bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories= bld.sourceDirectories=
bld.version=2.2.1 bld.version=2.2.1

View file

@ -121,10 +121,9 @@ public class CryptoPriceBuild extends Project {
@BuildCommand(summary = "Compiles the Kotlin project") @BuildCommand(summary = "Compiles the Kotlin project")
@Override @Override
public void compile() throws Exception { public void compile() throws Exception {
final var options = new CompileOptions().jvmOptions("--enable-native-access=ALL-UNNAMED");
new CompileKotlinOperation() new CompileKotlinOperation()
.fromProject(this) .fromProject(this)
.compileOptions(options) .compileOptions(new CompileOptions().verbose(true))
.execute(); .execute();
} }

View file

@ -42,6 +42,8 @@ import java.math.BigDecimal
import java.text.NumberFormat import java.text.NumberFormat
import java.time.LocalDate import java.time.LocalDate
import java.util.* import java.util.*
import java.util.logging.Level
import java.util.logging.Logger
/** /**
* Retrieves and holds a cryptocurrency price. * Retrieves and holds a cryptocurrency price.
@ -57,6 +59,9 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
// Coinbase API URL // Coinbase API URL
private const val COINBASE_API_URL = "https://api.coinbase.com/v2/" private const val COINBASE_API_URL = "https://api.coinbase.com/v2/"
/** The logger instance. **/
val logger: Logger by lazy { Logger.getLogger(CryptoPrice::class.java.simpleName) }
/** /**
* Converts JSON data object to [CryptoPrice]. * Converts JSON data object to [CryptoPrice].
* *
@ -105,6 +110,9 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
id = "empty_response", id = "empty_response",
message = "Empty response." message = "Empty response."
) )
if (logger.isLoggable(Level.FINE)) {
logger.fine(body)
}
try { try {
val json = JSONObject(body) val json = JSONObject(body)
if (response.isSuccessful) { if (response.isSuccessful) {

View file

@ -42,9 +42,12 @@ import net.thauvin.erik.crypto.CryptoPrice.Companion.sellPrice
import net.thauvin.erik.crypto.CryptoPrice.Companion.spotPrice import net.thauvin.erik.crypto.CryptoPrice.Companion.spotPrice
import net.thauvin.erik.crypto.CryptoPrice.Companion.toPrice import net.thauvin.erik.crypto.CryptoPrice.Companion.toPrice
import org.json.JSONObject import org.json.JSONObject
import org.junit.jupiter.api.BeforeAll
import java.math.BigDecimal import java.math.BigDecimal
import java.time.LocalDate import java.time.LocalDate
import java.util.* import java.util.*
import java.util.logging.ConsoleHandler
import java.util.logging.Level
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith import kotlin.test.assertFailsWith
@ -239,4 +242,16 @@ class CryptoPriceTest {
assertEquals(json, price.toString(), "toString()") assertEquals(json, price.toString(), "toString()")
assertEquals(price.toString(), price.toJson(""), "toString() = toJson('')") assertEquals(price.toString(), price.toJson(""), "toString() = toJson('')")
} }
companion object {
@JvmStatic
@BeforeAll
fun beforeAll() {
with(CryptoPrice.logger) {
addHandler(ConsoleHandler().apply { level = Level.FINE })
level = Level.FINE
useParentHandlers = false
}
}
}
} }