Repository: openshift-pipelines/pipelines-as-code
Pull request #55 (2021-05-17 07:32:37)

Pass the same context around
Instead of using a context in struct pass the context around, the same context
for kubernetes API stuff than for GitHUB interactions.



Patch:
diff --git a/pkg/cli/interface.go b/pkg/cli/interface.go
index d916d358..efd2c383 100644
--- a/pkg/cli/interface.go
+++ b/pkg/cli/interface.go
@@ -1,6 +1,7 @@
 package cli
 
 import (
+	"context"
 	"net/http"
 
 	pacversioned "github.com/openshift-pipelines/pipelines-as-code/pkg/generated/clientset/versioned"
@@ -36,8 +37,8 @@ type Params interface {
 }
 
 type KubeInteractionIntf interface {
-	GetConsoleUI(string, string) (string, error)
-	GetNamespace(string) error
+	GetConsoleUI(context.Context, string, string) (string, error)
+	GetNamespace(context.Context, string) error
 	TektonCliPRDescribe(string, string) (string, error)
 	TektonCliFollowLogs(string, string) (string, error)
 }
diff --git a/pkg/cmd/pipelineascode/pipelineascode.go b/pkg/cmd/pipelineascode/pipelineascode.go
index 7a5dffc2..86a4b2f8 100644
--- a/pkg/cmd/pipelineascode/pipelineascode.go
+++ b/pkg/cmd/pipelineascode/pipelineascode.go
@@ -1,6 +1,7 @@
 package pipelineascode
 
 import (
+	"context"
 	"fmt"
 	"io/ioutil"
 	"os"
@@ -49,7 +50,8 @@ func Command(p cli.Params) *cobra.Command {
 				return err
 			}
 
-			return runWrap(opts, cs, kinteract)
+			ctx := context.Background()
+			return runWrap(ctx, opts, cs, kinteract)
 		},
 	}
 
@@ -70,14 +72,14 @@ func Command(p cli.Params) *cobra.Command {
 	return cmd
 }
 
-func getRunInfoFromArgsOrPayload(cs *cli.Clients, payload string, runinfo *webvcs.RunInfo) (*webvcs.RunInfo, error) {
+func getRunInfoFromArgsOrPayload(ctx context.Context, cs *cli.Clients, payload string, runinfo *webvcs.RunInfo) (*webvcs.RunInfo, error) {
 	if err := runinfo.Check(); err == nil {
 		return runinfo, err
 	} else if payload == "" {
 		return &webvcs.RunInfo{}, fmt.Errorf("no payload or not enough params set properly")
 	}
 
-	payloadinfo, err := cs.GithubClient.ParsePayload(cs.Log, runinfo.EventType, payload)
+	payloadinfo, err := cs.GithubClient.ParsePayload(ctx, cs.Log, runinfo.EventType, payload)
 	if err != nil {
 		return &webvcs.RunInfo{}, err
 	}
@@ -90,7 +92,7 @@ func getRunInfoFromArgsOrPayload(cs *cli.Clients, payload string, runinfo *webvc
 }
 
 // Wrap around a Run, create a CheckStatusID if there is a failure.
-func runWrap(opts *pacpkg.Options, cs *cli.Clients, kinteract cli.KubeInteractionIntf) error {
+func runWrap(ctx context.Context, opts *pacpkg.Options, cs *cli.Clients, kinteract cli.KubeInteractionIntf) error {
 	if opts.PayloadFile != "" {
 		_, err := os.Stat(opts.PayloadFile)
 		if err != nil {
@@ -104,22 +106,22 @@ func runWrap(opts *pacpkg.Options, cs *cli.Clients, kinteract cli.KubeInteractio
 		opts.Payload = string(b)
 	}
 
-	runinfo, err := getRunInfoFromArgsOrPayload(cs, opts.Payload, &opts.RunInfo)
+	runinfo, err := getRunInfoFromArgsOrPayload(ctx, cs, opts.Payload, &opts.RunInfo)
 	if err != nil {
 		return err
 	}
 
 	// Get webconsole url as soon as possible to have a link to click there
-	url, err := kinteract.GetConsoleUI("", "")
+	url, err := kinteract.GetConsoleUI(ctx, "", "")
 	if err != nil {
 		cs.Log.Error(err)
 		url = defaultURL
 	}
 	runinfo.WebConsoleURL = url
 
-	err = pacpkg.Run(cs, kinteract, runinfo)
+	err = pacpkg.Run(ctx, cs, kinteract, runinfo)
 	if err != nil && runinfo.CheckRunID != nil && !strings.Contains(err.Error(), "403 Resource not accessible by integration") {
-		_, _ = cs.GithubClient.CreateStatus(runinfo, "completed", "failure",
+		_, _ = cs.GithubClient.CreateStatus(ctx, runinfo, "completed", "failure",
 			fmt.Sprintf("There was an issue validating the commit: %q", err),
 			runinfo.WebConsoleURL)
 	}
diff --git a/pkg/consoleui/consoleui.go b/pkg/consoleui/consoleui.go
index b9afe234..94cf8fdf 100644
--- a/pkg/consoleui/consoleui.go
+++ b/pkg/consoleui/consoleui.go
@@ -20,9 +20,9 @@ const (
 
 // getOpenshiftConsole use dynamic client to get the route of the openshift
 // console where we can point to.
-func getOpenshiftConsole(cs *cli.Clients, ns, pr string) (string, error) {
+func getOpenshiftConsole(ctx context.Context, cs *cli.Clients, ns, pr string) (string, error) {
 	gvr := schema.GroupVersionResource{Group: openShiftRouteGroup, Version: openShiftRouteVersion, Resource: openShiftRouteResource}
-	route, err := cs.Dynamic.Resource(gvr).Namespace(openShiftConsoleNS).Get(context.Background(), openShiftConsoleRouteName, metav1.GetOptions{})
+	route, err := cs.Dynamic.Resource(gvr).Namespace(openShiftConsoleNS).Get(ctx, openShiftConsoleRouteName, metav1.GetOptions{})
 	if err != nil {
 		return "", err
 	}
@@ -49,10 +49,10 @@ func getOpenshiftConsole(cs *cli.Clients, ns, pr string) (string, error) {
 
 // GetConsoleUI Get a Console URL, OpenShift Console or Tekton Dashboard.
 // don't error if we can't find it.
-func GetConsoleUI(cs *cli.Clients, ns, pr string) (string, error) {
+func GetConsoleUI(ctx context.Context, cs *cli.Clients, ns, pr string) (string, error) {
 	var url string
 	var err error
-	url, err = getOpenshiftConsole(cs, ns, pr)
+	url, err = getOpenshiftConsole(ctx, cs, ns, pr)
 	if err != nil {
 		return "", err
 	}
diff --git a/pkg/kubeinteraction/kubeinteraction.go b/pkg/kubeinteraction/kubeinteraction.go
index 9d939cad..6f6f1a79 100644
--- a/pkg/kubeinteraction/kubeinteraction.go
+++ b/pkg/kubeinteraction/kubeinteraction.go
@@ -1,6 +1,8 @@
 package kubeinteraction
 
 import (
+	"context"
+
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/consoleui"
 	cliinterface "github.com/tektoncd/cli/pkg/cli"
@@ -12,8 +14,8 @@ type Interaction struct {
 	TektonCliLogsOptions clioptions.LogOptions
 }
 
-func (k Interaction) GetConsoleUI(ns, pr string) (string, error) {
-	return consoleui.GetConsoleUI(k.Clients, ns, pr)
+func (k Interaction) GetConsoleUI(ctx context.Context, ns, pr string) (string, error) {
+	return consoleui.GetConsoleUI(ctx, k.Clients, ns, pr)
 }
 
 func NewKubernetesInteraction(c *cli.Clients) (*Interaction, error) {
diff --git a/pkg/kubeinteraction/namespace.go b/pkg/kubeinteraction/namespace.go
index c6fc87d2..4da80aaf 100644
--- a/pkg/kubeinteraction/namespace.go
+++ b/pkg/kubeinteraction/namespace.go
@@ -7,8 +7,8 @@ import (
 )
 
 // GetNamespace get a namespace
-func (k Interaction) GetNamespace(namespace string) error {
-	_, err := k.Clients.Kube.CoreV1().Namespaces().Get(context.Background(), namespace, v1.GetOptions{})
+func (k Interaction) GetNamespace(ctx context.Context, namespace string) error {
+	_, err := k.Clients.Kube.CoreV1().Namespaces().Get(ctx, namespace, v1.GetOptions{})
 	if err != nil {
 		k.Clients.Log.Infof("Namespace: %s cannot be found", namespace)
 		return err
diff --git a/pkg/pipelineascode/acl.go b/pkg/pipelineascode/acl.go
index 57192ad1..47f5f9c6 100644
--- a/pkg/pipelineascode/acl.go
+++ b/pkg/pipelineascode/acl.go
@@ -1,6 +1,7 @@
 package pipelineascode
 
 import (
+	"context"
 	"strings"
 
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli"
@@ -15,7 +16,7 @@ type OwnersConfig struct {
 }
 
 // aclCheck check if we are allowed to run pipeline
-func aclCheck(cs *cli.Clients, runinfo *webvcs.RunInfo) (bool, error) {
+func aclCheck(ctx context.Context, cs *cli.Clients, runinfo *webvcs.RunInfo) (bool, error) {
 	// If the user who submitted the PR is the same as the Owner of the repo
 	// then allow it.
 	if runinfo.Owner == runinfo.Sender {
@@ -24,7 +25,7 @@ func aclCheck(cs *cli.Clients, runinfo *webvcs.RunInfo) (bool, error) {
 
 	// If the user who has submitted the pr is a owner on the repo then allows
 	// the CI to be run.
-	isUserMemberRepo, err := cs.GithubClient.CheckSenderOrgMembership(runinfo)
+	isUserMemberRepo, err := cs.GithubClient.CheckSenderOrgMembership(ctx, runinfo)
 	if err != nil {
 		return false, err
 	}
@@ -35,7 +36,7 @@ func aclCheck(cs *cli.Clients, runinfo *webvcs.RunInfo) (bool, error) {
 
 	// If we have a prow OWNERS file in the defaultBranch (ie: master) then
 	// parse it in approvers and reviewers field and check if sender is in there.
-	ownerFile, err := cs.GithubClient.GetFileFromDefaultBranch("OWNERS", runinfo)
+	ownerFile, err := cs.GithubClient.GetFileFromDefaultBranch(ctx, "OWNERS", runinfo)
 
 	// Don't error out if the OWNERS file cannot be found
 	if err != nil && !strings.Contains(err.Error(), "cannot find") {
diff --git a/pkg/pipelineascode/pipelineascode.go b/pkg/pipelineascode/pipelineascode.go
index b573fa2d..b45725c0 100644
--- a/pkg/pipelineascode/pipelineascode.go
+++ b/pkg/pipelineascode/pipelineascode.go
@@ -24,11 +24,11 @@ type Options struct {
 	RunInfo     webvcs.RunInfo
 }
 
-func getRepoByCR(cs *cli.Clients, url, branch, forceNamespace string) (apipac.Repository, error) {
+func getRepoByCR(ctx context.Context, cs *cli.Clients, url, branch, forceNamespace string) (apipac.Repository, error) {
 	var repository apipac.Repository
 
 	repositories, err := cs.PipelineAsCode.PipelinesascodeV1alpha1().Repositories("").List(
-		context.Background(), metav1.ListOptions{})
+		ctx, metav1.ListOptions{})
 	if err != nil {
 		return repository, err
 	}
@@ -54,51 +54,53 @@ func getRepoByCR(cs *cli.Clients, url, branch, forceNamespace string) (apipac.Re
 	return repository, nil
 }
 
-func Run(cs *cli.Clients, k8int cli.KubeInteractionIntf, runinfo *webvcs.RunInfo) error {
+// Run over the main loop
+func Run(ctx context.Context, cs *cli.Clients, k8int cli.KubeInteractionIntf, runinfo *webvcs.RunInfo) error {
 	var err error
 	var maintekton TektonYamlConfig
 
-	checkRun, err := cs.GithubClient.CreateCheckRun("in_progress", runinfo)
+	checkRun, err := cs.GithubClient.CreateCheckRun(ctx, "in_progress", runinfo)
 	if err != nil {
 		return err
 	}
 	runinfo.CheckRunID = checkRun.ID
 
-	allowed, err := aclCheck(cs, runinfo)
+	allowed, err := aclCheck(ctx, cs, runinfo)
 	if err != nil {
 		return err
 	}
 
 	if !allowed {
-		_, _ = cs.GithubClient.CreateStatus(runinfo, "completed", "skipped",
+		_, _ = cs.GithubClient.CreateStatus(ctx, runinfo, "completed", "skipped",
 			fmt.Sprintf("User %s is not allowed to run CI on this repo.", runinfo.Sender),
 			"https://tenor.com/search/police-cat-gifs")
 		cs.Log.Infof("User %s is not allowed to run CI on this repo", runinfo.Sender)
 		return nil
 	}
 
-	maintektonyaml, _ := cs.GithubClient.GetFileFromDefaultBranch(filepath.Join(tektonDir, tektonConfigurationFile), runinfo)
+	maintektonyaml, _ := cs.GithubClient.GetFileFromDefaultBranch(ctx, filepath.Join(tektonDir, tektonConfigurationFile), runinfo)
 	if maintektonyaml != "" {
-		maintekton, err = processTektonYaml(cs, runinfo, maintektonyaml)
+		maintekton, err = processTektonYaml(ctx, cs, runinfo, maintektonyaml)
 		if err != nil {
 			return err
 		}
 	}
-	repo, err := getRepoByCR(cs, runinfo.URL, runinfo.BaseBranch, maintekton.Namespace)
+
+	repo, err := getRepoByCR(ctx, cs, runinfo.URL, runinfo.BaseBranch, maintekton.Namespace)
 	if err != nil {
 		return err
 	}
 
 	if repo.Spec.Namespace == "" {
-		_, _ = cs.GithubClient.CreateStatus(runinfo, "completed", "skipped",
+		_, _ = cs.GithubClient.CreateStatus(ctx, runinfo, "completed", "skipped",
 			"Could not find a configuration for this repository", "https://tenor.com/search/sad-cat-gifs")
 		cs.Log.Infof("Could not find a namespace match for %s/%s on %s", runinfo.Owner, runinfo.Repository, runinfo.BaseBranch)
 		return nil
 	}
 
-	objects, err := cs.GithubClient.GetTektonDir(tektonDir, runinfo)
+	objects, err := cs.GithubClient.GetTektonDir(ctx, tektonDir, runinfo)
 	if err != nil {
-		_, _ = cs.GithubClient.CreateStatus(runinfo, "completed", "skipped",
+		_, _ = cs.GithubClient.CreateStatus(ctx, runinfo, "completed", "skipped",
 			"😿 Could not find a <b>.tekton/</b> directory for this repository", "https://tenor.com/search/sad-cat-gifs")
 		return err
 	}
@@ -108,11 +110,11 @@ func Run(cs *cli.Clients, k8int cli.KubeInteractionIntf, runinfo *webvcs.RunInfo
 		"sha", runinfo.SHA,
 		"event_type", "pull_request")
 
-	err = k8int.GetNamespace(repo.Spec.Namespace)
+	err = k8int.GetNamespace(ctx, repo.Spec.Namespace)
 	if err != nil {
 		return err
 	}
-	_, err = cs.GithubClient.CreateStatus(runinfo, "in_progress", "",
+	_, err = cs.GithubClient.CreateStatus(ctx, runinfo, "in_progress", "",
 		fmt.Sprintf("Creating pipelinerun in namespace <b>%s</b>", repo.Spec.Namespace),
 		"https://tenor.com/search/sad-cat-gifs")
 	if err != nil {
@@ -122,12 +124,12 @@ func Run(cs *cli.Clients, k8int cli.KubeInteractionIntf, runinfo *webvcs.RunInfo
 	yamlConfig := TektonYamlConfig{}
 	for _, file := range objects {
 		if file.GetName() == tektonConfigurationFile {
-			data, err := cs.GithubClient.GetObject(file.GetSHA(), runinfo)
+			data, err := cs.GithubClient.GetObject(ctx, file.GetSHA(), runinfo)
 			if err != nil {
 				return err
 			}
 
-			yamlConfig, err = processTektonYaml(cs, runinfo, string(data))
+			yamlConfig, err = processTektonYaml(ctx, cs, runinfo, string(data))
 			if err != nil {
 				return err
 			}
@@ -135,7 +137,7 @@ func Run(cs *cli.Clients, k8int cli.KubeInteractionIntf, runinfo *webvcs.RunInfo
 		}
 	}
 
-	allTemplates, err := cs.GithubClient.GetTektonDirTemplate(objects, runinfo)
+	allTemplates, err := cs.GithubClient.GetTektonDirTemplate(ctx, objects, runinfo)
 	if err != nil {
 		return err
 	}
@@ -166,19 +168,18 @@ func Run(cs *cli.Clients, k8int cli.KubeInteractionIntf, runinfo *webvcs.RunInfo
 		"tekton.dev/pipeline-ascode-branch":     runinfo.BaseBranch,
 	}
 
-	ctx := context.Background()
 	pr, err := cs.Tekton.TektonV1beta1().PipelineRuns(repo.Spec.Namespace).Create(ctx, prun, metav1.CreateOptions{})
 	if err != nil {
 		return err
 	}
 
-	consoleURL, err := k8int.GetConsoleUI(repo.Spec.Namespace, pr.GetName())
+	consoleURL, err := k8int.GetConsoleUI(ctx, repo.Spec.Namespace, pr.GetName())
 	if err != nil {
 		// Don't bomb out if we can't get the console UI
 		consoleURL = "https://giphy.com/explore/cat-exercise-wheel"
 	}
 
-	_, err = cs.GithubClient.CreateStatus(runinfo, "in_progress", "",
+	_, err = cs.GithubClient.CreateStatus(ctx, runinfo, "in_progress", "",
 		fmt.Sprintf(`Starting Pipelinerun <b>%s</b> in namespace <b>%s</b><br><br>You can follow the execution on the command line with : <br><br><code>tkn pr logs -f -n %s %s</code>`,
 			pr.GetName(), repo.Spec.Namespace, repo.Spec.Namespace, pr.GetName()),
 		consoleURL)
diff --git a/pkg/pipelineascode/processconfig.go b/pkg/pipelineascode/processconfig.go
index ca2fdf9f..68104537 100644
--- a/pkg/pipelineascode/processconfig.go
+++ b/pkg/pipelineascode/processconfig.go
@@ -1,6 +1,7 @@
 package pipelineascode
 
 import (
+	"context"
 	"io/ioutil"
 	"strings"
 
@@ -28,7 +29,7 @@ func addTaskYamlDocuments(data string) string {
 	return "\n---\n" + strings.TrimSpace(data) + "\n"
 }
 
-func processTektonYaml(cs *cli.Clients, runinfo *webvcs.RunInfo, data string) (TektonYamlConfig, error) {
+func processTektonYaml(ctx context.Context, cs *cli.Clients, runinfo *webvcs.RunInfo, data string) (TektonYamlConfig, error) {
 	tyConfig := TektonYamlConfig{}
 	ty := tektonYaml{}
 	err := yaml.Unmarshal([]byte(data), &ty)
@@ -55,7 +56,7 @@ func processTektonYaml(cs *cli.Clients, runinfo *webvcs.RunInfo, data string) (T
 			defer res.Body.Close()
 			tyConfig.RemoteTasks += addTaskYamlDocuments(string(data))
 		case strings.Contains(task, "/"):
-			data, err := cs.GithubClient.GetFileInsideRepo(task, false, runinfo)
+			data, err := cs.GithubClient.GetFileInsideRepo(ctx, task, false, runinfo)
 			if err != nil {
 				return tyConfig, err
 			}
diff --git a/pkg/pipelineascode/status.go b/pkg/pipelineascode/status.go
index 37732903..7612d596 100644
--- a/pkg/pipelineascode/status.go
+++ b/pkg/pipelineascode/status.go
@@ -141,7 +141,7 @@ func postFinalStatus(ctx context.Context, cs *cli.Clients, k8int cli.KubeInterac
 		return pr, err
 	}
 
-	consoleURL, err := k8int.GetConsoleUI(namespace, pr.Name)
+	consoleURL, err := k8int.GetConsoleUI(ctx, namespace, pr.Name)
 	if err != nil {
 		consoleURL = "https://giphy.com/search/cat-reading"
 	}
@@ -162,7 +162,7 @@ func postFinalStatus(ctx context.Context, cs *cli.Clients, k8int cli.KubeInterac
 		return pr, err
 	}
 
-	_, err = cs.GithubClient.CreateStatus(runinfo,
+	_, err = cs.GithubClient.CreateStatus(ctx, runinfo,
 		"completed", pipelineRunStatus(pr),
 		outputBuffer.String(), consoleURL)
 
diff --git a/pkg/webvcs/github.go b/pkg/webvcs/github.go
index 59013e41..1a0a255e 100644
--- a/pkg/webvcs/github.go
+++ b/pkg/webvcs/github.go
@@ -18,10 +18,10 @@ import (
 )
 
 type GithubVCS struct {
-	Context context.Context
-	Client  *github.Client
+	Client *github.Client
 }
 
+// RunInfo Information about current run
 type RunInfo struct {
 	BaseBranch    string // branch against where we are making the PR
 	HeadBranch    string // branch from where our SHA get tested
@@ -36,6 +36,7 @@ type RunInfo struct {
 	WebConsoleURL string
 }
 
+// Check check if the runinfo is properly set
 func (r RunInfo) Check() error {
 	if r.SHA != "" && r.BaseBranch != "" &&
 		r.Repository != "" && r.DefaultBranch != "" &&
@@ -51,15 +52,14 @@ func (r *RunInfo) DeepCopyInto(out *RunInfo) {
 	*out = *r
 }
 
+// NewGithubVCS Create a new GitHub VCS object for token
 func NewGithubVCS(token string) GithubVCS {
-	ctx := context.Background()
 	ts := oauth2.StaticTokenSource(
 		&oauth2.Token{AccessToken: token},
 	)
-	tc := oauth2.NewClient(ctx, ts)
+	tc := oauth2.NewClient(context.Background(), ts)
 	return GithubVCS{
-		Client:  github.NewClient(tc),
-		Context: ctx,
+		Client: github.NewClient(tc),
 	}
 }
 
@@ -80,17 +80,17 @@ func payloadFix(payload string) string {
 	return replacer.Replace(payload)
 }
 
-func (v GithubVCS) handleReRequestEvent(log *zap.SugaredLogger, event *github.CheckRunEvent) (RunInfo, error) {
+func (v GithubVCS) handleReRequestEvent(ctx context.Context, log *zap.SugaredLogger, event *github.CheckRunEvent) (RunInfo, error) {
 	runinfo := RunInfo{
 		Owner:      event.GetRepo().GetOwner().GetLogin(),
 		Repository: event.GetRepo().GetName(),
 	}
 	prNumber := event.GetCheckRun().GetCheckSuite().PullRequests[0].GetNumber()
 	log.Infof("Recheck of PR %s/%s#%d has been requested", runinfo.Owner, runinfo.Repository, prNumber)
-	return v.getPullRequest(runinfo, prNumber)
+	return v.getPullRequest(ctx, runinfo, prNumber)
 }
 
-func (v GithubVCS) handleIssueCommentEvent(log *zap.SugaredLogger, event *github.IssueCommentEvent) (RunInfo, error) {
+func (v GithubVCS) handleIssueCommentEvent(ctx context.Context, log *zap.SugaredLogger, event *github.IssueCommentEvent) (RunInfo, error) {
 	runinfo := RunInfo{
 		Owner:      event.GetRepo().GetOwner().GetLogin(),
 		Repository: event.GetRepo().GetName(),
@@ -108,12 +108,12 @@ func (v GithubVCS) handleIssueCommentEvent(log *zap.SugaredLogger, event *github
 	}
 
 	log.Infof("PR recheck from issue commment on %s/%s#%d has been requested", runinfo.Owner, runinfo.Repository, prNumber)
-	return v.getPullRequest(runinfo, prNumber)
+	return v.getPullRequest(ctx, runinfo, prNumber)
 }
 
 // getPullRequest get a pull request details
-func (v GithubVCS) getPullRequest(runinfo RunInfo, prNumber int) (RunInfo, error) {
-	pr, _, err := v.Client.PullRequests.Get(context.Background(), runinfo.Owner, runinfo.Repository, prNumber)
+func (v GithubVCS) getPullRequest(ctx context.Context, runinfo RunInfo, prNumber int) (RunInfo, error) {
+	pr, _, err := v.Client.PullRequests.Get(ctx, runinfo.Owner, runinfo.Repository, prNumber)
 	if err != nil {
 		return runinfo, err
 	}
@@ -131,7 +131,7 @@ func (v GithubVCS) getPullRequest(runinfo RunInfo, prNumber int) (RunInfo, error
 }
 
 // ParsePayload parse payload event
-func (v GithubVCS) ParsePayload(log *zap.SugaredLogger, eventType, payload string) (*RunInfo, error) {
+func (v GithubVCS) ParsePayload(ctx context.Context, log *zap.SugaredLogger, eventType, payload string) (*RunInfo, error) {
 	var runinfo RunInfo
 	payload = payloadFix(payload)
 	event, err := github.ParseWebHook(eventType, []byte(payloadFix(payload)))
@@ -146,14 +146,14 @@ func (v GithubVCS) ParsePayload(log *zap.SugaredLogger, eventType, payload strin
 	switch event := event.(type) {
 	case *github.CheckRunEvent:
 		if event.GetAction() == "rerequested" {
-			runinfo, err = v.handleReRequestEvent(log, event)
+			runinfo, err = v.handleReRequestEvent(ctx, log, event)
 			if err != nil {
 				return &runinfo, err
 			}
 
 		}
 	case *github.IssueCommentEvent:
-		runinfo, err = v.handleIssueCommentEvent(log, event)
+		runinfo, err = v.handleIssueCommentEvent(ctx, log, event)
 		if err != nil {
 			return &runinfo, err
 		}
@@ -177,8 +177,8 @@ func (v GithubVCS) ParsePayload(log *zap.SugaredLogger, eventType, payload strin
 
 // CheckSenderOrgMembership Get sender user's organization. We can
 // only get the one that the user sets as public 🤷
-func (v GithubVCS) CheckSenderOrgMembership(runinfo *RunInfo) (bool, error) {
-	users, resp, err := v.Client.Organizations.ListMembers(v.Context, runinfo.Owner,
+func (v GithubVCS) CheckSenderOrgMembership(ctx context.Context, runinfo *RunInfo) (bool, error) {
+	users, resp, err := v.Client.Organizations.ListMembers(ctx, runinfo.Owner,
 		&github.ListMembersOptions{
 			PublicOnly: true, // We can't list private member in a org
 		})
@@ -200,8 +200,9 @@ func (v GithubVCS) CheckSenderOrgMembership(runinfo *RunInfo) (bool, error) {
 	return false, nil
 }
 
-func (v GithubVCS) GetTektonDir(path string, runinfo *RunInfo) ([]*github.RepositoryContent, error) {
-	fp, objects, resp, err := v.Client.Repositories.GetContents(v.Context, runinfo.Owner,
+// GetTektonDir Get tekton directory from a repository
+func (v GithubVCS) GetTektonDir(ctx context.Context, path string, runinfo *RunInfo) ([]*github.RepositoryContent, error) {
+	fp, objects, resp, err := v.Client.Repositories.GetContents(ctx, runinfo.Owner,
 		runinfo.Repository, path, &github.RepositoryContentGetOptions{Ref: runinfo.SHA})
 
 	if fp != nil {
@@ -219,14 +220,14 @@ func (v GithubVCS) GetTektonDir(path string, runinfo *RunInfo) ([]*github.Reposi
 }
 
 // GetFileInsideRepo Get a file via Github API using the runinfo information, we
-// branch is true, the user the branch as ref instead of the SHA
-func (v GithubVCS) GetFileInsideRepo(path string, branch bool, runinfo *RunInfo) (string, error) {
+// branch is true, the user the branch as ref isntead of the SHA
+func (v GithubVCS) GetFileInsideRepo(ctx context.Context, path string, branch bool, runinfo *RunInfo) (string, error) {
 	ref := runinfo.SHA
 	if branch {
 		ref = runinfo.BaseBranch
 	}
 
-	fp, objects, resp, err := v.Client.Repositories.GetContents(v.Context, runinfo.Owner,
+	fp, objects, resp, err := v.Client.Repositories.GetContents(ctx, runinfo.Owner,
 		runinfo.Repository, path, &github.RepositoryContentGetOptions{Ref: ref})
 	if err != nil {
 		return "", err
@@ -238,7 +239,7 @@ func (v GithubVCS) GetFileInsideRepo(path string, branch bool, runinfo *RunInfo)
 		return "", fmt.Errorf("cannot find %s in this repository", path)
 	}
 
-	getobj, err := v.GetObject(fp.GetSHA(), runinfo)
+	getobj, err := v.GetObject(ctx, fp.GetSHA(), runinfo)
 	if err != nil {
 		return "", err
 	}
@@ -248,25 +249,26 @@ func (v GithubVCS) GetFileInsideRepo(path string, branch bool, runinfo *RunInfo)
 
 // GetFileFromDefaultBranch will get a file directly from the Default BaseBranch as
 // configured in runinfo which is directly set in webhook by Github
-func (v GithubVCS) GetFileFromDefaultBranch(path string, runinfo *RunInfo) (string, error) {
+func (v GithubVCS) GetFileFromDefaultBranch(ctx context.Context, path string, runinfo *RunInfo) (string, error) {
 	runInfoOnMain := &RunInfo{}
 	runinfo.DeepCopyInto(runInfoOnMain)
 	runInfoOnMain.BaseBranch = runInfoOnMain.DefaultBranch
 
-	tektonyaml, err := v.GetFileInsideRepo(path, true, runInfoOnMain)
+	tektonyaml, err := v.GetFileInsideRepo(ctx, path, true, runInfoOnMain)
 	if err != nil {
 		return "", fmt.Errorf("cannot find %s inside the %s branch: %s", path, runInfoOnMain.BaseBranch, err)
 	}
 	return tektonyaml, err
 }
 
-func (v GithubVCS) GetTektonDirTemplate(objects []*github.RepositoryContent, runinfo *RunInfo) (string, error) {
+// GetTektonDirTemplate Get all templates in tekton directory
+func (v GithubVCS) GetTektonDirTemplate(ctx context.Context, objects []*github.RepositoryContent, runinfo *RunInfo) (string, error) {
 	var allTemplates string
 
 	for _, value := range objects {
 		if value.GetName() != "tekton.yaml" && (strings.HasSuffix(value.GetName(), ".yaml") ||
 			strings.HasSuffix(value.GetName(), ".yml")) {
-			data, err := v.GetObject(value.GetSHA(), runinfo)
+			data, err := v.GetObject(ctx, value.GetSHA(), runinfo)
 			if err != nil {
 				return "", err
 			}
@@ -279,8 +281,9 @@ func (v GithubVCS) GetTektonDirTemplate(objects []*github.RepositoryContent, run
 	return allTemplates, nil
 }
 
-func (v GithubVCS) GetObject(sha string, runinfo *RunInfo) ([]byte, error) {
-	blob, _, err := v.Client.Git.GetBlob(v.Context, runinfo.Owner, runinfo.Repository, sha)
+// GetObject Get an object from a repository
+func (v GithubVCS) GetObject(ctx context.Context, sha string, runinfo *RunInfo) ([]byte, error) {
+	blob, _, err := v.Client.Git.GetBlob(ctx, runinfo.Owner, runinfo.Repository, sha)
 	if err != nil {
 		return nil, err
 	}
@@ -292,7 +295,7 @@ func (v GithubVCS) GetObject(sha string, runinfo *RunInfo) ([]byte, error) {
 	return decoded, err
 }
 
-func (v GithubVCS) CreateCheckRun(status string, runinfo *RunInfo) (*github.CheckRun, error) {
+func (v GithubVCS) CreateCheckRun(ctx context.Context, status string, runinfo *RunInfo) (*github.CheckRun, error) {
 	now := github.Timestamp{Time: time.Now()}
 	checkrunoption := github.CreateCheckRunOptions{
 		Name:       "Tekton Pipeline as Code CI",
@@ -302,11 +305,11 @@ func (v GithubVCS) CreateCheckRun(status string, runinfo *RunInfo) (*github.Chec
 		StartedAt:  &now,
 	}
 
-	checkRun, _, err := v.Client.Checks.CreateCheckRun(v.Context, runinfo.Owner, runinfo.Repository, checkrunoption)
+	checkRun, _, err := v.Client.Checks.CreateCheckRun(ctx, runinfo.Owner, runinfo.Repository, checkrunoption)
 	return checkRun, err
 }
 
-func (v GithubVCS) CreateStatus(runinfo *RunInfo, status, conclusion, text, detailsURL string) (*github.CheckRun, error) {
+func (v GithubVCS) CreateStatus(ctx context.Context, runinfo *RunInfo, status, conclusion, text, detailsURL string) (*github.CheckRun, error) {
 	now := github.Timestamp{Time: time.Now()}
 
 	var summary, title string
@@ -348,6 +351,6 @@ func (v GithubVCS) CreateStatus(runinfo *RunInfo, status, conclusion, text, deta
 		opts.Conclusion = &conclusion
 	}
 
-	checkRun, _, err := v.Client.Checks.UpdateCheckRun(v.Context, runinfo.Owner, runinfo.Repository, *runinfo.CheckRunID, opts)
+	checkRun, _, err := v.Client.Checks.UpdateCheckRun(ctx, runinfo.Owner, runinfo.Repository, *runinfo.CheckRunID, opts)
 	return checkRun, err
 }


Test patch:
diff --git a/pkg/cmd/pipelineascode/pipelineascode_test.go b/pkg/cmd/pipelineascode/pipelineascode_test.go
index 24a5a698..c0b59162 100644
--- a/pkg/cmd/pipelineascode/pipelineascode_test.go
+++ b/pkg/cmd/pipelineascode/pipelineascode_test.go
@@ -19,9 +19,9 @@ import (
 )
 
 func TestRunWrapOld(t *testing.T) {
-	fakectx, _ := rtesting.SetupFakeContext(t)
+	ctx, _ := rtesting.SetupFakeContext(t)
 	fakeghclient, mux, _, teardown := ghtesthelper.SetupGH()
-	stdata, _ := testclient.SeedTestData(t, fakectx, testclient.Data{})
+	stdata, _ := testclient.SeedTestData(t, ctx, testclient.Data{})
 	observer, _ := zapobserver.New(zap.InfoLevel)
 	fakelogger := zap.New(observer).Sugar()
 	checkid := 1234
@@ -32,8 +32,7 @@ func TestRunWrapOld(t *testing.T) {
 	})
 	cs := &cli.Clients{
 		GithubClient: webvcs.GithubVCS{
-			Client:  fakeghclient,
-			Context: fakectx,
+			Client: fakeghclient,
 		},
 		Log:            fakelogger,
 		PipelineAsCode: stdata.PipelineAsCode,
@@ -47,11 +46,11 @@ func TestRunWrapOld(t *testing.T) {
 			EventType: "pull_request",
 		},
 	}
-	err := runWrap(options, cs, k8int)
+	err := runWrap(ctx, options, cs, k8int)
 	assert.ErrorContains(t, err, "no payload")
 
 	options.PayloadFile = "testdata/pull_request.json"
-	err = runWrap(options, cs, k8int)
+	err = runWrap(ctx, options, cs, k8int)
 	assert.NilError(t, err)
 }
 
@@ -62,6 +61,7 @@ func TestGetInfo(t *testing.T) {
 	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
 		fmt.Fprint(w, ``)
 	})
+	ctx, _ := rtesting.SetupFakeContext(t)
 	cs := &cli.Clients{
 		GithubClient: webvcs.GithubVCS{
 			Client: fakeclient,
@@ -151,7 +151,7 @@ func TestGetInfo(t *testing.T) {
 	}
 	for _, tC := range testCases {
 		t.Run(tC.desc, func(t *testing.T) {
-			runinfo, err := getRunInfoFromArgsOrPayload(cs, tC.payload, &tC.runinfo)
+			runinfo, err := getRunInfoFromArgsOrPayload(ctx, cs, tC.payload, &tC.runinfo)
 			if tC.errmsg != "" {
 				assert.ErrorContains(t, err, tC.errmsg)
 			} else {
@@ -163,9 +163,9 @@ func TestGetInfo(t *testing.T) {
 }
 
 func TestRunWrap(t *testing.T) {
-	fakectx, _ := rtesting.SetupFakeContext(t)
+	ctx, _ := rtesting.SetupFakeContext(t)
 	fakeghclient, mux, _, teardown := ghtesthelper.SetupGH()
-	stdata, _ := testclient.SeedTestData(t, fakectx, testclient.Data{})
+	stdata, _ := testclient.SeedTestData(t, ctx, testclient.Data{})
 	observer, _ := zapobserver.New(zap.InfoLevel)
 	fakelogger := zap.New(observer).Sugar()
 	checkid := 1234
@@ -179,8 +179,7 @@ func TestRunWrap(t *testing.T) {
 	defer teardown()
 	cs := &cli.Clients{
 		GithubClient: webvcs.GithubVCS{
-			Client:  fakeghclient,
-			Context: fakectx,
+			Client: fakeghclient,
 		},
 		Log:            fakelogger,
 		PipelineAsCode: stdata.PipelineAsCode,
@@ -211,7 +210,7 @@ func TestRunWrap(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			err := runWrap(tt.opts, cs, kinteract)
+			err := runWrap(ctx, tt.opts, cs, kinteract)
 			if tt.substrErr != "" {
 				assert.ErrorContains(t, err, tt.substrErr)
 			} else {
diff --git a/pkg/pipelineascode/acl_test.go b/pkg/pipelineascode/acl_test.go
index 15bc610f..c47643ac 100644
--- a/pkg/pipelineascode/acl_test.go
+++ b/pkg/pipelineascode/acl_test.go
@@ -1,7 +1,6 @@
 package pipelineascode
 
 import (
-	"context"
 	"encoding/base64"
 	"fmt"
 	"net/http"
@@ -10,6 +9,7 @@ import (
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli"
 	ghtesthelper "github.com/openshift-pipelines/pipelines-as-code/pkg/test/github"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/webvcs"
+	rtesting "knative.dev/pkg/reconciler/testing"
 )
 
 func TestAclCheck(t *testing.T) {
@@ -46,9 +46,9 @@ func TestAclCheck(t *testing.T) {
 		fmt.Fprintf(rw, `{"content": "%s"}`, base64.RawStdEncoding.EncodeToString([]byte("approvers:\n  - approved\n")))
 	})
 
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gvcs := webvcs.GithubVCS{
-		Client:  fakeclient,
-		Context: context.Background(),
+		Client: fakeclient,
 	}
 
 	tests := []struct {
@@ -109,7 +109,7 @@ func TestAclCheck(t *testing.T) {
 				GithubClient: gvcs,
 			}
 
-			got, err := aclCheck(&cs, tt.runinfo)
+			got, err := aclCheck(ctx, &cs, tt.runinfo)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("aclCheck() error = %v, wantErr %v", err, tt.wantErr)
 				return
diff --git a/pkg/pipelineascode/pipelineascode_test.go b/pkg/pipelineascode/pipelineascode_test.go
index 6ff0470e..38b35012 100644
--- a/pkg/pipelineascode/pipelineascode_test.go
+++ b/pkg/pipelineascode/pipelineascode_test.go
@@ -96,7 +96,7 @@ func TestFilterByGood(t *testing.T) {
 	}
 	cs, _ := testclient.SeedTestData(t, ctx, d)
 	client := &cli.Clients{PipelineAsCode: cs.PipelineAsCode}
-	repo, err := getRepoByCR(client, url, branch, "")
+	repo, err := getRepoByCR(ctx, client, url, branch, "")
 	assert.NilError(t, err)
 	assert.Equal(t, repo.Spec.Namespace, targetNamespace)
 }
@@ -116,7 +116,7 @@ func TestFilterByNotMatch(t *testing.T) {
 	}
 	cs, _ := testclient.SeedTestData(t, ctx, d)
 	client := &cli.Clients{PipelineAsCode: cs.PipelineAsCode}
-	repo, err := getRepoByCR(client, otherurl, branch, "")
+	repo, err := getRepoByCR(ctx, client, otherurl, branch, "")
 	assert.NilError(t, err)
 	assert.Equal(t, repo.Spec.Namespace, "")
 }
@@ -136,7 +136,7 @@ func TestFilterByNotInItsNamespace(t *testing.T) {
 	}
 	cs, _ := testclient.SeedTestData(t, ctx, d)
 	client := &cli.Clients{PipelineAsCode: cs.PipelineAsCode}
-	repo, err := getRepoByCR(client, url, branch, "")
+	repo, err := getRepoByCR(ctx, client, url, branch, "")
 	assert.ErrorContains(t, err, fmt.Sprintf("repo CR %s matches but belongs to", testname))
 	assert.Equal(t, repo.Spec.Namespace, "")
 }
@@ -157,7 +157,7 @@ func TestFilterForceNamespace(t *testing.T) {
 	}
 	cs, _ := testclient.SeedTestData(t, ctx, d)
 	client := &cli.Clients{PipelineAsCode: cs.PipelineAsCode}
-	_, err := getRepoByCR(client, url, branch, forcedNamespace)
+	_, err := getRepoByCR(ctx, client, url, branch, forcedNamespace)
 	assert.ErrorContains(t, err, "as configured from tekton.yaml on the main branch")
 }
 
@@ -202,8 +202,7 @@ func TestRunDeniedFromForcedNamespace(t *testing.T) {
 	})
 
 	gcvs := webvcs.GithubVCS{
-		Client:  fakeclient,
-		Context: ctx,
+		Client: fakeclient,
 	}
 	datas := testclient.Data{
 		Repositories: []*v1alpha1.Repository{
@@ -217,7 +216,7 @@ func TestRunDeniedFromForcedNamespace(t *testing.T) {
 	}
 	k8int := kitesthelper.KinterfaceTest{}
 
-	err := Run(cs, &k8int, runinfo)
+	err := Run(ctx, cs, &k8int, runinfo)
 
 	assert.Error(t, err,
 		fmt.Sprintf("repo CR matches but should be installed in %s as configured from tekton.yaml on the main branch",
@@ -322,8 +321,7 @@ func TestRun(t *testing.T) {
 		})
 
 	gcvs := webvcs.GithubVCS{
-		Client:  fakeclient,
-		Context: ctx,
+		Client: fakeclient,
 	}
 
 	repo := testclient.Data{
@@ -367,7 +365,7 @@ func TestRun(t *testing.T) {
 	// TODO: I am not sure why querying stdata.Tekton.PipelineRun.List doesn't
 	// give back anything while it works for repo, we will need to investigate
 	// this to make better testing.
-	err = Run(cs, &k8int, runinfo)
+	err = Run(ctx, cs, &k8int, runinfo)
 	assert.NilError(t, err)
 	assert.Assert(t, len(log.TakeAll()) > 0)
 	got, err := stdata.PipelineAsCode.PipelinesascodeV1alpha1().Repositories("namespace").Get(
diff --git a/pkg/pipelineascode/processconfig_test.go b/pkg/pipelineascode/processconfig_test.go
index 10978ba6..a56cf179 100644
--- a/pkg/pipelineascode/processconfig_test.go
+++ b/pkg/pipelineascode/processconfig_test.go
@@ -1,7 +1,6 @@
 package pipelineascode
 
 import (
-	"context"
 	"encoding/base64"
 	"fmt"
 	"net/http"
@@ -9,6 +8,7 @@ import (
 
 	ghtesthelper "github.com/openshift-pipelines/pipelines-as-code/pkg/test/github"
 	httptesthelper "github.com/openshift-pipelines/pipelines-as-code/pkg/test/http"
+	rtesting "knative.dev/pkg/reconciler/testing"
 
 	"github.com/google/go-cmp/cmp"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli"
@@ -19,15 +19,17 @@ import (
 )
 
 func TestProcessTektonYamlNamespace(t *testing.T) {
+	ctx, _ := rtesting.SetupFakeContext(t)
 	namespace := "liguedestalents"
 	data := "namespace: " + namespace
 	cs := cli.Clients{}
-	ret, err := processTektonYaml(&cs, &webvcs.RunInfo{}, data)
+	ret, err := processTektonYaml(ctx, &cs, &webvcs.RunInfo{}, data)
 	assert.NilError(t, err)
 	assert.Equal(t, ret.Namespace, namespace)
 }
 
 func TestProcessTektonYamlRemoteTask(t *testing.T) {
+	ctx, _ := rtesting.SetupFakeContext(t)
 	data := `tasks:
 - https://foo.bar
 - https://hello.moto
@@ -42,7 +44,7 @@ HELLO
 HELLO
 `
 
-	ret, err := processTektonYaml(&cs, &webvcs.RunInfo{}, data)
+	ret, err := processTektonYaml(ctx, &cs, &webvcs.RunInfo{}, data)
 	assert.NilError(t, err)
 	if d := cmp.Diff(ret.RemoteTasks, expected); d != "" {
 		t.Fatalf("-got, +want: %v", d)
@@ -50,7 +52,7 @@ HELLO
 }
 
 func TestProcessTektonYamlRefInternal(t *testing.T) {
-	ctx := context.Background()
+	ctx, _ := rtesting.SetupFakeContext(t)
 	expected := "EAT YOUR VEGGIES"
 	data := `tasks:
 - be/healthy
@@ -79,12 +81,11 @@ func TestProcessTektonYamlRefInternal(t *testing.T) {
 	})
 
 	gcvs := webvcs.GithubVCS{
-		Client:  fakeclient,
-		Context: ctx,
+		Client: fakeclient,
 	}
 	cs := &cli.Clients{GithubClient: gcvs}
 
-	ret, err := processTektonYaml(cs, &webvcs.RunInfo{}, data)
+	ret, err := processTektonYaml(ctx, cs, &webvcs.RunInfo{}, data)
 	assert.NilError(t, err)
 
 	if d := cmp.Diff(ret.RemoteTasks, "\n---\n"+expected+"\n"); d != "" {
diff --git a/pkg/test/kubernetestint/kubernetesint.go b/pkg/test/kubernetestint/kubernetesint.go
index c8d1eae6..7ad29963 100644
--- a/pkg/test/kubernetestint/kubernetesint.go
+++ b/pkg/test/kubernetestint/kubernetesint.go
@@ -1,6 +1,9 @@
 package kubernetestint
 
-import "errors"
+import (
+	"context"
+	"errors"
+)
 
 type KinterfaceTest struct {
 	ConsoleURL     string
@@ -9,11 +12,11 @@ type KinterfaceTest struct {
 	prDescribe string
 }
 
-func (k *KinterfaceTest) GetConsoleUI(ns string, pr string) (string, error) {
+func (k *KinterfaceTest) GetConsoleUI(ctx context.Context, ns string, pr string) (string, error) {
 	return k.ConsoleURL, nil
 }
 
-func (k *KinterfaceTest) GetNamespace(ns string) error {
+func (k *KinterfaceTest) GetNamespace(ctx context.Context, ns string) error {
 	if k.NamespaceError {
 		return errors.New("cannot find Namespace")
 	}
diff --git a/pkg/webvcs/github_test.go b/pkg/webvcs/github_test.go
index ff26ad79..e5e5c28e 100644
--- a/pkg/webvcs/github_test.go
+++ b/pkg/webvcs/github_test.go
@@ -1,7 +1,6 @@
 package webvcs
 
 import (
-	"context"
 	"encoding/json"
 	"fmt"
 	"io/ioutil"
@@ -30,15 +29,15 @@ func setupFakesURLS() (client GithubVCS, teardown func()) {
 	fakeclient, mux, _, teardown := ghtesthelper.SetupGH()
 
 	mux.HandleFunc("/repos/check/run/check-runs", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, `{"id": 555}`)
+		_, _ = fmt.Fprint(w, `{"id": 555}`)
 	})
 
 	mux.HandleFunc("/repos/check/run/check-runs/2026", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, `{"id": 666}`)
+		_, _ = fmt.Fprint(w, `{"id": 666}`)
 	})
 
 	mux.HandleFunc("/repos/foo/bar/contents/README.md", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, `{
+		_, _ = fmt.Fprint(w, `{
 "name": "README.md",
 "sha": "readmemdsha",
 "type": "file"
@@ -46,7 +45,7 @@ func setupFakesURLS() (client GithubVCS, teardown func()) {
 	})
 
 	mux.HandleFunc("/repos/foo/bar/git/blobs/readmemdsha", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, `{
+		_, _ = fmt.Fprint(w, `{
 "name": "README.md",
 "content": "aGVsbG8gbW90bwo=",
 "encoding": "base64"
@@ -54,7 +53,7 @@ func setupFakesURLS() (client GithubVCS, teardown func()) {
 	})
 
 	mux.HandleFunc("/repos/tekton/dir/git/blobs/pipelineyaml", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, `{
+		_, _ = fmt.Fprint(w, `{
 "name": "README.md",
 "content": "aGVsbG8gcGlwZWxpbmV5YW1s",
 "encoding": "base64"
@@ -62,7 +61,7 @@ func setupFakesURLS() (client GithubVCS, teardown func()) {
 	})
 
 	mux.HandleFunc("/repos/tekton/dir/git/blobs/runyaml", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, `{
+		_, _ = fmt.Fprint(w, `{
 "name": "README.md",
 "content": "aGVsbG8gcnVueWFtbA==",
 "encoding": "base64"
@@ -70,7 +69,7 @@ func setupFakesURLS() (client GithubVCS, teardown func()) {
 	})
 
 	mux.HandleFunc("/repos/tekton/dir/git/blobs/tektonyaml", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, `{
+		_, _ = fmt.Fprint(w, `{
 "name": "README.md",
 "content": "aGVsbG8gdGVrdG9ueWFtbA==",
 "encoding": "base64"
@@ -78,7 +77,7 @@ func setupFakesURLS() (client GithubVCS, teardown func()) {
 	})
 
 	mux.HandleFunc("/repos/tekton/dir/contents/.tekton", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, `[{
+		_, _ = fmt.Fprint(w, `[{
 
 				  "name": "pipeline.yaml",
 				  "path": ".tekton/pipeline.yaml",
@@ -99,11 +98,11 @@ func setupFakesURLS() (client GithubVCS, teardown func()) {
 		     }]`)
 	})
 	mux.HandleFunc("/repos/throw/error/contents/.tekton", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, "ERRROR")
+		_, _ = fmt.Fprint(w, "ERRROR")
 	})
 
 	mux.HandleFunc("/repos/its/afile/contents/.tekton", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, `{
+		_, _ = fmt.Fprint(w, `{
 "name": ".tekton",
 "sha": "decfae2653959f7c6c25f21f026c3819bea41ecf",
 "type": "file",
@@ -113,21 +112,19 @@ func setupFakesURLS() (client GithubVCS, teardown func()) {
 		w.WriteHeader(http.StatusNotFound)
 	})
 
-	ctx := context.Background()
 	gcvs := GithubVCS{
-		Client:  fakeclient,
-		Context: ctx,
+		Client: fakeclient,
 	}
-
 	return gcvs, teardown
 }
 
 func TestPayLoadFix(t *testing.T) {
 	b, err := ioutil.ReadFile("testdata/pull_request_with_newlines.json")
 	assert.NilError(t, err)
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gvcs := NewGithubVCS("none")
 	logger, _ := getLogger()
-	_, err = gvcs.ParsePayload(logger, "pull_request", payloadFix(string(b)))
+	_, err = gvcs.ParsePayload(ctx, logger, "pull_request", payloadFix(string(b)))
 	// would bomb out on "assertion failed: error is not nil: invalid character
 	// '\n' in string literal" if we don't payloadfix
 	assert.NilError(t, err)
@@ -146,14 +143,14 @@ func TestParsePayloadRerequest(t *testing.T) {
 	fakeclient, mux, _, teardown := ghtesthelper.SetupGH()
 	defer teardown()
 	mux.HandleFunc("/repos/"+prOwner+"/"+repoName+"/pulls/"+prNumber, func(rw http.ResponseWriter, r *http.Request) {
-		fmt.Fprintf(rw, `{"head": {"ref": "123"}, "user": {"login": "%s"}}`, prOwner)
+		_, _ = fmt.Fprintf(rw, `{"head": {"ref": "123"}, "user": {"login": "%s"}}`, prOwner)
 	})
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gvcs := GithubVCS{
-		Client:  fakeclient,
-		Context: context.Background(),
+		Client: fakeclient,
 	}
 	logger, observer := getLogger()
-	runinfo, err := gvcs.ParsePayload(logger, "check_run", checkrunEvent)
+	runinfo, err := gvcs.ParsePayload(ctx, logger, "check_run", checkrunEvent)
 	assert.NilError(t, err)
 
 	assert.Equal(t, prOwner, runinfo.Owner)
@@ -173,7 +170,7 @@ func TestParsePayLoadRetest(t *testing.T) {
 	fakeclient, mux, _, teardown := ghtesthelper.SetupGH()
 	defer teardown()
 	mux.HandleFunc("/repos/"+prOwner+"/"+repoName+"/pulls/"+prNumber, func(rw http.ResponseWriter, r *http.Request) {
-		fmt.Fprintf(rw, `{"head": {"ref": "123"}, "user": {"login": "%s"}}`, prOwner)
+		_, _ = fmt.Fprintf(rw, `{"head": {"ref": "123"}, "user": {"login": "%s"}}`, prOwner)
 	})
 
 	issueEvent := fmt.Sprintf(`{
@@ -196,11 +193,10 @@ func TestParsePayLoadRetest(t *testing.T) {
 	ctx, _ := rtesting.SetupFakeContext(t)
 	logger, observer := getLogger()
 	gvcs := GithubVCS{
-		Client:  fakeclient,
-		Context: ctx,
+		Client: fakeclient,
 	}
 
-	runinfo, err := gvcs.ParsePayload(logger, "issue_comment", issueEvent)
+	runinfo, err := gvcs.ParsePayload(ctx, logger, "issue_comment", issueEvent)
 	assert.NilError(t, err)
 	assert.Equal(t, prOwner, runinfo.Owner)
 	// Make sure the PR owner is the runinfo.Owner and not the issueSender
@@ -213,10 +209,11 @@ func TestParsePayload(t *testing.T) {
 	b, err := ioutil.ReadFile("testdata/pull_request.json")
 	assert.NilError(t, err)
 
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gvcs := NewGithubVCS("none")
 	logger, _ := getLogger()
 
-	runinfo, err := gvcs.ParsePayload(logger, "pull_request", string(b))
+	runinfo, err := gvcs.ParsePayload(ctx, logger, "pull_request", string(b))
 	assert.NilError(t, err)
 	assert.Assert(t, runinfo.BaseBranch == "master")
 	assert.Assert(t, runinfo.Owner == "chmouel")
@@ -225,27 +222,31 @@ func TestParsePayload(t *testing.T) {
 }
 
 func TestParsePayloadInvalid(t *testing.T) {
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gvcs := NewGithubVCS("none")
 	logger, _ := getLogger()
-	_, err := gvcs.ParsePayload(logger, "pull_request", "hello moto")
+	_, err := gvcs.ParsePayload(ctx, logger, "pull_request", "hello moto")
 	assert.ErrorContains(t, err, "invalid character")
 }
 
 func TestParsePayloadUnkownEvent(t *testing.T) {
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gvcs := NewGithubVCS("none")
 	logger, _ := getLogger()
-	_, err := gvcs.ParsePayload(logger, "foo", "{\"hello\": \"moto\"}")
+	_, err := gvcs.ParsePayload(ctx, logger, "foo", "{\"hello\": \"moto\"}")
 	assert.ErrorContains(t, err, "unknown X-Github-Event")
 }
 
 func TestParsePayCannotParse(t *testing.T) {
 	gvcs := NewGithubVCS("none")
+	ctx, _ := rtesting.SetupFakeContext(t)
 	logger, _ := getLogger()
-	_, err := gvcs.ParsePayload(logger, "gollum", "{}")
+	_, err := gvcs.ParsePayload(ctx, logger, "gollum", "{}")
 	assert.Error(t, err, "this event is not supported")
 }
 
 func TestGetFileInsideRepo(t *testing.T) {
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gcvs, teardown := setupFakesURLS()
 	defer teardown()
 	type args struct {
@@ -313,13 +314,14 @@ func TestGetFileInsideRepo(t *testing.T) {
 	}
 	for _, tt := range testGetTektonDir {
 		t.Run(tt.name, func(t *testing.T) {
-			got, err := gcvs.GetFileInsideRepo(tt.args.path, false, tt.args.runinfo)
+			got, err := gcvs.GetFileInsideRepo(ctx, tt.args.path, false, tt.args.runinfo)
 			tt.args.assertion(t, got, err)
 		})
 	}
 }
 
 func TestGetTektonDir(t *testing.T) {
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gcvs, teardown := setupFakesURLS()
 	defer teardown()
 
@@ -392,7 +394,7 @@ func TestGetTektonDir(t *testing.T) {
 	}
 	for _, tt := range testGetTektonDir {
 		t.Run(tt.name, func(t *testing.T) {
-			got, err := gcvs.GetTektonDir(tt.args.path, tt.args.runinfo)
+			got, err := gcvs.GetTektonDir(ctx, tt.args.path, tt.args.runinfo)
 			tt.args.assertion(t, got, err)
 		})
 	}
@@ -404,18 +406,18 @@ hello pipelineyaml
 ---
 hello runyaml
 `
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gcvs, teardown := setupFakesURLS()
 	defer teardown()
-
 	runinfo := &RunInfo{
 		Owner:      "tekton",
 		Repository: "dir",
 	}
 
-	ghr, err := gcvs.GetTektonDir(".tekton", runinfo)
+	ghr, err := gcvs.GetTektonDir(ctx, ".tekton", runinfo)
 	assert.NilError(t, err)
 
-	got, err := gcvs.GetTektonDirTemplate(ghr, runinfo)
+	got, err := gcvs.GetTektonDirTemplate(ctx, ghr, runinfo)
 	assert.NilError(t, err)
 	if d := cmp.Diff(got, expected); d != "" {
 		t.Fatalf("-got, +want: %v", d)
@@ -423,13 +425,14 @@ hello runyaml
 }
 
 func TestGithubVCS_CreateCheckRun(t *testing.T) {
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gcvs, teardown := setupFakesURLS()
 	defer teardown()
 	runinfo := &RunInfo{
 		Owner:      "check",
 		Repository: "run",
 	}
-	cr, err := gcvs.CreateCheckRun("hello moto", runinfo)
+	cr, err := gcvs.CreateCheckRun(ctx, "hello moto", runinfo)
 	assert.NilError(t, err)
 	assert.Equal(t, cr.GetID(), int64(555))
 }
@@ -493,6 +496,7 @@ func TestRunInfoCheck(t *testing.T) {
 }
 
 func TestCreateStatus(t *testing.T) {
+	ctx, _ := rtesting.SetupFakeContext(t)
 	gcvs, teardown := setupFakesURLS()
 	checkrunid := int64(2026)
 	defer teardown()
@@ -501,7 +505,7 @@ func TestCreateStatus(t *testing.T) {
 		Repository: "run",
 		CheckRunID: &checkrunid,
 	}
-	cr, err := gcvs.CreateStatus(runinfo, "completed", "success", "Yay", "https://foo/bar")
+	cr, err := gcvs.CreateStatus(ctx, runinfo, "completed", "success", "Yay", "https://foo/bar")
 	assert.NilError(t, err)
 	assert.Equal(t, cr.GetID(), int64(666))
 }
@@ -597,10 +601,9 @@ func TestGithubVCS_CreateStatus(t *testing.T) {
 			fakeclient, mux, _, teardown := ghtesthelper.SetupGH()
 			defer teardown()
 
-			ctx := context.Background()
+			ctx, _ := rtesting.SetupFakeContext(t)
 			gcvs := GithubVCS{
-				Client:  fakeclient,
-				Context: ctx,
+				Client: fakeclient,
 			}
 			mux.HandleFunc(fmt.Sprintf("/repos/check/run/check-runs/%d", checkrunid), func(rw http.ResponseWriter, r *http.Request) {
 				bit, _ := ioutil.ReadAll(r.Body)
@@ -618,10 +621,11 @@ func TestGithubVCS_CreateStatus(t *testing.T) {
 				assert.Equal(t, checkRun.Output.GetText(), tt.args.text)
 				assert.Equal(t, checkRun.GetDetailsURL(), tt.args.detailsURL)
 				assert.Assert(t, strings.Contains(checkRun.Output.GetTitle(), tt.args.titleSubstr))
-				fmt.Fprintf(rw, `{"id": %d}`, resultid)
+				_, err = fmt.Fprintf(rw, `{"id": %d}`, resultid)
+				assert.NilError(t, err)
 			})
 
-			got, err := gcvs.CreateStatus(tt.args.runinfo, tt.args.status, tt.args.conclusion, tt.args.text, tt.args.detailsURL)
+			got, err := gcvs.CreateStatus(ctx, tt.args.runinfo, tt.args.status, tt.args.conclusion, tt.args.text, tt.args.detailsURL)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("GithubVCS.CreateStatus() error = %v, wantErr %v", err, tt.wantErr)
 				return