mirror of
https://github.com/ddworken/hishtory.git
synced 2025-03-13 14:58:17 +01:00
Skip TestLiveOpenAiApi for non-master branches to allow dependabot PRs to pass GH actions
This commit is contained in:
parent
56d5189538
commit
42f9659b47
@ -13,7 +13,7 @@ import (
|
||||
// A basic sanity test that our integration with the OpenAI API is correct and is returning reasonable results (at least for a very basic query)
|
||||
func TestLiveOpenAiApi(t *testing.T) {
|
||||
if os.Getenv("OPENAI_API_KEY") == "" {
|
||||
if testutils.IsGithubAction() {
|
||||
if testutils.IsGithubAction() && testutils.GetCurrentGitBranch(t) == testutils.DefaultGitBranchName {
|
||||
t.Fatal("OPENAI_API_KEY is not set, cannot run TestLiveOpenAiApi")
|
||||
} else {
|
||||
t.Skip("Skipping test since OPENAI_API_KEY is not set")
|
||||
|
@ -425,3 +425,17 @@ func GetOsVersion(t *testing.T) string {
|
||||
version := unix.ByteSliceToString(uts.Release[:])
|
||||
return strings.Split(version, ".")[0]
|
||||
}
|
||||
|
||||
const DefaultGitBranchName = "master"
|
||||
|
||||
func GetCurrentGitBranch(t *testing.T) string {
|
||||
cmd := exec.Command("git", "symbolic-ref", "--short", "HEAD")
|
||||
var out bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to get current git branch: %v", err)
|
||||
}
|
||||
|
||||
return strings.TrimSpace(out.String())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user