diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1700f2ded12..5ba0da7f9573 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - os: ubuntu-latest ruby: "4.0" # (b/515549177): Disabled linkinator globally due to broken external doc links. - task: "--rubocop-toplevel --rubocop --build --yard" + task: "--rubocop-toplevel --rubocop --build --yard --doctest" - os: macos-latest ruby: "4.0" task: "--test" diff --git a/.toys/ci.rb b/.toys/ci.rb index a1cd344821c7..266c92c025cd 100644 --- a/.toys/ci.rb +++ b/.toys/ci.rb @@ -19,14 +19,15 @@ "rubocop", "build", "yard", + "doctest", "linkinator", "acceptance", "conformance", "samples-main", "samples-latest", ].freeze -OPTIONAL_TASKS = ["conformance"].freeze -ISSUE_TASKS = ["bundle", "test", "rubocop", "build", "yard", "linkinator"].freeze +OPTIONAL_TASKS = ["conformance", "doctest"].freeze +ISSUE_TASKS = ["bundle", "test", "rubocop", "build", "yard", "doctest", "linkinator"].freeze FAILURES_REPORT_PATH = "tmp/ci-failures.json" desc "Run CI tasks." diff --git a/.toys/doctest.rb b/.toys/doctest.rb new file mode 100644 index 000000000000..f0f7423cb036 --- /dev/null +++ b/.toys/doctest.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +desc "Run YARD doctests for this gem" + +include :exec, e: true + +def run + require "bundler" + gem_dir = Dir.pwd + unless File.file?(File.join(gem_dir, "Gemfile")) && File.file?(File.join(gem_dir, "support/doctest_helper.rb")) + puts "No doctests configured for #{File.basename(gem_dir)}." + exit 0 + end + Bundler.with_unbundled_env do + exec ["bundle", "exec", "yard", "--plugin", "doctest", "doctest"] + end +end