Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix e2e tests #331

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@ on:
- main
workflow_dispatch:


jobs:
e2e:
runs-on: ubuntu-latest

permissions:
id-token: write

steps:
- name: Checkout code
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

- name: Setup golang
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '1.21'
go-version: '1.22'
check-latest: true
- name: Restore cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-${{ hashFiles('**/go.sum') }}
restore-keys: go-
cache: true

- name: Run local registry
run: podman run -d -p 5000:5000 registry:2

- name: Build test image
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2.13
id: test-image
with:
base-image: scratch
image: test
oci: true

- name: Push test image to local registry
id: push
uses: redhat-actions/push-to-registry@9986a6552bc4571882a4a67e016b17361412b4df # v2.7.1
with:
image: ${{ steps.test-image.outputs.image }}
registry: localhost:5000
tls-verify: false

- name: Run e2e tests
run: go run mage.go E2ETest
8 changes: 6 additions & 2 deletions dependencies.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
---
dependencies:
- name: go
version: 1.21
- name: go (GitHub Actions)
version: 1.22
refPaths:
- path: .github/workflows/e2e.yml
match: go-version

- name: go (go.mod)
version: 1.21
refPaths:
- path: go.mod
match: go
3 changes: 3 additions & 0 deletions sign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ func (s *Signer) SignImageWithOptions(options *Options, reference string) (objec
return nil, fmt.Errorf("sign reference: %s: %w", reference, err)
}

// remove the reference from the cache in case we called IsImageSigned before signing.
s.signedRefs.Delete(reference)

// After signing, registry consistency may not be there right
// away. Retry the image verification if it fails
// ref: https://github.com/kubernetes-sigs/promo-tools/issues/536
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ const (

func TestSignImageSuccess(t *testing.T) {
// Test the prerequisites
signer := sign.New(nil)
opts := sign.Default()
opts.IgnoreTlog = true
opts.CertIdentityRegexp = "https://github.com/kubernetes-sigs/release-sdk/.github/workflows/e2e.yml@.*"
opts.CertOidcIssuer = "https://token.actions.githubusercontent.com"

signer := sign.New(opts)
signed, err := signer.IsImageSigned(imageRef)
require.Nil(t, err)
require.False(t, signed)
Expand Down