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 pact in CI/CD #35

Closed
wants to merge 1 commit into from
Closed

chore: setup pact in CI/CD #35

wants to merge 1 commit into from

Conversation

teodora-sandu
Copy link
Collaborator

@teodora-sandu teodora-sandu commented Apr 22, 2024

The diagram of the pipeline can be found at https://miro.com/app/board/uXjVNsON77A=/?moveToWidget=3458764586699482727&cot=14

The workspace-service branch is https://github.com/snyk/workspace-service/compare/main...feat/spike/pact-separate.

After publish-contract:

  • when it succeeds
    Screenshot 2024-04-25 at 12 00 06
  • when there already is a version of this contract but with some changes
    Screenshot 2024-04-26 at 17 00 52

After verify-contract:
Screenshot 2024-04-25 at 13 30 14
Screenshot 2024-04-25 at 13 32 09

After make is-contract-compatible:

  • when workspace-service has not deployed the version
    Screenshot 2024-04-25 at 13 35 10
  • when workspace-service has deployed the version (../code-client-go/.bin/pact/bin/pact-broker record_deployment --pacticipant WorkspaceApi --version 7.35.1-featspikepact-separate+7.147b9763.SNAPSHOT.Teodoras-MacBook-Pro --environment production --broker-base-url $PACT_BROKER_URL --broker-token $PACT_BROKER_TOKEN from the workspace-service repo)
    Screenshot 2024-04-25 at 14 40 01
    Screenshot 2024-04-25 at 14 40 51

We need to be able to create an environment first: ../code-client-go/.bin/pact/bin/pact-broker create-environment --name production --display-name Production --production --broker-base-url $PACT_BROKER_URL --broker-token $PACT_BROKER_TOKEN
After make deploy-contract:
Screenshot 2024-04-25 at 14 41 35

To do:

  • check if prodsec are happy with the solution
  • add Node.js to the pipeline so we can run the workspace-service tests in verify-contract
  • change the workspace-service branch once https://github.com/snyk/workspace-service/compare/main...feat/spike/pact-separate is PR-ed and merged
  • get admin access to snyk-dev pactflow
  • update the release pipeline so it's also performing these steps + the make deploy-contract one

@@ -1,3 +1,5 @@
//go:build smoke
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL


if [[ $(git diff ..main **/pacts/*.json) ]]; then
echo "Contract has changed"
if [[ $(git diff ..main .consumer-version) ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add that to the CI to forcibly fail PR checks?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you mean? Do you mean an earlier linting check rather than failing so late in the CI/CD?

else
echo "Publishing Pact contracts..."
pact-broker publish internal/deepcode/pacts/code-client-go-snykcodeapi.json --consumer-app-version "$consumerVersion" --branch main --broker-base-url "$brokerUrl" --broker-token "$brokerToken"
pact-broker publish internal/workspace/2024-03-12/pacts/code-client-go-workspaceapi.json --consumer-app-version "$consumerVersion" --branch main --broker-base-url "$brokerUrl" --broker-token "$brokerToken"

Choose a reason for hiding this comment

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

It'd be safer to pass broker token as env variable with PACT_BROKER_TOKEN instead of CLI parameter.

@CLAassistant
Copy link

CLAassistant commented Apr 25, 2024

CLA assistant check
All committers have signed the CLA.

@teodora-sandu teodora-sandu force-pushed the chore/pact-setup branch 6 times, most recently from 1a614d9 to 40cf21f Compare April 26, 2024 16:23
@teodora-sandu teodora-sandu force-pushed the chore/pact-setup branch 2 times, most recently from 3dd6586 to 91757e1 Compare June 6, 2024 16:00
@teodora-sandu
Copy link
Collaborator Author

Most of this was implemented in #55. This version is the diamond version but webhookless, which we shouldn't do because of what's explained in https://snyksec.atlassian.net/browse/IDE-296?focusedCommentId=998299.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants