Skip to content

Commit

Permalink
Merge pull request #237 from Ecwid/upgrade-deps
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
juvirez authored Nov 29, 2022
2 parents d7ad545 + 464f960 commit 106e9c3
Show file tree
Hide file tree
Showing 30 changed files with 216 additions and 182 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
steps:

- name: Checkout full repository history
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
Expand All @@ -32,7 +32,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build, run tests and upload dev snapshot to Maven Central with Gradle
run: ./gradlew devSnapshot printDevSnapshotReleaseNode
run: ./gradlew devSnapshot printDevSnapshotReleaseNote
env:
STORE_ID: ${{ secrets.STORE_ID }}
API_TOKEN: ${{ secrets.API_TOKEN }}
Expand All @@ -44,7 +44,7 @@ jobs:
GITHUB_HEAD_REF: ${{ github.head_ref }}

- name: Upload artifacts with checks results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: failure()
with:
name: check-results
Expand All @@ -53,7 +53,7 @@ jobs:
${{ github.workspace }}/build/reports/detekt/detekt.html
- name: Upload static analysis results
uses: github/codeql-action/upload-sarif@v1
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: ${{ github.workspace }}/build/reports/detekt/detekt.sarif
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/push-to-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
steps:

- name: Checkout full repository history
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
Expand All @@ -34,7 +34,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build, upload release version to Maven Central and create git release tag with Gradle
run: ./gradlew detekt final closeAndReleaseRepository printFinalReleaseNode
run: ./gradlew detekt final closeAndReleaseRepository printFinalReleaseNote
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }}
Expand All @@ -44,7 +44,7 @@ jobs:
GRGIT_PASS: ${{ secrets.GRGIT_PASS }}

- name: Upload static analysis results
uses: github/codeql-action/upload-sarif@v1
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: ${{ github.workspace }}/build/reports/detekt/detekt.sarif
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ src/test/resources/test.properties

# Files created by github actions before workflow job run
# Task `gradle release` requires that git reposoitary to be clean
settings.xml
settings.xml
toolchains.xml
38 changes: 23 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
java
signing
kotlin("jvm") version "1.5.32"
id("com.adarshr.test-logger") version "2.1.1"
id("io.codearte.nexus-staging") version "0.22.0"
kotlin("jvm") version "1.7.21"
id("com.adarshr.test-logger") version "3.2.0"
id("io.codearte.nexus-staging") version "0.30.0"
id("nebula.release") version "17.1.0"
id("maven-publish")
id("io.gitlab.arturbosch.detekt") version "1.17.1"
id("io.gitlab.arturbosch.detekt") version "1.22.0"
id("org.gradle.test-retry") version "1.4.1"
}

Expand All @@ -24,14 +24,14 @@ dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))

api("com.google.code.gson:gson:2.8.6")
api("com.google.code.gson:gson:2.10")
api("org.apache.httpcomponents:httpclient:4.5.13")

testImplementation("org.junit.jupiter:junit-jupiter:5.7.0")
testImplementation("org.reflections:reflections:0.9.11")
testImplementation("uk.co.jemos.podam:podam:7.2.6.RELEASE")
testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
testImplementation("org.reflections:reflections:0.10.2")
testImplementation("uk.co.jemos.podam:podam:7.2.11.RELEASE")

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.17.1")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0")
}

configure<JavaPluginConvention> {
Expand Down Expand Up @@ -87,6 +87,7 @@ tasks.withType<Sign> {
doFirst {
settingsProvider.validateGPGSecrets()
}
dependsOn(tasks.getByName("build"))
}

tasks.withType<PublishToMavenRepository> {
Expand All @@ -95,24 +96,26 @@ tasks.withType<PublishToMavenRepository> {
}
}

tasks.register("printFinalReleaseNode") {
tasks.register(Tasks.PRINT_FINAL_RELEASE_NOTE_TASK_NAME) {
doLast {
printFinalReleaseNode(
printFinalReleaseNote(
groupId = PublicationSettings.GROUP_ID,
artifactId = PublicationSettings.ARTIFACT_ID,
sanitizedVersion = project.sanitizeVersion()
)
}
dependsOn(tasks.getByName("final"))
}

tasks.register("printDevSnapshotReleaseNode") {
tasks.register(Tasks.PRINT_DEV_SNAPSHOT_RELEASE_NOTE_TASK_NAME) {
doLast {
printDevSnapshotReleaseNode(
printDevSnapshotReleaseNote(
groupId = PublicationSettings.GROUP_ID,
artifactId = PublicationSettings.ARTIFACT_ID,
sanitizedVersion = project.sanitizeVersion()
)
}
dependsOn(tasks.getByName("devSnapshot"))
}

detekt {
Expand Down Expand Up @@ -227,7 +230,7 @@ fun Project.sanitizeVersion(): String {

fun Project.isSnapshotVersion() = version.toString().contains("-dev.")

fun printFinalReleaseNode(groupId: String, artifactId: String, sanitizedVersion: String) {
fun printFinalReleaseNote(groupId: String, artifactId: String, sanitizedVersion: String) {
println()
println("========================================================")
println()
Expand All @@ -249,7 +252,7 @@ fun printFinalReleaseNode(groupId: String, artifactId: String, sanitizedVersion:
println()
}

fun printDevSnapshotReleaseNode(groupId: String, artifactId: String, sanitizedVersion: String) {
fun printDevSnapshotReleaseNote(groupId: String, artifactId: String, sanitizedVersion: String) {
println()
println("========================================================")
println()
Expand Down Expand Up @@ -330,3 +333,8 @@ object Consts {
const val SLOW_TESTS_LOGGING_THRESHOLD_MS = 30_000L
const val MAX_TEST_RETRIES_COUNT = 3
}

object Tasks {
const val PRINT_FINAL_RELEASE_NOTE_TASK_NAME = "printFinalReleaseNote"
const val PRINT_DEV_SNAPSHOT_RELEASE_NOTE_TASK_NAME = "printDevSnapshotReleaseNote"
}
14 changes: 8 additions & 6 deletions config/detekt.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
complexity:
ComplexMethod:
CyclomaticComplexMethod:
threshold: 40
LargeClass:
excludes: ['**/test/**']
excludes: [ '**/test/**' ]
LongMethod:
threshold: 100
excludes: ['**/test/**']
excludes: [ '**/test/**' ]
LongParameterList:
functionThreshold: 10
constructorThreshold: 15
excludes: ['**/com/ecwid/apiclient/v3/ApiClient.kt']
excludes: [ '**/com/ecwid/apiclient/v3/ApiClient.kt' ]
NestedBlockDepth:
excludes: ['**/test/**']
excludes: [ '**/test/**' ]
TooManyFunctions:
thresholdInFiles: 50
thresholdInClasses: 50
Expand All @@ -29,14 +29,16 @@ style:
ReturnCount:
max: 5
UnnecessaryAbstractClass:
excludes: ['**/test/**']
excludes: [ '**/test/**' ]
WildcardImport:
active: false

# ktlint rules
formatting:
MaximumLineLength:
maxLineLength: 180
EnumEntryNameCase:
active: false # We need to fix all enums before enabling this inspection
# Initially enabled
NoBlankLineBeforeRbrace:
active: false
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
14 changes: 8 additions & 6 deletions src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ interface StoreProfileApiClient {
fun getStoreProfile(request: StoreProfileRequest): FetchedStoreProfile
fun updateStoreProfile(request: StoreProfileUpdateRequest): StoreProfileUpdateResult
fun getLatestStats(request: LatestStatsRequest): FetchedLatestStats
fun getShippingOptions(request: ShippingOptionsRequest): ShippingOptionsResult
// fun addShippingOption()
// fun updateShippingOption()
fun getPaymentOptions(request: PaymentOptionsRequest): PaymentOptionsResult
// fun addPaymentOption()
// fun updatePaymentOption()
fun getShippingOptions(request: ShippingOptionsRequest): ShippingOptionsResult

// fun addShippingOption()
// fun updateShippingOption()
fun getPaymentOptions(request: PaymentOptionsRequest): PaymentOptionsResult

// fun addPaymentOption()
// fun updatePaymentOption()
fun uploadStoreLogo(request: StoreLogoUploadRequest): StoreLogoUploadResult
fun removeStoreLogo(request: StoreLogoRemoveRequest): StoreLogoRemoveResult
fun uploadInvoiceLogo(request: InvoiceLogoUploadRequest): InvoiceLogoUploadResult
Expand Down
12 changes: 11 additions & 1 deletion src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,16 @@ class ApiClientHelper private constructor(
)
}
}

is HttpResponse.Error -> {
try {
val responseBody = responseBytes.asString()
logErrorResponseIfNeeded(requestId, requestTime, httpResponse.statusCode, responseBody)
val ecwidError = if (responseBody.isNotBlank()) {
jsonTransformer.deserialize(responseBody, EcwidApiError::class.java)
} else null
} else {
null
}
throw EcwidApiException(
statusCode = httpResponse.statusCode,
reasonPhrase = httpResponse.reasonPhrase,
Expand All @@ -151,6 +154,7 @@ class ApiClientHelper private constructor(
)
}
}

is HttpResponse.TransportError -> {
logTransportErrorResponseIfNeeded(
requestId,
Expand Down Expand Up @@ -196,16 +200,19 @@ class ApiClientHelper private constructor(
uri = createApiEndpointUri(pathSegments),
params = params.withCredentialsParams(credentials)
)

HttpMethod.POST -> HttpRequest.HttpPostRequest(
uri = createApiEndpointUri(pathSegments),
params = params.withCredentialsParams(credentials),
transportHttpBody = httpBody.prepare(jsonTransformer)
)

HttpMethod.PUT -> HttpRequest.HttpPutRequest(
uri = createApiEndpointUri(pathSegments),
params = params.withCredentialsParams(credentials),
transportHttpBody = httpBody.prepare(jsonTransformer)
)

HttpMethod.DELETE -> HttpRequest.HttpDeleteRequest(
uri = createApiEndpointUri(pathSegments),
params = params.withCredentialsParams(credentials)
Expand Down Expand Up @@ -393,12 +400,15 @@ internal fun HttpBody.prepare(jsonTransformer: JsonTransformer): TransportHttpBo
val bodyAsBytes = jsonTransformer.serialize(obj, objExt).toByteArray()
TransportHttpBody.ByteArrayBody(bodyAsBytes, MIME_TYPE_APPLICATION_JSON)
}

is HttpBody.ByteArrayBody -> {
TransportHttpBody.ByteArrayBody(bytes, mimeType)
}

is HttpBody.InputStreamBody -> {
TransportHttpBody.InputStreamBody(stream, mimeType)
}

is HttpBody.LocalFileBody -> {
TransportHttpBody.LocalFileBody(file, mimeType)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ private data class SingleBatchRequest(
is HttpBody.EmptyBody -> {
null
}

is HttpBody.JsonBody -> {
requestInfo.httpBody.obj
}

is HttpBody.ByteArrayBody,
is HttpBody.InputStreamBody,
is HttpBody.LocalFileBody -> {
throw IllegalStateException("Request type ${requestInfo.httpBody.javaClass.simpleName} is not allowed in batch requests")
error("Request type ${requestInfo.httpBody.javaClass.simpleName} is not allowed in batch requests")
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data class FetchedCategory(

val hdThumbnailUrl: String? = null,
val thumbnailUrl: String? = null,
val imageUrl: String? = null, // TODO Cannot test due to bug https://track.ecwid.com/youtrack/issue/ECWID-53222
val imageUrl: String? = null, // TODO Cannot test due to bug https://track.ecwid.com/youtrack/issue/ECWID-53222
val originalImageUrl: String? = null,
val originalImage: PictureInfo? = null,
val url: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,25 +290,4 @@ data class CustomAppRequest(
val height: Double? = null
)

fun forLogging(): CustomAppRequest {
return this.copy(merchantAppSettings = merchantAppSettings?.let {
MerchantAppSettings(it.map { (key, value) -> key to formatSettingValue(key, value) }.toMap())
})
}

private fun formatSettingValue(key: String, value: String): String {
if (key == STORAGE_PUBLIC_CONFIG_KEY) {
return value
}
if (value.length <= 2) {
return SECRET_KEYS_PLACEHOLDER
}
return value.first() + SECRET_KEYS_PLACEHOLDER + value.last()
}

companion object {
private const val STORAGE_PUBLIC_CONFIG_KEY = "public"
private const val SECRET_KEYS_PLACEHOLDER = "XXX"
}

}
Loading

0 comments on commit 106e9c3

Please sign in to comment.