From 124a9965cce0242c881458855640a1f33d87223a Mon Sep 17 00:00:00 2001 From: JasonPowr <20076537@mail.wit.ie> Date: Wed, 6 Dec 2023 14:06:39 +0000 Subject: [PATCH 1/2] re-add unit tests --- ...backfill-redis-1-0-gamma-pull-request.yaml | 15 +++++++++++++ .tekton/backfill-redis-1-0-gamma-push.yaml | 15 +++++++++++++ .tekton/rekor-cli-1-3-pull-request.yaml | 15 +++++++++++++ .tekton/rekor-cli-1-3-push.yaml | 15 +++++++++++++ .../rekor-server-1-0-gamma-pull-request.yaml | 15 +++++++++++++ .tekton/rekor-server-1-0-gamma-push.yaml | 15 +++++++++++++ .tekton/rekor-unit-test.yaml | 22 +++++++++++++++++++ pkg/api/entries.go | 2 +- 8 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 .tekton/rekor-unit-test.yaml diff --git a/.tekton/backfill-redis-1-0-gamma-pull-request.yaml b/.tekton/backfill-redis-1-0-gamma-pull-request.yaml index a3fe50e06..cf794acc7 100644 --- a/.tekton/backfill-redis-1-0-gamma-pull-request.yaml +++ b/.tekton/backfill-redis-1-0-gamma-pull-request.yaml @@ -383,6 +383,21 @@ spec: operator: in values: - "false" + - name: run-unit-test + runAfter: + - prefetch-dependencies + taskRef: + params: + - name: name + value: go-unit-test + - name: bundle + value: quay.io/securesign/rekor-unit-test:latest + - name: kind + value: task + resolver: bundles + workspaces: + - name: source + workspace: workspace workspaces: - name: workspace - name: git-auth diff --git a/.tekton/backfill-redis-1-0-gamma-push.yaml b/.tekton/backfill-redis-1-0-gamma-push.yaml index bc1dfa894..7d57ebfe0 100644 --- a/.tekton/backfill-redis-1-0-gamma-push.yaml +++ b/.tekton/backfill-redis-1-0-gamma-push.yaml @@ -380,6 +380,21 @@ spec: operator: in values: - "false" + - name: run-unit-test + runAfter: + - prefetch-dependencies + taskRef: + params: + - name: name + value: go-unit-test + - name: bundle + value: quay.io/securesign/rekor-unit-test:latest + - name: kind + value: task + resolver: bundles + workspaces: + - name: source + workspace: workspace workspaces: - name: workspace - name: git-auth diff --git a/.tekton/rekor-cli-1-3-pull-request.yaml b/.tekton/rekor-cli-1-3-pull-request.yaml index 6ff663a81..c719a1597 100644 --- a/.tekton/rekor-cli-1-3-pull-request.yaml +++ b/.tekton/rekor-cli-1-3-pull-request.yaml @@ -383,6 +383,21 @@ spec: operator: in values: - "false" + - name: run-unit-test + runAfter: + - prefetch-dependencies + taskRef: + params: + - name: name + value: go-unit-test + - name: bundle + value: quay.io/securesign/rekor-unit-test:latest + - name: kind + value: task + resolver: bundles + workspaces: + - name: source + workspace: workspace workspaces: - name: workspace - name: git-auth diff --git a/.tekton/rekor-cli-1-3-push.yaml b/.tekton/rekor-cli-1-3-push.yaml index 9f3e10bfd..61863bd29 100644 --- a/.tekton/rekor-cli-1-3-push.yaml +++ b/.tekton/rekor-cli-1-3-push.yaml @@ -380,6 +380,21 @@ spec: operator: in values: - "false" + - name: run-unit-test + runAfter: + - prefetch-dependencies + taskRef: + params: + - name: name + value: go-unit-test + - name: bundle + value: quay.io/securesign/rekor-unit-test:latest + - name: kind + value: task + resolver: bundles + workspaces: + - name: source + workspace: workspace workspaces: - name: workspace - name: git-auth diff --git a/.tekton/rekor-server-1-0-gamma-pull-request.yaml b/.tekton/rekor-server-1-0-gamma-pull-request.yaml index b597590a3..5ac9254f6 100644 --- a/.tekton/rekor-server-1-0-gamma-pull-request.yaml +++ b/.tekton/rekor-server-1-0-gamma-pull-request.yaml @@ -383,6 +383,21 @@ spec: operator: in values: - "false" + - name: run-unit-test + runAfter: + - prefetch-dependencies + taskRef: + params: + - name: name + value: go-unit-test + - name: bundle + value: quay.io/securesign/rekor-unit-test:latest + - name: kind + value: task + resolver: bundles + workspaces: + - name: source + workspace: workspace workspaces: - name: workspace - name: git-auth diff --git a/.tekton/rekor-server-1-0-gamma-push.yaml b/.tekton/rekor-server-1-0-gamma-push.yaml index 0a16c9a45..48db00e5f 100644 --- a/.tekton/rekor-server-1-0-gamma-push.yaml +++ b/.tekton/rekor-server-1-0-gamma-push.yaml @@ -380,6 +380,21 @@ spec: operator: in values: - "false" + - name: run-unit-test + runAfter: + - prefetch-dependencies + taskRef: + params: + - name: name + value: go-unit-test + - name: bundle + value: quay.io/securesign/rekor-unit-test:latest + - name: kind + value: task + resolver: bundles + workspaces: + - name: source + workspace: workspace workspaces: - name: workspace - name: git-auth diff --git a/.tekton/rekor-unit-test.yaml b/.tekton/rekor-unit-test.yaml new file mode 100644 index 000000000..380ab4469 --- /dev/null +++ b/.tekton/rekor-unit-test.yaml @@ -0,0 +1,22 @@ +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: go-unit-test + annotations: + tekton.dev/title: "Go Unit Test Task" +spec: + workspaces: + - name: source + steps: + - name: run-tests + image: registry.access.redhat.com/ubi9/go-toolset@sha256:c3a9c5c7fb226f6efcec2424dd30c38f652156040b490c9eca5ac5b61d8dc3ca + workingDir: $(workspaces.source.path)/source + script: | + #!/usr/bin/env sh + go test ./... + +# This file bundles the unit tests for rekor. +# If any changes are made to this file, it must be pushed to Quay using the following command: +# 'tkn bundle push quay.io/securesign/rekor-unit-test:latest -f .tekton/rekor-unit-test.yaml'. +# This will generate a new SHA for the bundle. +# Ensure that this new SHA is updated in the pull and push pipeline files for each component. \ No newline at end of file diff --git a/pkg/api/entries.go b/pkg/api/entries.go index ca2ac8244..56ef783d9 100644 --- a/pkg/api/entries.go +++ b/pkg/api/entries.go @@ -352,7 +352,7 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl } func publishEvent(ctx context.Context, publisher pubsub.Publisher, event *events.Event, contentType events.EventContentType) { - err := publisher.Publish(context.WithoutCancel(ctx), event, contentType) + err := publisher.Publish(ctx, event, contentType) incPublishEvent(event.Type().Name(), contentType, err == nil) if err != nil { log.ContextLogger(ctx).Error(err) From a500f4cf137b1b7c2da90a060498be3f209420f4 Mon Sep 17 00:00:00 2001 From: JasonPowr <20076537@mail.wit.ie> Date: Wed, 6 Dec 2023 16:53:59 +0000 Subject: [PATCH 2/2] remove unnecessary comment --- .tekton/rekor-unit-test.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.tekton/rekor-unit-test.yaml b/.tekton/rekor-unit-test.yaml index 380ab4469..a076d2dcd 100644 --- a/.tekton/rekor-unit-test.yaml +++ b/.tekton/rekor-unit-test.yaml @@ -17,6 +17,4 @@ spec: # This file bundles the unit tests for rekor. # If any changes are made to this file, it must be pushed to Quay using the following command: -# 'tkn bundle push quay.io/securesign/rekor-unit-test:latest -f .tekton/rekor-unit-test.yaml'. -# This will generate a new SHA for the bundle. -# Ensure that this new SHA is updated in the pull and push pipeline files for each component. \ No newline at end of file +# 'tkn bundle push quay.io/securesign/rekor-unit-test:latest -f .tekton/rekor-unit-test.yaml'. \ No newline at end of file