Skip to content

Commit 6c5ed26

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 2df1e71 + 1ab22d2 commit 6c5ed26

File tree

107 files changed

+2220
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+2220
-363
lines changed

.github/workflows/pull-request.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ jobs:
2424
cache: 'gradle'
2525

2626
- name: Build, run tests and upload dev snapshot to Maven Central with Gradle
27-
run: ./gradlew devSnapshot printDevSnapshotReleaseNote
27+
run: |
28+
./gradlew devSnapshot printDevSnapshotReleaseNote printSanitizedVersion
29+
cat sanitized_version.md >> $GITHUB_STEP_SUMMARY
2830
env:
2931
STORE_ID: ${{ secrets.STORE_ID }}
3032
API_TOKEN: ${{ secrets.API_TOKEN }}
@@ -34,9 +36,10 @@ jobs:
3436
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
3537
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
3638
GITHUB_HEAD_REF: ${{ github.head_ref }}
39+
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
3740

3841
- name: Upload artifacts with checks results
39-
uses: actions/upload-artifact@v3
42+
uses: actions/upload-artifact@v4
4043
if: failure()
4144
with:
4245
name: check-results
@@ -45,7 +48,7 @@ jobs:
4548
${{ github.workspace }}/build/reports/detekt/detekt.html
4649
4750
- name: Upload static analysis results
48-
uses: github/codeql-action/upload-sarif@v2
51+
uses: github/codeql-action/upload-sarif@v3
4952
if: always()
5053
with:
5154
sarif_file: ${{ github.workspace }}/build/reports/detekt/detekt.sarif

.github/workflows/push-to-master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
GRGIT_PASS: ${{ secrets.GRGIT_PASS }}
3838

3939
- name: Upload static analysis results
40-
uses: github/codeql-action/upload-sarif@v2
40+
uses: github/codeql-action/upload-sarif@v3
4141
if: always()
4242
with:
4343
sarif_file: ${{ github.workspace }}/build/reports/detekt/detekt.sarif

build.gradle.kts

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies {
2626

2727
api("com.google.code.gson:gson:2.10")
2828
api("org.apache.httpcomponents:httpclient:4.5.13")
29+
api("org.apache.httpcomponents.client5:httpclient5:5.5")
2930
api("io.prometheus:prometheus-metrics-core:1.1.0")
3031

3132
testImplementation(kotlin("test"))
@@ -127,6 +128,12 @@ tasks.register(Tasks.PRINT_DEV_SNAPSHOT_RELEASE_NOTE_TASK_NAME) {
127128
dependsOn(tasks.getByName("devSnapshot"))
128129
}
129130

131+
tasks.register(Tasks.PRINT_SUMMARY_SANITIZED_TASK_NAME) {
132+
doLast {
133+
printSanitizedVersion(project.sanitizeVersion())
134+
}
135+
}
136+
130137
detekt {
131138
allRules = false
132139
basePath = "$projectDir"
@@ -200,6 +207,8 @@ nexusPublishing {
200207
useStaging.set(!project.isSnapshotVersion())
201208
packageGroup.set(PublicationSettings.STAGING_PACKAGE_GROUP)
202209
stagingProfileId.set(PublicationSettings.STAGING_PROFILE_ID)
210+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
211+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
203212
username.set(settingsProvider.ossrhUsername)
204213
password.set(settingsProvider.ossrhPassword)
205214
}
@@ -210,15 +219,16 @@ nexusPublishing {
210219
// <major>.<minor>.<patch>-dev.#+<branchname>.<hash> (local branch)
211220
// <major>.<minor>.<patch>-dev.#+<hash> (github pull request)
212221
// to:
213-
// <major>.<minor>.<patch>-dev+<branchname>-SNAPSHOT
222+
// <major>.<minor>.<patch>-dev+<branchname>_<hash>-SNAPSHOT
214223
fun Project.sanitizeVersion(): String {
215224
val version = version.toString()
216225
return if (project.isSnapshotVersion()) {
217226
val githubHeadRef = settingsProvider.githubHeadRef
227+
val githubHeadSHA = settingsProvider.githubHeadSHA?.take(Consts.MAX_HEAD_SHA_LENGTH)
218228
if (githubHeadRef != null) {
219229
// github pull request
220230
version
221-
.replace(Regex("-dev\\.\\d+\\+[a-f0-9]+$"), "-dev+$githubHeadRef-SNAPSHOT")
231+
.replace(Regex("-dev\\.\\d+\\+[a-f0-9]+$"), "-dev+${githubHeadRef}_$githubHeadSHA-SNAPSHOT")
222232
} else {
223233
// local branch
224234
version
@@ -244,12 +254,6 @@ fun printFinalReleaseNote(groupId: String, artifactId: String, sanitizedVersion:
244254
println("Discover on Maven Central:")
245255
println(" https://repo1.maven.org/maven2/${groupId.replace('.', '/')}/$artifactId/")
246256
println()
247-
println("Edit or delete artifacts on OSS Nexus Repository Manager:")
248-
println(" https://oss.sonatype.org/#nexus-search;gav~$groupId~~~~")
249-
println()
250-
println("Control staging repositories on OSS Nexus Repository Manager:")
251-
println(" https://oss.sonatype.org/#stagingRepositories")
252-
println()
253257
println("========================================================")
254258
println()
255259
}
@@ -264,15 +268,22 @@ fun printDevSnapshotReleaseNote(groupId: String, artifactId: String, sanitizedVe
264268
println(" version: $sanitizedVersion")
265269
println()
266270
println("Discover on Maven Central:")
267-
println(" https://oss.sonatype.org/content/groups/public/${groupId.replace('.', '/')}/$artifactId/")
268-
println()
269-
println("Edit or delete artifacts on OSS Nexus Repository Manager:")
270-
println(" https://oss.sonatype.org/#nexus-search;gav~$groupId~~~~")
271+
println(" https://central.sonatype.com/repository/maven-snapshots/${groupId.replace('.', '/')}/$artifactId/$sanitizedVersion/maven-metadata.xml")
271272
println()
272273
println("========================================================")
273274
println()
274275
}
275276

277+
fun printSanitizedVersion(sanitizedVersion: String) {
278+
val markdownMessage = """
279+
|## Sanitized Version
280+
|
281+
|**Version:** $sanitizedVersion
282+
|
283+
""".trimMargin()
284+
File("sanitized_version.md").writeText(markdownMessage)
285+
}
286+
276287
class SettingsProvider {
277288

278289
val gpgSigningKey: String?
@@ -290,6 +301,9 @@ class SettingsProvider {
290301
val githubHeadRef: String?
291302
get() = System.getenv(GITHUB_HEAD_REF_PROPERTY)
292303

304+
val githubHeadSHA: String?
305+
get() = System.getenv(GITHUB_HEAD_SHA_PROPERTY)
306+
293307
fun validateGPGSecrets() = require(
294308
value = !gpgSigningKey.isNullOrBlank() && !gpgSigningPassword.isNullOrBlank(),
295309
lazyMessage = {
@@ -310,6 +324,7 @@ class SettingsProvider {
310324
private const val OSSRH_USERNAME_PROPERTY = "OSSRH_USERNAME"
311325
private const val OSSRH_PASSWORD_PROPERTY = "OSSRH_PASSWORD"
312326
private const val GITHUB_HEAD_REF_PROPERTY = "GITHUB_HEAD_REF"
327+
private const val GITHUB_HEAD_SHA_PROPERTY = "GITHUB_HEAD_SHA"
313328
}
314329
}
315330

@@ -339,9 +354,11 @@ object PublicationSettings {
339354
object Consts {
340355
const val SLOW_TESTS_LOGGING_THRESHOLD_MS = 30_000L
341356
const val MAX_TEST_RETRIES_COUNT = 3
357+
const val MAX_HEAD_SHA_LENGTH = 8
342358
}
343359

344360
object Tasks {
345361
const val PRINT_FINAL_RELEASE_NOTE_TASK_NAME = "printFinalReleaseNote"
346362
const val PRINT_DEV_SNAPSHOT_RELEASE_NOTE_TASK_NAME = "printDevSnapshotReleaseNote"
363+
const val PRINT_SUMMARY_SANITIZED_TASK_NAME = "printDevSanitizedVersion"
347364
}

src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import com.ecwid.apiclient.v3.dto.customer.request.*
2424
import com.ecwid.apiclient.v3.dto.customer.result.*
2525
import com.ecwid.apiclient.v3.dto.customergroup.request.*
2626
import com.ecwid.apiclient.v3.dto.customergroup.result.*
27+
import com.ecwid.apiclient.v3.dto.images.request.ImagesMainColorsRequest
28+
import com.ecwid.apiclient.v3.dto.images.result.FetchedImagesMainColorsResult
2729
import com.ecwid.apiclient.v3.dto.instantsite.redirects.request.*
2830
import com.ecwid.apiclient.v3.dto.instantsite.redirects.result.*
29-
import com.ecwid.apiclient.v3.dto.order.request.*
30-
import com.ecwid.apiclient.v3.dto.order.result.*
3131
import com.ecwid.apiclient.v3.dto.productreview.request.*
3232
import com.ecwid.apiclient.v3.dto.productreview.result.*
3333
import com.ecwid.apiclient.v3.dto.producttype.request.*
@@ -45,16 +45,20 @@ import com.ecwid.apiclient.v3.dto.storage.result.*
4545
import com.ecwid.apiclient.v3.dto.subscriptions.request.SubscriptionsSearchRequest
4646
import com.ecwid.apiclient.v3.dto.subscriptions.result.FetchedSubscription
4747
import com.ecwid.apiclient.v3.dto.subscriptions.result.SubscriptionsSearchResult
48+
import com.ecwid.apiclient.v3.dto.swatches.request.RecentSwatchColorsGetRequest
49+
import com.ecwid.apiclient.v3.dto.swatches.result.FetchedSwatchColorsResult
4850
import com.ecwid.apiclient.v3.dto.variation.request.*
4951
import com.ecwid.apiclient.v3.dto.variation.result.*
5052
import com.ecwid.apiclient.v3.httptransport.HttpTransport
5153
import com.ecwid.apiclient.v3.impl.*
5254
import com.ecwid.apiclient.v3.jsontransformer.JsonTransformerProvider
55+
import java.io.Closeable
5356
import kotlin.reflect.KClass
5457

5558
open class ApiClient private constructor(
5659
protected val apiClientHelper: ApiClientHelper,
5760
storeProfileApiClient: StoreProfileApiClient,
61+
brandsApiClient: BrandsApiClient,
5862
productsApiClient: ProductsApiClient,
5963
categoriesApiClient: CategoriesApiClient,
6064
ordersApiClient: OrdersApiClient,
@@ -74,8 +78,11 @@ open class ApiClient private constructor(
7478
slugInfoApiClient: SlugInfoApiClientImpl,
7579
productReviewsApiClient: ProductReviewsApiClientImpl,
7680
storeExtrafieldsApiClient: StoreExtrafieldsApiClientImpl,
81+
swatchesApiClient: SwatchesApiClientImpl,
82+
imagesApiClient: ImagesApiClientImpl,
7783
) :
7884
StoreProfileApiClient by storeProfileApiClient,
85+
BrandsApiClient by brandsApiClient,
7986
ProductsApiClient by productsApiClient,
8087
CategoriesApiClient by categoriesApiClient,
8188
OrdersApiClient by ordersApiClient,
@@ -94,11 +101,15 @@ open class ApiClient private constructor(
94101
InstantSiteRedirectsApiClient by instantSiteRedirectsApiClient,
95102
SlugInfoApiClient by slugInfoApiClient,
96103
ProductReviewsApiClient by productReviewsApiClient,
97-
StoreExtrafieldsApiClient by storeExtrafieldsApiClient {
104+
StoreExtrafieldsApiClient by storeExtrafieldsApiClient,
105+
SwatchesApiClient by swatchesApiClient,
106+
ImagesApiClient by imagesApiClient,
107+
Closeable {
98108

99109
constructor(apiClientHelper: ApiClientHelper) : this(
100110
apiClientHelper = apiClientHelper,
101111
storeProfileApiClient = StoreProfileApiClientImpl(apiClientHelper),
112+
brandsApiClient = BrandsApiClientImpl(apiClientHelper),
102113
productsApiClient = ProductsApiClientImpl(apiClientHelper),
103114
categoriesApiClient = CategoriesApiClientImpl(apiClientHelper),
104115
ordersApiClient = OrdersApiClientImpl(apiClientHelper),
@@ -118,8 +129,14 @@ open class ApiClient private constructor(
118129
slugInfoApiClient = SlugInfoApiClientImpl(apiClientHelper),
119130
productReviewsApiClient = ProductReviewsApiClientImpl(apiClientHelper),
120131
storeExtrafieldsApiClient = StoreExtrafieldsApiClientImpl(apiClientHelper),
132+
swatchesApiClient = SwatchesApiClientImpl(apiClientHelper),
133+
imagesApiClient = ImagesApiClientImpl(apiClientHelper),
121134
)
122135

136+
override fun close() {
137+
apiClientHelper.httpTransport.close()
138+
}
139+
123140
companion object {
124141

125142
fun create(
@@ -315,3 +332,12 @@ interface ProductReviewsApiClient {
315332
fun massUpdateProductReview(request: ProductReviewMassUpdateRequest): ProductReviewMassUpdateResult
316333
fun getProductReviewsFiltersData(request: ProductReviewFiltersDataRequest): ProductReviewFiltersDataResult
317334
}
335+
336+
// Swatches
337+
interface SwatchesApiClient {
338+
fun getRecentSwatchColors(request: RecentSwatchColorsGetRequest): FetchedSwatchColorsResult
339+
}
340+
341+
interface ImagesApiClient {
342+
fun getImagesMainColors(request: ImagesMainColorsRequest): FetchedImagesMainColorsResult
343+
}

0 commit comments

Comments
 (0)