Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:
cache: 'gradle'

- name: Build, run tests and upload dev snapshot to Maven Central with Gradle
run: ./gradlew devSnapshot printDevSnapshotReleaseNote
run: |
./gradlew devSnapshot printDevSnapshotReleaseNote printSanitizedVersion
cat sanitized_version.md >> $GITHUB_STEP_SUMMARY
env:
STORE_ID: ${{ secrets.STORE_ID }}
API_TOKEN: ${{ secrets.API_TOKEN }}
Expand All @@ -34,6 +36,7 @@ jobs:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }}

- name: Upload artifacts with checks results
uses: actions/upload-artifact@v3
Expand Down
27 changes: 25 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ tasks.register(Tasks.PRINT_DEV_SNAPSHOT_RELEASE_NOTE_TASK_NAME) {
dependsOn(tasks.getByName("devSnapshot"))
}

tasks.register(Tasks.PRINT_SUMMARY_SANITIZED_TASK_NAME) {
doLast {
printSanitizedVersion(project.sanitizeVersion())
}
}

detekt {
allRules = false
basePath = "$projectDir"
Expand Down Expand Up @@ -210,15 +216,16 @@ nexusPublishing {
// <major>.<minor>.<patch>-dev.#+<branchname>.<hash> (local branch)
// <major>.<minor>.<patch>-dev.#+<hash> (github pull request)
// to:
// <major>.<minor>.<patch>-dev+<branchname>-SNAPSHOT
// <major>.<minor>.<patch>-dev+<branchname>_<hash>-SNAPSHOT
fun Project.sanitizeVersion(): String {
val version = version.toString()
return if (project.isSnapshotVersion()) {
val githubHeadRef = settingsProvider.githubHeadRef
val githubHeadSHA = settingsProvider.githubHeadSHA?.take(Consts.MAX_HEAD_SHA_LENGTH)
if (githubHeadRef != null) {
// github pull request
version
.replace(Regex("-dev\\.\\d+\\+[a-f0-9]+$"), "-dev+$githubHeadRef-SNAPSHOT")
.replace(Regex("-dev\\.\\d+\\+[a-f0-9]+$"), "-dev+${githubHeadRef}_$githubHeadSHA-SNAPSHOT")
} else {
// local branch
version
Expand Down Expand Up @@ -273,6 +280,16 @@ fun printDevSnapshotReleaseNote(groupId: String, artifactId: String, sanitizedVe
println()
}

fun printSanitizedVersion(sanitizedVersion: String) {
val markdownMessage = """
|## Sanitized Version
|
|**Version:** $sanitizedVersion
|
""".trimMargin()
File("sanitized_version.md").writeText(markdownMessage)
}

class SettingsProvider {

val gpgSigningKey: String?
Expand All @@ -290,6 +307,9 @@ class SettingsProvider {
val githubHeadRef: String?
get() = System.getenv(GITHUB_HEAD_REF_PROPERTY)

val githubHeadSHA: String?
get() = System.getenv(GITHUB_HEAD_SHA_PROPERTY)

fun validateGPGSecrets() = require(
value = !gpgSigningKey.isNullOrBlank() && !gpgSigningPassword.isNullOrBlank(),
lazyMessage = {
Expand All @@ -310,6 +330,7 @@ class SettingsProvider {
private const val OSSRH_USERNAME_PROPERTY = "OSSRH_USERNAME"
private const val OSSRH_PASSWORD_PROPERTY = "OSSRH_PASSWORD"
private const val GITHUB_HEAD_REF_PROPERTY = "GITHUB_HEAD_REF"
private const val GITHUB_HEAD_SHA_PROPERTY = "GITHUB_HEAD_SHA"
}
}

Expand Down Expand Up @@ -339,9 +360,11 @@ object PublicationSettings {
object Consts {
const val SLOW_TESTS_LOGGING_THRESHOLD_MS = 30_000L
const val MAX_TEST_RETRIES_COUNT = 3
const val MAX_HEAD_SHA_LENGTH = 8
}

object Tasks {
const val PRINT_FINAL_RELEASE_NOTE_TASK_NAME = "printFinalReleaseNote"
const val PRINT_DEV_SNAPSHOT_RELEASE_NOTE_TASK_NAME = "printDevSnapshotReleaseNote"
const val PRINT_SUMMARY_SANITIZED_TASK_NAME = "printDevSanitizedVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface StoreProfileApiClient {
fun getShippingOptions(request: ShippingOptionsRequest): ShippingOptionsResult

// fun addShippingOption()
// fun updateShippingOption()
fun updateShippingOption(request: ShippingOptionUpdateRequest): ShippingOptionUpdateResult
fun getPaymentOptions(request: PaymentOptionsRequest): PaymentOptionsResult
fun createPaymentOption(request: PaymentOptionCreateRequest): PaymentOptionCreateResult
fun deletePaymentOption(request: PaymentOptionDeleteRequest): PaymentOptionDeleteResult
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.ecwid.apiclient.v3.dto.profile.request

import com.ecwid.apiclient.v3.dto.ApiRequest
import com.ecwid.apiclient.v3.httptransport.HttpBody
import com.ecwid.apiclient.v3.impl.RequestInfo

data class ShippingOptionUpdateRequest(
val optionId: String = "",
val updatedShippingOption: UpdatedShippingOption = UpdatedShippingOption()
) : ApiRequest {
override fun toRequestInfo() = RequestInfo.createPutRequest(
pathSegments = listOf(
"profile",
"shippingOptions",
optionId,
),
httpBody = HttpBody.JsonBody(
obj = updatedShippingOption
)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.ecwid.apiclient.v3.dto.profile.request

import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO
import com.ecwid.apiclient.v3.dto.profile.result.FetchedStoreProfile
import java.util.*

data class UpdatedShippingOption(
val title: String? = null,
val enabled: Boolean? = null,
val orderBy: Int? = null,
val destinationZone: Zone? = null,
val businessHours: String? = null,
val businessHoursLimitationType: String? = null,
val blackoutDates: List<BlackoutDates>? = null,
val scheduled: Boolean? = null,
val scheduledPickup: Boolean? = null,
val fulfillmentTimeInMinutes: Int? = null,
val scheduledTimePrecisionType: String? = null,
val deliveryTimeDays: String? = null,
val timeSlotLengthInMinutes: Int? = null,
val allowSameDayDelivery: Boolean? = null,
val cutoffTimeForSameDayDelivery: String? = null,
val availabilityPeriod: String? = null,
val pickupInstruction: String? = null,
val description: String? = null,
val pickupPreparationTimeHours: Int? = null,
val pickupBusinessHours: String? = null,
val minimumOrderSubtotal: Int? = null,
val flatRate: FlatRate? = null,
val ratesTable: TableRatesDetails? = null,
val estimatedShippingTimeAtCheckoutSettings: EstimatedShippingTimeAtCheckoutSettings? = null,
val details: Details? = null,
) : ApiUpdatedDTO {
override fun getModifyKind(): ApiUpdatedDTO.ModifyKind {
return ApiUpdatedDTO.ModifyKind.ReadWrite(FetchedStoreProfile.ShippingOption::class)
}
}

data class Zone(
val id: String? = null,
val name: String? = null,
val countryCodes: List<String>? = null,
val stateOrProvinceCodes: List<String>? = null,
val postCodes: List<String>? = null,
val geoPolygons: List<GeoPolygons>? = null,
)

data class GeoPolygons(
val coordinates: List<List<Double>>? = null,
)

data class BlackoutDates(
val fromDate: Date? = null,
val toDate: Date? = null,
val repeatedAnnually: Boolean? = null,
)

data class FlatRate(
val rateType: String? = null,
val rate: Double? = null,
)

data class TableRatesDetails(
val tableBasedOn: String? = null,
val rates: String? = null,
)

data class EstimatedShippingTimeAtCheckoutSettings(
val estimatedDeliveryDateAtCheckoutEnabled: Boolean? = null,
val estimatedTransitTimeInDays: List<Int>? = null,
val fulfillmentTimeInDays: Int? = null,
val cutoffTimeForSameDayPacking: String? = null,
val shippingBusinessDays: List<String>? = null,
val deliveryDays: List<String>? = null,
)

data class Details(
val useDefaultAccount: Boolean? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap
import com.ecwid.apiclient.v3.dto.common.ProductCondition
import com.ecwid.apiclient.v3.dto.profile.enums.ProductFilterType
import com.ecwid.apiclient.v3.dto.profile.request.UpdatedPaymentOption
import com.ecwid.apiclient.v3.dto.profile.request.UpdatedShippingOption
import com.ecwid.apiclient.v3.dto.profile.request.UpdatedStoreProfile
import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName
import java.util.*
Expand Down Expand Up @@ -286,7 +287,11 @@ data class FetchedStoreProfile(
val pickupBusinessHours: String? = null,
val scheduled: Boolean? = null,
val scheduledTimePrecisionType: ScheduledTimePrecisionType? = null,
)
) : ApiFetchedDTO {
override fun getModifyKind(): ModifyKind {
return ModifyKind.ReadWrite(UpdatedShippingOption::class)
}
}

@Suppress("unused")
enum class ScheduledTimePrecisionType {
Expand All @@ -304,7 +309,12 @@ data class FetchedStoreProfile(
val name: String? = null,
val countryCodes: List<String>? = null,
val stateOrProvinceCodes: List<String>? = null,
val postCodes: List<String>? = null
val postCodes: List<String>? = null,
val geoPolygons: List<GeoPolygons>? = null,
)

data class GeoPolygons(
val coordinates: List<List<Double>>? = null,
)

data class CarrierMethod(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.ecwid.apiclient.v3.dto.profile.result

import com.ecwid.apiclient.v3.dto.common.ApiResultDTO

data class ShippingOptionUpdateResult(
val success: Boolean = true
) : ApiResultDTO
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ internal class StoreProfileApiClientImpl(
override fun getShippingOptions(request: ShippingOptionsRequest): ShippingOptionsResult =
apiClientHelper.makeObjectResultRequest(request)

override fun updateShippingOption(request: ShippingOptionUpdateRequest): ShippingOptionUpdateResult =
apiClientHelper.makeObjectResultRequest(request)

override fun getPaymentOptions(request: PaymentOptionsRequest): PaymentOptionsResult =
apiClientHelper.makeObjectResultRequest(request)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class CategoriesTest : BaseEntityTest() {
// Searching categories with different combinations of baseUrl and cleanUrls parameters
assertCategoryUrlMatchesRegex(
categorySearchRequest = CategoriesSearchRequest(),
urlPattern = "https://.*.company.site.*/products#!/Category-.*c.*"
urlPattern = "https://.*.company.site.*/products/Category-.*c.*"
)
assertCategoryUrlMatchesRegex(
categorySearchRequest = CategoriesSearchRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class ProductsTest : BaseEntityTest() {
// Searching products with different combinations of baseUrl and cleanUrls parameters
assertProductUrlMatchesRegex(
productSearchRequest = ByFilters(keyword = productCreateRequest.newProduct.sku),
urlPattern = "https://.*.company.site.*/products#!/Product-.*p.*"
urlPattern = "https://.*.company.site.*/products/Product-.*p.*"
)
assertProductUrlMatchesRegex(
productSearchRequest = ByFilters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ val fetchedStoreProfileNullablePropertyRules: List<NullablePropertyRule<*, *>> =
IgnoreNullable(FetchedStoreProfile.GeneralInfo::starterSite),
IgnoreNullable(FetchedStoreProfile.GeneralInfo::storeUrl),
IgnoreNullable(FetchedStoreProfile.GeneralInfo::websitePlatform),
AllowNullable(FetchedStoreProfile.GeoPolygons::coordinates),
IgnoreNullable(FetchedStoreProfile.GiftCardProducts::id),
IgnoreNullable(FetchedStoreProfile.GiftCardProducts::name),
IgnoreNullable(FetchedStoreProfile.GiftCardProducts::url),
Expand Down Expand Up @@ -376,6 +377,7 @@ val fetchedStoreProfileNullablePropertyRules: List<NullablePropertyRule<*, *>> =
IgnoreNullable(FetchedStoreProfile.Zone::name),
IgnoreNullable(FetchedStoreProfile.Zone::postCodes),
IgnoreNullable(FetchedStoreProfile.Zone::stateOrProvinceCodes),
AllowNullable(FetchedStoreProfile.Zone::geoPolygons),
AllowNullable(FetchedStoreProfile.Settings::googleProductCategory),
AllowNullable(FetchedStoreProfile.Settings::googleProductCategoryName),
AllowNullable(FetchedStoreProfile.InstantSiteInfo::ecwidSubdomainSuffix),
Expand Down
Loading