Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kotlin): macos compatible helpers and build on CI #3297

Merged
merged 12 commits into from
Jul 1, 2024
36 changes: 33 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ jobs:
SWIFT_DATA: ${{ steps.gen-matrix.outputs.SWIFT_DATA }}
RUN_MACOS_SWIFT_CTS: ${{ steps.gen-matrix.outputs.RUN_MACOS_SWIFT_CTS }}

RUN_MACOS_KOTLIN_BUILD: ${{ steps.gen-matrix.outputs.RUN_MACOS_KOTLIN_BUILD }}

scripts:
runs-on: ubuntu-22.04
timeout-minutes: 10
Expand Down Expand Up @@ -338,6 +340,35 @@ jobs:
name: clients-${{matrix.client.language }}
path: clients-${{matrix.client.language }}.zip

kotlin_build_macos:
timeout-minutes: 10
runs-on: macos-latest
needs:
- setup
- client_gen
if: |
always() &&
needs.setup.outputs.RUN_MACOS_KOTLIN_BUILD == 'true' &&
!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure')
steps:
- uses: actions/checkout@v4

- name: Download artifacts
uses: ./scripts/ci/actions/restore-artifacts
with:
type: languages
languages: |
kotlin

- name: Setup
uses: ./.github/actions/setup
with:
type: minimal
language: kotlin

- run: yarn cli build clients kotlin

swift_cts_macos:
timeout-minutes: 20
runs-on: macos-latest
Expand Down Expand Up @@ -371,8 +402,7 @@ jobs:
type: minimal
language: swift

- name: Run CTS
run: yarn cli cts run swift ${{ fromJSON(needs.setup.outputs.SWIFT_DATA).toRun }}
- run: yarn cli cts run swift ${{ fromJSON(needs.setup.outputs.SWIFT_DATA).toRun }}

codegen:
runs-on: ubuntu-22.04
Expand All @@ -382,9 +412,9 @@ jobs:
- client_gen
- client_gen_javascript
- swift_cts_macos
- kotlin_build_macos
if: |
always() &&
(needs.swift_cts_macos.result == 'success' || needs.swift_cts_macos.result == 'skipped') &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup it should already be validate by the next clause I think

!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure')
permissions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import io.ktor.http.*
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import java.util.SortedMap
import java.util.TreeMap
import kotlin.collections.LinkedHashMap

/**
* Builds a restriction string based on provided [SecuredApiKeyRestrictions].
*/
internal fun SearchClient.buildRestrictionString(restriction: SecuredApiKeyRestrictions): String {
val sortedParams: SortedMap<String, String> = TreeMap()
val sortedParams = LinkedHashMap<String, String>()

restriction.searchParams?.let { searchParams ->
val json = options.json.encodeToJsonElement(SearchParamsObject.serializer(), searchParams).jsonObject
Expand All @@ -23,7 +22,7 @@ internal fun SearchClient.buildRestrictionString(restriction: SecuredApiKeyRestr
is JsonArray -> element.joinToString(",") { it.jsonPrimitive.content }
else -> element.jsonPrimitive.content
}
sortedParams[key] = value
sortedParams.put(key, value)
}
}

Expand All @@ -43,5 +42,7 @@ internal fun SearchClient.buildRestrictionString(restriction: SecuredApiKeyRestr
sortedParams["validUntil"] = it.toString()
}

return sortedParams.entries.joinToString("&") { "${it.key}=${it.value.encodeURLParameter()}" }
return sortedParams.entries
.sortedBy { it.key }
.joinToString("&") { "${it.key}=${it.value.encodeURLParameter()}" }
}

This file was deleted.

1 change: 1 addition & 0 deletions scripts/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
},
],
'@typescript-eslint/sort-type-union-intersection-members': 0,
complexity: 0,
'no-param-reassign': 0,
'@typescript-eslint/consistent-type-assertions': 0,
},
Expand Down
6 changes: 6 additions & 0 deletions scripts/ci/githubActions/createMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ async function createClientMatrix(baseBranch: string): Promise<void> {
core.setOutput('RUN_MACOS_SWIFT_CTS', true);
}

// If there are updates for the Kotlin client, we allow ourselves to run the build step on macOS
const runKotlin = clientMatrix.client.find((c) => c.language === 'kotlin');
if (runKotlin) {
core.setOutput('RUN_MACOS_KOTLIN_BUILD', true);
}

const javascriptData = clientMatrix.client.find((c) => c.language === 'javascript');
if (javascriptData) {
core.setOutput('JAVASCRIPT_DATA', JSON.stringify(javascriptData));
Expand Down
Loading