-
Notifications
You must be signed in to change notification settings - Fork 1
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
chore: setup gold pact for contract testing [IDE-296] #55
Conversation
gitCommitSHA=$(git rev-parse HEAD) | ||
gitBranch=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
pact-broker publish ./internal/workspace/2024-05-14/pacts/code-client-go-workspace-service.json --consumer-app-version "$gitCommitSHA" --branch="$gitBranch" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to use the Docker image so we don't have to install the CLI but I had trouble getting it to work in CircleCI, even though locally it worked. So I gave up
$(TOOLS_BIN)/pact-broker: | ||
@cd $(TOOLS_BIN); curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | PACT_CLI_VERSION=v2.4.4 bash; cd ../ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we need the CLI after all?
return http.DefaultClient | ||
client := http.Client{ | ||
Timeout: time.Duration(60) * time.Second, | ||
Transport: testutil.TestAuthRoundTripper{http.DefaultTransport}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use the client from go-application-framework getNetworkAccess().getHttpClient()
. That should take care of authentication of Snyk URLs.
see github.com/snyk/go-application-framework@v0.0.0-20240610102034-19c275b56341/pkg/networking/middleware/auth_header.go:36
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid using GAF because of cyclic deps, otherwise we'll have GAF -> code-client-go -> GAF. Unless there's some other way to get around this?
client := http.Client{ | ||
Timeout: time.Duration(60) * time.Second, | ||
Transport: testutil.TestAuthRoundTripper{http.DefaultTransport}, | ||
} | ||
return &client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, maybe you'll want to update the HTTP Client to the go-application-framework one in all places. But your choice.
Description
Adds a step in the pipeline that publishes the Pact generated by running the contract tests for the Workspace API and fixes up the Pact test and generated contract so that the provider-side tests correctly pass. Can see the contract tests passing for this new contract in https://github.com/snyk/workspace-service/pull/1065. The pipeline follows these standards: https://docs.pact.io/pact_nirvana/step_5.
The uploaded Pact in the Pact broker is at https://snyk-dev.pactflow.io/overview/provider/workspace-service/consumer/code-client-go. To get access to it you need to ask someone who is already logged in to invite you (@teodora-sandu @michelkaporin @vikki).
Checklist
🚨After having merged, please update the
snyk-ls
and CLI go.mod to pull in latest client.