From 7785758b4175ed661d73ab78ff87b7a78c79d577 Mon Sep 17 00:00:00 2001 From: Jefferson Ramos Date: Wed, 9 Aug 2023 18:55:35 -0300 Subject: [PATCH] test: update github ref used on e2e oncluster tests (#1917) --- test/oncluster/scenario_github_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/oncluster/scenario_github_test.go b/test/oncluster/scenario_github_test.go index 5b1bf89845..44aef7c59b 100644 --- a/test/oncluster/scenario_github_test.go +++ b/test/oncluster/scenario_github_test.go @@ -4,6 +4,7 @@ package oncluster import ( "path/filepath" + "regexp" "strings" "testing" @@ -32,10 +33,14 @@ Notes: func resolveGitVars() (gitRepoUrl string, gitRef string) { // On a GitHub Action (Pull Request) these variables will be set - // https://docs.github.com/en/actions/learn-github-actions/variables + // https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables gitRepo := common.GetOsEnvOrDefault("GITHUB_REPOSITORY", "knative/func") - gitRef = common.GetOsEnvOrDefault("GITHUB_REF", "main") gitRepoUrl = "https://github.com/" + gitRepo + ".git" + + gitRef = common.GetOsEnvOrDefault("GITHUB_REF", "main") + // GitHub uses 2 refs per merge request (refs/pull/ID/head and refs/pull/ID/merge), ensure using */head + exp := regexp.MustCompile("^refs/pull/(.*?)/merge$") + gitRef = exp.ReplaceAllString(gitRef, "refs/pull/${1}/head") return }