diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-01 06:06:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-01 06:06:26 +0300 |
commit | 56d96ad7fab4d4b95f5529d8080b3cc2873794a0 (patch) | |
tree | 7fe93fc8ff4d82d815000781ffb9c98d7259211a /lib/tasks | |
parent | 8078bd185fd9fce86cb5a8d9a6b6209e0c23ae44 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/gitlab/graphql.rake | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/lib/tasks/gitlab/graphql.rake b/lib/tasks/gitlab/graphql.rake index 902f22684ee..f8ce3cd46a8 100644 --- a/lib/tasks/gitlab/graphql.rake +++ b/lib/tasks/gitlab/graphql.rake @@ -2,10 +2,24 @@ return if Rails.env.production? +require 'graphql/rake_task' + namespace :gitlab do OUTPUT_DIR = Rails.root.join("doc/api/graphql/reference") TEMPLATES_DIR = 'lib/gitlab/graphql/docs/templates/' + # Defines tasks for dumping the GraphQL schema: + # - gitlab:graphql:schema:dump + # - gitlab:graphql:schema:idl + # - gitlab:graphql:schema:json + GraphQL::RakeTask.new( + schema_name: 'GitlabSchema', + dependencies: [:environment], + directory: OUTPUT_DIR, + idl_outfile: "gitlab_schema.graphql", + json_outfile: "gitlab_schema.json" + ) + namespace :graphql do desc 'GitLab | Generate GraphQL docs' task compile_docs: :environment do @@ -25,11 +39,20 @@ namespace :gitlab do if doc == renderer.contents puts "GraphQL documentation is up to date" else - puts '#' * 10 - puts '#' - puts '# GraphQL documentation is outdated! Please update it by running `bundle exec rake gitlab:graphql:compile_docs`.' - puts '#' - puts '#' * 10 + format_output('GraphQL documentation is outdated! Please update it by running `bundle exec rake gitlab:graphql:compile_docs`.') + abort + end + end + + desc 'GitLab | Check if GraphQL schemas are up to date' + task check_schema: :environment do + idl_doc = File.read(Rails.root.join(OUTPUT_DIR, 'gitlab_schema.graphql')) + json_doc = File.read(Rails.root.join(OUTPUT_DIR, 'gitlab_schema.json')) + + if idl_doc == GitlabSchema.to_definition && json_doc == GitlabSchema.to_json + puts "GraphQL schema is up to date" + else + format_output('GraphQL schema is outdated! Please update it by running `bundle exec rake gitlab:graphql:schema:dump`.') abort end end @@ -42,3 +65,12 @@ def render_options template: Rails.root.join(TEMPLATES_DIR, 'default.md.haml') } end + +def format_output(str) + heading = '#' * 10 + puts heading + puts '#' + puts "# #{str}" + puts '#' + puts heading +end |