Refactor integration E2E tests

* General cleanup of the integration tests Golang code. Move the
  `e2e.go` codebase into its own package and separate files.
* Reduce the overall log spam from the integration tests output.
* Add final GitHub workflow step that stops GARM server, and does the
  GitHub cleanup of any orphaned resources.
* Add `TODO` to implement cleanup of the orphaned GitHub webhooks.
  This is useful, if the uninstall of the webhooks failed.
* Add `TODO` for extra missing checks on the GitHub webhooks
  install / uninstall logic.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
This commit is contained in:
Ionut Balutoiu 2023-08-24 14:32:37 +03:00
parent 789644c27f
commit 318bc52b57
15 changed files with 1473 additions and 1547 deletions

View file

@ -0,0 +1,34 @@
package main
import (
"log"
"os"
"github.com/cloudbase/garm/test/integration/e2e"
)
var (
orgName = os.Getenv("ORG_NAME")
repoName = os.Getenv("REPO_NAME")
ghToken = os.Getenv("GH_TOKEN")
)
func main() {
controllerID, ctrlIdFound := os.LookupEnv("GARM_CONTROLLER_ID")
if ctrlIdFound {
_ = e2e.GhOrgRunnersCleanup(ghToken, orgName, controllerID)
_ = e2e.GhRepoRunnersCleanup(ghToken, orgName, repoName, controllerID)
} else {
log.Println("Env variable GARM_CONTROLLER_ID is not set, skipping GitHub runners cleanup")
}
baseURL, baseUrlFound := os.LookupEnv("GARM_BASE_URL")
if ctrlIdFound && baseUrlFound {
log.Printf("TODO: Cleanup org & repo webhooks staring with: %s/webhooks/%s", baseURL, controllerID)
// TODO: Cleanup org webhooks that start with "{baseURL}/webhooks/{controllerID}"
// TODO: Cleanup repo webhooks that start with "{baseURL}/webhooks/{controllerID}"
} else {
log.Println("Env variables GARM_CONTROLLER_ID & GARM_BASE_URL are not set, skipping webhooks cleanup")
}
}