Repository navigation
test: support hermetic local API reference #3351
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - next | |
| - 'stl/**' | |
| - 'codegen/stl/**' | |
| pull_request: | |
| branches: | |
| - main | |
| - next | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ci-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| lint: | |
| name: CI / lint | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Java | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 | |
| with: | |
| distribution: temurin | |
| java-version: | | |
| 8 | |
| 21 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2 | |
| - name: Run lints | |
| run: ./scripts/lint | |
| build: | |
| name: CI / build + Jackson compatibility | |
| if: >- | |
| !(github.repository == 'stainless-sdks/openai-java' && | |
| github.event_name == 'push' && | |
| !startsWith(github.ref, 'refs/heads/stl/')) | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Java | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 | |
| with: | |
| distribution: temurin | |
| java-version: | | |
| 8 | |
| 21 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2 | |
| - name: Build SDK and run compatibility tests | |
| env: | |
| GRADLE_OPTS: -Dkotlin.compiler.execution.strategy=in-process | |
| run: ./scripts/build | |
| test: | |
| name: CI / tests | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Java | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 | |
| with: | |
| distribution: temurin | |
| java-version: | | |
| 8 | |
| 21 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2 | |
| - name: Run tests | |
| run: ./scripts/test | |
| api_compatibility: | |
| name: CI / API compatibility | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 20 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Java | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 | |
| with: | |
| distribution: temurin | |
| java-version: | | |
| 8 | |
| 21 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2 | |
| - name: Compile previous tests against the proposed SDK | |
| env: | |
| BASE_COMMIT: ${{ github.event.pull_request.base.sha }} | |
| GRADLE_OPTS: -Dkotlin.compiler.execution.strategy=in-process | |
| run: | | |
| set -euo pipefail | |
| # The proposed detector verifies the current compatibility policy. Running the baseline | |
| # detector as well prevents a PR from weakening that policy to hide an SDK break. | |
| ./scripts/detect-breaking-changes "$BASE_COMMIT" | |
| BASE_DETECTOR="$(mktemp ./scripts/detect-breaking-changes.baseline.XXXXXX)" | |
| trap 'rm -f "$BASE_DETECTOR"' EXIT | |
| git show "${BASE_COMMIT}:scripts/detect-breaking-changes" > "$BASE_DETECTOR" | |
| chmod +x "$BASE_DETECTOR" | |
| "$BASE_DETECTOR" "$BASE_COMMIT" | |
| required: | |
| name: CI / required | |
| if: always() | |
| needs: | |
| - lint | |
| - build | |
| - test | |
| - api_compatibility | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Verify required jobs succeeded | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| REPOSITORY: ${{ github.repository }} | |
| REF: ${{ github.ref }} | |
| LINT_RESULT: ${{ needs.lint.result }} | |
| BUILD_RESULT: ${{ needs.build.result }} | |
| TEST_RESULT: ${{ needs.test.result }} | |
| API_COMPATIBILITY_RESULT: ${{ needs.api_compatibility.result }} | |
| run: | | |
| set -euo pipefail | |
| failed_jobs=() | |
| [[ "$LINT_RESULT" == "success" ]] || failed_jobs+=("lint: $LINT_RESULT") | |
| [[ "$TEST_RESULT" == "success" ]] || failed_jobs+=("test: $TEST_RESULT") | |
| if [[ "$EVENT_NAME" == "push" && | |
| "$REPOSITORY" == "stainless-sdks/openai-java" && | |
| "$REF" != refs/heads/stl/* ]]; then | |
| [[ "$BUILD_RESULT" == "skipped" ]] || | |
| failed_jobs+=("build: expected skipped, got $BUILD_RESULT") | |
| else | |
| [[ "$BUILD_RESULT" == "success" ]] || failed_jobs+=("build: $BUILD_RESULT") | |
| fi | |
| if [[ "$EVENT_NAME" == "pull_request" && "$API_COMPATIBILITY_RESULT" != "success" ]]; then | |
| failed_jobs+=("API compatibility: $API_COMPATIBILITY_RESULT") | |
| fi | |
| if (( ${#failed_jobs[@]} > 0 )); then | |
| printf 'Required CI job did not succeed: %s\n' "${failed_jobs[@]}" | |
| exit 1 | |
| fi | |
| echo "All required CI jobs succeeded." |