diff --git a/.fasterci/config.yaml b/.fasterci/config.yaml index b964dd3e..557e3a84 100644 --- a/.fasterci/config.yaml +++ b/.fasterci/config.yaml @@ -12,6 +12,8 @@ workflows: steps: - name: Build & test bazel: + build_flags: + - --enable_bzlmod=false build_targets: - //... test_targets: @@ -19,6 +21,8 @@ workflows: - name: Build & test e2e working-directory: e2e bazel: + build_flags: + - --enable_bzlmod=false build_targets: - //... test_targets: @@ -31,11 +35,11 @@ workflows: build_targets: - //... build_flags: - - --config=bzlmod + - --enable_bzlmod test_targets: - //... test_flags: - - --config=bzlmod + - --enable_bzlmod - --test_size_filters=-large,-enormous - <<: *build_workflow diff --git a/WORKSPACE b/WORKSPACE index 05a64db9..b786a676 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -21,6 +21,12 @@ http_archive( ], ) +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") + +go_rules_dependencies() + +go_register_toolchains(version = "1.21.6") + http_archive( name = "buildifier_prebuilt", sha256 = "8ada9d88e51ebf5a1fdff37d75ed41d51f5e677cdbeafb0a22dda54747d6e07e", @@ -42,12 +48,6 @@ load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains buildifier_prebuilt_register_toolchains() -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") - -go_rules_dependencies() - -go_register_toolchains(version = "1.21.6") - # # Self dependencies # diff --git a/e2e/WORKSPACE b/e2e/WORKSPACE index 6a1f0df4..f9642d5c 100644 --- a/e2e/WORKSPACE +++ b/e2e/WORKSPACE @@ -22,10 +22,10 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_go", - sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3", + sha256 = "6734a719993b1ba4ebe9806e853864395a8d3968ad27f9dd759c196b3eb3abe8", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip", + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.45.1/rules_go-v0.45.1.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.45.1/rules_go-v0.45.1.zip", ], ) @@ -33,7 +33,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe go_rules_dependencies() -go_register_toolchains(version = "1.20.6") +go_register_toolchains(version = "1.21.6") load("@rules_gitops//gitops:deps.bzl", "rules_gitops_dependencies") diff --git a/gitops/deps.bzl b/gitops/deps.bzl index de6b90c7..ea808d2a 100644 --- a/gitops/deps.bzl +++ b/gitops/deps.bzl @@ -49,7 +49,7 @@ def rules_gitops_dependencies(): name = "aspect_bazel_lib", sha256 = "b554eb7942a5ab44c90077df6a0c76fc67c5874c9446a007e9ba68be82bd4796", strip_prefix = "bazel-lib-2.7.1", - url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.4.1/bazel-lib-v2.7.1.tar.gz", + url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.1/bazel-lib-v2.7.1.tar.gz", ) maybe( diff --git a/go.mod b/go.mod index b991c4aa..72ffba60 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/fasterci/rules_gitops -go 1.19 +go 1.21 require ( github.com/ghodss/yaml v1.0.0 diff --git a/testing/it_sidecar/it_sidecar.go b/testing/it_sidecar/it_sidecar.go index 814540c2..e9816c8a 100644 --- a/testing/it_sidecar/it_sidecar.go +++ b/testing/it_sidecar/it_sidecar.go @@ -340,20 +340,31 @@ func cleanup(clientset *kubernetes.Clientset) { } } +var ErrTimedOut = errors.New("timed out") +var ErrStdinClosed = errors.New("stdin closed") +var ErrTermSignalReceived = errors.New("TERM signal received") + func main() { flag.Parse() log.SetOutput(os.Stdout) - ctx, cancel := context.WithTimeout(context.Background(), *timeout) - defer cancel() - ctx, stopSignal := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM) - defer stopSignal() + ctx, timeoutCancel := context.WithTimeoutCause(context.Background(), *timeout, ErrTimedOut) + defer timeoutCancel() + ctx, cancel := context.WithCancelCause(ctx) + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) + go func() { + <-c + log.Print("First TERM signal, stopping...") + cancel(ErrTermSignalReceived) + signal.Stop(c) + }() // cancel context if stdin is closed go func() { reader := bufio.NewReader(os.Stdin) for { _, _, err := reader.ReadRune() if err != nil && err == io.EOF { - cancel() + cancel(ErrStdinClosed) break } } @@ -378,13 +389,12 @@ func main() { if err != nil { log.Print(err) } - cancel() + cancel(fmt.Errorf("terminate due to kubernetes listening failure: %w", err)) }() listenForEvents(ctx, clientset, func(event *v1.Event) { if !allowErrors { - log.Println("Terminate due to failure") - cancel() + cancel(fmt.Errorf("terminate due to event %s/%s %s %s", event.Namespace, event.InvolvedObject.Name, event.Reason, event.Message)) } }) @@ -405,4 +415,13 @@ func main() { fmt.Println("READY") <-ctx.Done() + switch ctx.Err() { + case context.DeadlineExceeded: + log.Print("Deadline exceeded") + case context.Canceled: + log.Print("Context Canceled") + default: + log.Print(ctx.Err()) + } + }