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

Initial unit tests for OpenAIRetryServiceAdapter #18

Closed
wants to merge 3 commits into from
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
124 changes: 124 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Continuous Integration (CI) to Build & Test & Coverage & Lint.
# ~~
name: CI
on:
pull_request:
branches: [ main, '**' ]
push:
branches: [ main ]

jobs:
validate:
name: Validate Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: '11'
cache: 'sbt'

- name: Validate Code
run: sbt validateCode

build:
name: Build & Test
needs: [ validate ]
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
scala: [ '2.12.15', '2.13.10', '3.2.2' ]

steps:
- uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '8'
cache: 'sbt'

- name: Build & Test
run: sbt ++${{ matrix.scala }} testWithCoverage

- name: Upload coverage report (Cobertura)
uses: actions/[email protected]
with:
name: cobertura.xml
path: ${{github.workspace}}/target/scala-2.13/coverage-report/cobertura.xml

- name: Upload coverage report (HTML)
uses: actions/[email protected]
with:
name: scoverage-report-html
path: ${{github.workspace}}/target/scala-2.13/scoverage-report/

optional-build:
name: Build (Optional)
continue-on-error: ${{ matrix.experimental }}
needs: [ validate ]
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
distribution: [ 'corretto' ]
jdk: [ '11' ]
scala: [ '2.12.15', '2.13.10', '3.2.2' ]
experimental: [ false ]
include:
- jdk: '17'
distribution: 'corretto'
scala: '2.13.10'
experimental: true

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.jdk }}
cache: 'sbt'

- name: Perform Build / Test
run: sbt ++${{ matrix.scala }} compile test

coverage:
name: Coverage Report
if: ${{ github.event.pull_request }}
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: cobertura.xml

- name: Analyzing coverage report
uses: 5monkeys/cobertura-action@master
with:
path: cobertura.xml
only_changed_files: true
fail_below_threshold: true
show_missing: true
show_line: true
show_branch: true
show_class_names: true
link_missing_lines: true
minimum_coverage: 75

ready-to-merge:
name: Ready to Merge
if: ${{ github.event.pull_request }}
needs: [ optional-build, coverage ]
runs-on: ubuntu-latest
steps:
- run: echo 'Ready to merge.'
12 changes: 11 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,27 @@ ThisBuild / scalaVersion := scala212
ThisBuild / version := "0.3.3"
ThisBuild / isSnapshot := false

lazy val commonSettings = Seq(
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.16",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.16" % Test,
libraryDependencies += "org.mockito" %% "mockito-scala-scalatest" % "1.17.14" % Test
)

lazy val core = (project in file("openai-core"))
.settings(commonSettings: _*)

lazy val client = (project in file("openai-client"))
.settings(commonSettings: _*)
.dependsOn(core)
.aggregate(core)

lazy val client_stream = (project in file("openai-client-stream"))
.settings(commonSettings: _*)
.dependsOn(client)
.aggregate(client)

lazy val guice = (project in file("openai-guice"))
.settings(commonSettings: _*)
.dependsOn(client)
.aggregate(client_stream)

Expand All @@ -44,4 +54,4 @@ ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"

ThisBuild / sonatypeRepository := "https://s01.oss.sonatype.org/service/local"

ThisBuild / publishTo := sonatypePublishToBundle.value
ThisBuild / publishTo := sonatypePublishToBundle.value
Loading