-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
@@ -1,3 +1,5 @@ | |||
//go:build smoke |
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.
TIL
scripts/publish-contract.sh
Outdated
|
||
if [[ $(git diff ..main **/pacts/*.json) ]]; then | ||
echo "Contract has changed" | ||
if [[ $(git diff ..main .consumer-version) ]]; then |
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.
Should we add that to the CI to forcibly fail PR checks?
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.
What do you mean? Do you mean an earlier linting check rather than failing so late in the CI/CD?
scripts/publish-contract.sh
Outdated
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" |
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.
It'd be safer to pass broker token as env variable with PACT_BROKER_TOKEN
instead of CLI parameter.
1a614d9
to
40cf21f
Compare
3dd6586
to
91757e1
Compare
91757e1
to
8769a25
Compare
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. |
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
:After
![Screenshot 2024-04-25 at 13 30 14](https://private-user-images.githubusercontent.com/81559517/325605836-704c26f2-f504-4cb1-bfbc-5c694eb844d9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA1MzM1MDQsIm5iZiI6MTcyMDUzMzIwNCwicGF0aCI6Ii84MTU1OTUxNy8zMjU2MDU4MzYtNzA0YzI2ZjItZjUwNC00Y2IxLWJmYmMtNWM2OTRlYjg0NGQ5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA5VDEzNTMyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE4N2RhODgyOWUwZjgwNmIxNWYxM2JiM2ExNDY4OGI4MzkxNjI0OWM5MGViOWFhZjJjZWM1OGQ4YTQzOTFjYzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Qm6oBX_3StCbsXgMZV-DLMz4cXoH6bN8Z3QhrgnEBpM)
![Screenshot 2024-04-25 at 13 32 09](https://private-user-images.githubusercontent.com/81559517/325605846-f7fd743e-4061-4eb1-9a17-c48c994a3247.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA1MzM1MDQsIm5iZiI6MTcyMDUzMzIwNCwicGF0aCI6Ii84MTU1OTUxNy8zMjU2MDU4NDYtZjdmZDc0M2UtNDA2MS00ZWIxLTlhMTctYzQ4Yzk5NGEzMjQ3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA5VDEzNTMyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk4MzhiYzQyMzJlMDZkNDNmOGZhODQ1OTAzNmU3MjA1OTNhODYyYWQyZTUyOTIzMzllYTZhZjg4MTRiMzkyZWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.FClE57gz3MtLi_uv9pUNyFQT8OPhoVZUcCCefZNxtvI)
verify-contract
:After
make is-contract-compatible
:workspace-service
has not deployed the versionworkspace-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 theworkspace-service
repo)We need to be able to create an environment first:
![Screenshot 2024-04-25 at 14 41 35](https://private-user-images.githubusercontent.com/81559517/325634426-99f8b6b9-3f6e-4b5a-b2cf-236a0d475858.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA1MzM1MDQsIm5iZiI6MTcyMDUzMzIwNCwicGF0aCI6Ii84MTU1OTUxNy8zMjU2MzQ0MjYtOTlmOGI2YjktM2Y2ZS00YjVhLWIyY2YtMjM2YTBkNDc1ODU4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA5VDEzNTMyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRkZDE5NDExM2NlMzZjYjMwOWY4NTUxNmJiN2Y0NDExMDk1MDg5ZjJjNTU4YzMyZGEwNGE3N2JlMjQ3OTUzOTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.uYNMztDKCNI7FfsvH02VSJGnltdW96QLcPKfG5jV9zc)
../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
:To do:
workspace-service
tests inverify-contract
workspace-service
branch once https://github.com/snyk/workspace-service/compare/main...feat/spike/pact-separate is PR-ed and mergedmake deploy-contract
one