diff --git a/.github/actions/setup-sdk-runtime/action.yml b/.github/actions/setup-sdk-runtime/action.yml index b61148a..e05be36 100644 --- a/.github/actions/setup-sdk-runtime/action.yml +++ b/.github/actions/setup-sdk-runtime/action.yml @@ -3,7 +3,7 @@ description: Install the language runtime and formatter tools needed by an SDK e inputs: language: - description: Target language (ruby, python, go, dotnet, php, kotlin) + description: Target language (ruby, python, go, dotnet, php, kotlin, android) required: true sdk-path: description: Path to the checked-out SDK repo @@ -24,6 +24,10 @@ runs: dotnet) echo "version=$(grep -Po '(?<=net)\d+\.\d+' $(find . -name '*.csproj' -path '*/src/*' | head -1))" >> "$GITHUB_OUTPUT" ;; php) echo "version=$(grep -Po '\"php\":\s*\"\^?\K[\d.]+' composer.json)" >> "$GITHUB_OUTPUT" ;; kotlin) echo "version=$(grep -Po '(?<=JavaVersion\.VERSION_)\d+' build.gradle.kts | head -1)" >> "$GITHUB_OUTPUT" ;; + # android needs its own pattern: it sets the JVM target with + # `jvmToolchain(17)` and never mentions `JavaVersion.VERSION_`, so the + # kotlin branch above would yield an empty version. + android) echo "version=$(grep -Po 'jvmToolchain\(\K\d+' build.gradle.kts | head -1)" >> "$GITHUB_OUTPUT" ;; esac - name: Setup Ruby @@ -65,15 +69,18 @@ runs: with: php-version: ${{ steps.sdk-version.outputs.version }} + # Both Kotlin SDKs build with Gradle on a JDK. `android` targets the JVM + # (`kotlin("jvm")`), so it needs no Android SDK — the same JDK + Gradle pair + # the kotlin SDK uses is sufficient, on ubuntu. - name: Setup Java - if: inputs.language == 'kotlin' + if: inputs.language == 'kotlin' || inputs.language == 'android' uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: ${{ steps.sdk-version.outputs.version }} - name: Setup Gradle - if: inputs.language == 'kotlin' + if: inputs.language == 'kotlin' || inputs.language == 'android' uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v6.1.0 - name: Install SDK formatter tools diff --git a/.github/workflows/validate-sdks.yml b/.github/workflows/validate-sdks.yml index 25b4ba6..9c8d61f 100644 --- a/.github/workflows/validate-sdks.yml +++ b/.github/workflows/validate-sdks.yml @@ -79,7 +79,16 @@ jobs: language: ${{ matrix.language }} sdk-path: ${{ env.SDK_CHECKOUT_PATH }} + # Compatibility checking is skipped for android: no extractor is registered + # for it, so `sdk:compat-extract` exits 1 and would fail the whole matrix. + # There is nothing to protect yet either — android is unreleased, so it has + # no published surface a baseline could guard. Remove this condition (here + # and on the two steps below) once src/compat/extractors/android.ts exists. + # Downstream steps already tolerate the absence: the PR-comment script has + # an explicit "compat-report.json missing" branch, the diff report needs + # only sdk-code.diff, and both jq aggregations skip absent files. - name: Extract baseline snapshot + if: matrix.language != 'android' working-directory: openapi-spec run: | npm run sdk:compat-extract -- \ @@ -114,6 +123,7 @@ jobs: > "$GITHUB_WORKSPACE/openapi-spec/.oagen/${{ matrix.language }}/sdk-code.diff" || true - name: Extract candidate snapshot + if: matrix.language != 'android' working-directory: openapi-spec run: | npm run sdk:compat-extract -- \ @@ -129,8 +139,11 @@ jobs: cp "$GITHUB_WORKSPACE/${{ env.SDK_CHECKOUT_PATH }}/.oagen-manifest.json" \ .oagen/${{ matrix.language }}/sdk/ 2>/dev/null || true + # Skipping this sets steps.compat-diff.outcome to 'skipped', which the + # "Compat summary" step below already guards against. - name: Compat diff id: compat-diff + if: matrix.language != 'android' continue-on-error: true working-directory: openapi-spec run: npm run sdk:compat-diff -- --lang ${{ matrix.language }} diff --git a/scripts/sdk-generate.sh b/scripts/sdk-generate.sh index b60b58f..6e3294b 100755 --- a/scripts/sdk-generate.sh +++ b/scripts/sdk-generate.sh @@ -47,9 +47,9 @@ if [[ -z "$OUTPUT" ]]; then fi # Default namespace: WorkOS for languages whose namespace is a cased type/module -# name (php namespace, Swift module), workos for everything else +# name (php namespace, Swift module, Kotlin type prefix), workos for everything else if [[ -z "$NAMESPACE" ]]; then - if [[ "$LANG" == "php" || "$LANG" == "ios" ]]; then + if [[ "$LANG" == "php" || "$LANG" == "ios" || "$LANG" == "android" ]]; then NAMESPACE="WorkOS" else NAMESPACE="workos" @@ -121,4 +121,9 @@ PY EXTRA_ARGS+=(--api-surface "$TMP_SURFACE") fi -exec npx oagen generate --lang "$LANG" --spec "$SPEC" --namespace "$NAMESPACE" --output "$OUTPUT" "${EXTRA_ARGS[@]}" +# `${EXTRA_ARGS[@]+…}` rather than a bare `"${EXTRA_ARGS[@]}"`: under `set -u`, +# bash 3.2 (still what macOS ships as /bin/bash) treats expanding an empty array +# as an unbound variable. Only the node branch appends to EXTRA_ARGS, so every +# other language hit that error locally while Linux CI's bash 5 was unaffected. +exec npx oagen generate --lang "$LANG" --spec "$SPEC" --namespace "$NAMESPACE" \ + --output "$OUTPUT" ${EXTRA_ARGS[@]+"${EXTRA_ARGS[@]}"}