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

Adds a graphql validation script to force deploys #3061

Merged
merged 9 commits into from
Dec 13, 2018
Merged

Conversation

orta
Copy link
Contributor

@orta orta commented Nov 6, 2018

This script detects breaking changes between Reaction's schema and the one currently on prod.

The current one (where metaphysics prod is a week out of date) looks like:

 ~/d/p/a/j/s/force  $ node scripts/validate_schemas.js

[ { type: 'TYPE_REMOVED', description: 'LatLng was removed.' },
  { type: 'TYPE_REMOVED', description: 'City was removed.' },
  { type: 'TYPE_REMOVED',
    description: 'OrderModeEnum was removed.' },
  { type: 'TYPE_REMOVED', description: 'Offer was removed.' },
  { type: 'TYPE_REMOVED',
    description: 'OfferConnection was removed.' },
  { type: 'TYPE_REMOVED', description: 'OfferEdge was removed.' },
  { type: 'TYPE_REMOVED',
    description: 'ArtworkVersion was removed.' },
  { type: 'TYPE_REMOVED',
    description: 'CreateOfferOrderWithArtworkInput was removed.' },
  { type: 'TYPE_REMOVED',
    description: 'CreateOfferOrderWithArtworkPayload was removed.' },
  { type: 'TYPE_REMOVED',
    description: 'InitialOfferInput was removed.' },
  { type: 'TYPE_REMOVED',
    description: 'InitialOfferPayload was removed.' },
...

@orta
Copy link
Contributor Author

orta commented Nov 6, 2018

Alternative take, should this happen on a PR to release instead?

@orta
Copy link
Contributor Author

orta commented Nov 6, 2018

I switched this to use Danger to give a warning instead

@orta
Copy link
Contributor Author

orta commented Nov 7, 2018

Looks like Danger got removed from CI, so I've added back travis for running Danger on this repo

@orta orta force-pushed the wip_check_gql_breaking branch 9 times, most recently from b077074 to 5e0341b Compare November 7, 2018 13:04
@orta orta force-pushed the wip_check_gql_breaking branch 6 times, most recently from 85c451b to 1aa3e73 Compare November 7, 2018 18:13
@ashkan18
Copy link
Contributor

ashkan18 commented Nov 7, 2018

This is really cool! thanks @orta as always!

@orta orta force-pushed the wip_check_gql_breaking branch from 1aa3e73 to b6de4a9 Compare November 7, 2018 19:51
@orta orta changed the title WIP on adding a graphql validation script to force deploys Adds a graphql validation script to force deploys Nov 9, 2018
@orta orta force-pushed the wip_check_gql_breaking branch from b6de4a9 to f2cab46 Compare November 9, 2018 15:56
@ashkan18
Copy link
Contributor

ashkan18 commented Nov 9, 2018

this is really useful!! merge on green

@@ -9,7 +9,7 @@ jobs:
- checkout
- run:
name: Acceptance Tests
command: 'yarn install && yarn acceptance src/test/acceptance/*.js'
command: "yarn install && yarn acceptance src/test/acceptance/*.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

random q - is there any reason for this diff? Do we prefer single quoted strings in circle ci config files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

prettier does yml files, so these are the same code standard as the rest of front-end apps

@@ -0,0 +1,2 @@
language: node_js
script: yarn danger ci
Copy link
Contributor

Choose a reason for hiding this comment

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

@orta I see that in #3061 (comment) you mentioned that danger got removed from CI, but can you elaborate? I'm just wondering if there's a way that we can modify the configuration for Circle than introduce another build system for this project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, could be done, but it's simpler this way as it doesn't have to run inside docker and Travis is more reliable than Circle for Danger (due to the way they both handle ENV vars)

https://github.com/danger/danger-js/blob/f648c8a9d9e0bf1710bc6de9b78ef6fe54829066/source/ci_source/providers/Circle.ts#L4-L23

That said, this could also be ported to peril (instead of looking in the node modules, pull out the GraphQL schema from the git repo) but this should be enough for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hah, nice, looks like that is the way to go - the graphql schema for reaction was removed last week, artsy/reaction#1631

}

// Breaking change check for Metaphysics production when deploying
if (danger.github.pr.base.ref === "release") {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know a conversation topic during our recent platform practice meeting was checking for "dependencies in prod" before code hits staging as well, as such, ensuring that we never have staging code that shouldn't be deployed production.

Thoughts on updating this to run on PRs to master -- providing the staging check?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm interested in this^ too, but am OK with enforcing this on staging->release merges to start (and we can extend based on how that goes and how often it's an obstacle).

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'm wary that this will "break" builds that have nothing to do with metaphysics, so happy to do this as-is now and can look at making a tighter loop for when people either update reaction or other builds

buildClientSchema,
printSchema,
buildSchema,
findBreakingChanges,
Copy link
Contributor

Choose a reason for hiding this comment

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

so there's first class support for this in graphql-js? Very cool!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was surprised too!

@orta orta force-pushed the wip_check_gql_breaking branch from 8014c71 to 999d53a Compare December 13, 2018 21:50
@orta orta force-pushed the wip_check_gql_breaking branch from 999d53a to a901042 Compare December 13, 2018 21:52
@orta
Copy link
Contributor Author

orta commented Dec 13, 2018

What it looks like right now, if you remove the deploy PR check:

screen shot 2018-12-13 at 5 34 23 pm

@orta orta merged commit 2cc25bc into master Dec 13, 2018
@bhoggard bhoggard deleted the wip_check_gql_breaking branch April 8, 2020 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants