test: cleanup on e2e github test (#1662)

This commit is contained in:
Jefferson Ramos 2023-03-31 10:44:01 -03:00 committed by GitHub
parent 1ce5d2b7c3
commit b85a26eb46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 14 deletions

View File

@ -33,12 +33,12 @@ func GetRegistry() string {
// GetFuncBinaryPath should return the Path of 'func' binary under test // GetFuncBinaryPath should return the Path of 'func' binary under test
func GetFuncBinaryPath() string { func GetFuncBinaryPath() string {
return getOsEnvOrDefault("E2E_FUNC_BIN_PATH", "") return GetOsEnvOrDefault("E2E_FUNC_BIN_PATH", "")
} }
// GetRuntime returns the runtime that should be tested. // GetRuntime returns the runtime that should be tested.
func GetRuntime() string { func GetRuntime() string {
return getOsEnvOrDefault("E2E_RUNTIME", "node") return GetOsEnvOrDefault("E2E_RUNTIME", "node")
} }
// IsUseKnFunc indicates that tests should be run against "kn func" instead of "func" binary // IsUseKnFunc indicates that tests should be run against "kn func" instead of "func" binary
@ -46,7 +46,7 @@ func IsUseKnFunc() bool {
return strings.EqualFold(os.Getenv("E2E_USE_KN_FUNC"), "true") return strings.EqualFold(os.Getenv("E2E_USE_KN_FUNC"), "true")
} }
func getOsEnvOrDefault(env string, dflt string) string { func GetOsEnvOrDefault(env string, dflt string) string {
e := os.Getenv(env) e := os.Getenv(env)
if e == "" { if e == "" {
return dflt return dflt

View File

@ -4,7 +4,6 @@
package oncluster package oncluster
import ( import (
"os"
"path/filepath" "path/filepath"
"strings" "strings"
"testing" "testing"
@ -20,7 +19,7 @@ Test scenario covered here:
Notes: Notes:
* The function used as input for this scenario is stored in this repository at /test/oncluster/testdata/simplefunc * The function used as input for this scenario is stored in this repository at /test/oncluster/testdata/simplefunc
* On a CI Pull Request action (env CI="true") the branch used on the on-cluster test is the pull request reference. * On a CI Pull Request action the branch used on the on-cluster test is the pull request reference.
The equivalent deploy func command would look like this: The equivalent deploy func command would look like this:
func deploy --remote \ func deploy --remote \
@ -33,15 +32,11 @@ Notes:
*/ */
func resolveGitVars() (gitRepoUrl string, gitRef string) { func resolveGitVars() (gitRepoUrl string, gitRef string) {
var githubRepository = "knative/func" // On a GitHub Action (Pull Request) these variables will be set
gitRef = "main"
if os.Getenv("CI") == "true" {
// On a GitHub Action (Pull Request)
// https://docs.github.com/en/actions/learn-github-actions/variables // https://docs.github.com/en/actions/learn-github-actions/variables
githubRepository, _ = os.LookupEnv("GITHUB_REPOSITORY") gitRepo := common.GetOsEnvOrDefault("GITHUB_REPOSITORY", "knative/func")
gitRef, _ = os.LookupEnv("GITHUB_REF") gitRef = common.GetOsEnvOrDefault("GITHUB_REF", "main")
} gitRepoUrl = "https://github.com/" + gitRepo + ".git"
gitRepoUrl = "https://github.com/" + githubRepository + ".git"
return return
} }