code: def main(args: argparse.Namespace) -> None:
      if args.task == "pack":
          pack_rpackage()
      elif args.task == "build":
          src_dir = pack_rpackage()
          build_rpackage(src_dir)
      elif args.task == "doc":
          check_rmarkdown()
      elif args.task == "check":
          if args.build_tool == "autotools" and system() != "Windows":
              src_dir = pack_rpackage()
              tarball = build_rpackage(src_dir)
              check_rpackage(tarball)
          elif args.build_tool == "autotools":
              test_with_autotools()
          else:
              test_with_cmake(args)
      elif args.task == "timings":
          check_example_timing(Path("xgboost.Rcheck"), 2.5)
      else:
          raise ValueError("Unexpected task.")
  
file_path: xgboost/tests/ci_build/test_r_package.py
imports: import argparse
  import os
  import shutil
  import subprocess
  from io import StringIO
  from pathlib import Path
  from platform import system
  from test_utils import R_PACKAGE, ROOT, DirectoryExcursion, cd, print_time, record_time
label_desc: Use image node_id 9 for calling a global function with example usage: main(args) without return types