Skip to content

Commit 903df59

Browse files
committed
✅ Add OpenAI Integration Tests to GitHub Actions Workflow
1 parent fe467bf commit 903df59

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.github/workflows/checks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ jobs:
6868

6969
- name: Run Check task
7070
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
71+
env:
72+
CODEMODDER_OPENAI_API_KEY: ${{ secrets.CODEMODDER_OPENAI_API_KEY }}
7173
with:
7274
arguments: check --stacktrace
7375
cache-read-only: ${{ github.ref != 'refs/heads/main' }}

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
java-version: '17'
3737

3838
- uses: gradle/gradle-build-action@v2
39+
env:
40+
CODEMODDER_OPENAI_API_KEY: ${{ secrets.CODEMODDER_OPENAI_API_KEY }}
3941
with:
4042
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
4143
arguments: --console=plain --quiet --no-configuration-cache -Pversion=${{ inputs.version }} build distZip publishNebulaPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository

framework/codemodder-testutils-llm/src/main/java/io/codemodder/testutils/llm/CodemodderOpenAIKeys.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ private CodemodderOpenAIKeys() {}
1212
/**
1313
* Return true if and only if we have a non-empty {@code CODEMODDER_OPENAI_API_KEY} environment
1414
* variable.
15+
*
16+
* @throws IllegalStateException when running in a CI/CD environment and the key is not available.
17+
* This is backstop to ensure that all expected tests run in CI/CD.
1518
*/
1619
public static boolean isAvailable() {
1720
String key = System.getenv("CODEMODDER_OPENAI_API_KEY");
18-
return key != null && !key.isBlank();
21+
final var available = key != null && !key.isBlank();
22+
if (System.getenv("CI") != null && !available) {
23+
throw new IllegalStateException(
24+
"The CODEMODDER_OPENAI_API_KEY environment variable must be set in the CI/CD environment.");
25+
}
26+
return available;
1927
}
2028
}

0 commit comments

Comments
 (0)