Skip to content

Unit tests for OpenAIServiceWrapper #27

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

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
98fbfed
install github action to build and test on commit
phelps-sg Jun 9, 2023
1d6cd5e
install sbt-scoverage plugin (#24)
phelps-sg Jun 10, 2023
486a001
add command aliases
phelps-sg Jun 10, 2023
61052fa
install scalafix plugin and run scalafix on all source files
phelps-sg Jun 9, 2023
a408426
install scalafmt sbt plugin and reformat all files
phelps-sg Jun 9, 2023
435f1fa
new spec for OpenAIServiceWrapper (#24)
phelps-sg Jun 10, 2023
de2cc89
initial working test for OpenAIServiceWrapper (#24)
phelps-sg Jun 10, 2023
e0f73f9
formatting
phelps-sg Jun 10, 2023
cc54898
additional assertions to check wrapper called
phelps-sg Jun 10, 2023
16a7eb7
optimize imports
phelps-sg Jun 10, 2023
226e653
helper for testing wrap
phelps-sg Jun 10, 2023
3e3b7f3
additional test for retrieveModel
phelps-sg Jun 10, 2023
161bab8
additional test for createCompletion
phelps-sg Jun 10, 2023
875c537
additional test for creatChatCompletion
phelps-sg Jun 10, 2023
ed58068
refactor testWrapFor to testWrapWith
phelps-sg Jun 10, 2023
ec18a03
new test for createEdit
phelps-sg Jun 10, 2023
4e64007
new test for createImage
phelps-sg Jun 10, 2023
017b2b3
new test for createImageEdit
phelps-sg Jun 10, 2023
a6c6acd
new test for createImageVariation
phelps-sg Jun 10, 2023
52957c2
new test for createEmbeddings
phelps-sg Jun 10, 2023
454aff7
new test for listFiles
phelps-sg Jun 10, 2023
a64519b
new test for uploadFile
phelps-sg Jun 10, 2023
484f523
new test for deleteFile
phelps-sg Jun 10, 2023
e451d96
new test for retrieveFile
phelps-sg Jun 10, 2023
1e45eae
new test for listFineTunes
phelps-sg Jun 10, 2023
359e2f6
new test for cancelFineTune
phelps-sg Jun 10, 2023
4013d54
new test for deleteFineTuneModel
phelps-sg Jun 10, 2023
216b293
new test for createModeration
phelps-sg Jun 10, 2023
f8cc742
factored out common testDate
phelps-sg Jun 10, 2023
f228b44
fixture renamed response
phelps-sg Jun 10, 2023
5f829eb
Revert "install scalafmt sbt plugin and reformat all files"
phelps-sg Jun 15, 2023
f400222
Revert "install scalafix plugin and run scalafix on all source files"
phelps-sg Jun 15, 2023
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.'
41 changes: 40 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,33 @@ ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"

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

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

addCommandAlias(
"validateCode",
List(
"scalafix",
"scalafmtSbtCheck",
"scalafmtCheckAll",
"test:scalafix",
"test:scalafmtCheckAll"
).mkString(";")
)

addCommandAlias(
"formatCode",
List(
"scalafmt",
"scalafmtSbt",
"Test/scalafmt"
).mkString(";")
)

addCommandAlias(
"testWithCoverage",
List(
"coverage",
"test",
"coverageReport"
).mkString(";")
)
Loading