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

chore: setup gold pact for contract testing [IDE-296] #55

Merged
merged 2 commits into from
Jun 12, 2024

Conversation

teodora-sandu
Copy link
Contributor

@teodora-sandu teodora-sandu commented Jun 11, 2024

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

  • Tests added and all succeed
  • Linted
  • README.md updated, if user-facing

🚨After having merged, please update the snyk-ls and CLI go.mod to pull in latest client.

@teodora-sandu teodora-sandu requested a review from a team as a code owner June 11, 2024 13:21
@teodora-sandu teodora-sandu changed the title Chore/setup gold pact [IDE-296] chore: setup gold pact for contract testing [IDE-296] Jun 11, 2024
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"
Copy link
Contributor Author

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

Comment on lines +16 to +18
$(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 ../

Copy link
Contributor

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},
Copy link
Contributor

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

Copy link
Contributor Author

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?

Comment on lines +158 to +162
client := http.Client{
Timeout: time.Duration(60) * time.Second,
Transport: testutil.TestAuthRoundTripper{http.DefaultTransport},
}
return &client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

Copy link
Contributor

@bastiandoetsch bastiandoetsch left a 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.

@teodora-sandu teodora-sandu merged commit f8e7eba into main Jun 12, 2024
16 checks passed
@teodora-sandu teodora-sandu deleted the chore/setup-gold-pact branch June 12, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants