Beispiel #1
0
def task_test():
    """(dry)run tests"""
    env = "test"
    pym = [*P.RUN_IN[env], *P.PYM]

    dry_run_stem = P.get_atest_stem(extra_args=["--dryrun"],
                                    lockfile=P.get_lockfile(env),
                                    browser=P.BROWSER)
    real_stem = P.get_atest_stem(lockfile=P.get_lockfile(env),
                                 browser=P.BROWSER)

    dry_target = P.ATEST_OUT / dry_run_stem / P.ATEST_OUT_XML
    real_target = P.ATEST_OUT / real_stem / P.ATEST_OUT_XML

    clean, touch = P.get_ok_actions(P.OK.robot_dry_run)

    robot_deps = [
        *P.PY_SRC, *P.ALL_ROBOT, P.PIP_LISTS[env], P.SCRIPTS / "atest.py"
    ]

    yield dict(
        name="dryrun",
        doc=
        "pass the tests through the robot machinery, but don't actually _run_ anything",
        uptodate=[config_changed(os.environ.get("ATEST_ARGS", ""))],
        actions=[clean, [*pym, "_scripts.atest", "--dryrun"], touch],
        file_dep=robot_deps,
        targets=[dry_target, P.OK.robot_dry_run],
    )

    clean, touch = P.get_ok_actions(P.OK.robot)

    yield dict(
        name="atest",
        doc="run acceptance tests with robot",
        uptodate=[config_changed(os.environ.get("ATEST_ARGS", ""))],
        actions=[clean, [*pym, "_scripts.atest"], touch],
        file_dep=[P.OK.robot_dry_run, *robot_deps],
        targets=[real_target, P.OK.robot],
    )

    # Presently not running this on CI
    yield dict(
        name="combine",
        doc="combine all robot outputs into a single HTML report",
        actions=[[*pym, "_scripts.combine"]],
        file_dep=[
            real_target,
            *P.ATEST_OUT.rglob(P.ATEST_OUT_XML),
            P.SCRIPTS / "combine.py",
        ],
    )
Beispiel #2
0
def _make_env(env):
    lockfile = P.get_lockfile(env)

    explicit_list = P.BUILD / env / lockfile.name

    if not explicit_list.parent.exists():
        explicit_list.parent.mkdir(parents=True)

    actions = [
        lambda: explicit_list.unlink() if explicit_list.exists() else None,
    ]

    if P.CI:
        env_args = ["-n", env]
    else:
        env_args = ["-p", P.ENVS / env]
        actions += [
            [P.CONDA_EXE, "create", "-y", *env_args, "--file", lockfile],
        ]
    actions += [
        lambda: [
            explicit_list.write_bytes(
                subprocess.check_output(
                    [P.CONDA_EXE, "list", "--explicit", "--md5", *env_args])),
            None,
        ][-1],
    ]

    yield dict(
        name=env,
        file_dep=[lockfile],
        actions=actions,
        targets=[explicit_list],
    )
Beispiel #3
0
def task_lab():
    """start a jupyter lab server (with all other extensions)"""

    env = "test"
    lockfile = P.get_lockfile(env)
    str_lock = str(lockfile)
    needs_build = "lab1" in str_lock or "lab2" in str_lock

    frozen = P.PIP_LISTS[env]
    run_in = P.RUN_IN[env]
    pym = [*run_in, *P.PYM]

    app_dir = []

    if needs_build and not P.IN_BINDER:
        app_dir = ["--app-dir", P.APP_DIR]

    lab = [*pym, "jupyter", "lab"]

    lab_ext = [*pym, "jupyter", "labextension"]

    serve_deps = [frozen]

    if needs_build:
        yield dict(
            name="ext",
            uptodate=[config_changed({"labextensions": P.LAB_EXTENSIONS})],
            actions=[
                [
                    *lab_ext, "install", *app_dir, *P.LAB_EXTENSIONS,
                    "--no-build"
                ],
                [*lab, "build", *app_dir, "--debug"],
            ],
            file_dep=[frozen],
            targets=[P.APP_INDEX],
        )
        serve_deps += [P.APP_INDEX]

    def _lab():
        p = subprocess.Popen([*lab, *app_dir, "--no-browser", "--debug"],
                             stdin=subprocess.PIPE)
        try:
            p.wait()
        except KeyboardInterrupt:
            p.terminate()
            p.communicate(b"y\n")
            p.terminate()
        finally:
            p.wait()

        print("maybe check your process log")

    yield dict(
        name="serve",
        doc="runs lab (never stops)",
        uptodate=[lambda: False],
        actions=[PythonInteractiveAction(_lab)],
        file_dep=serve_deps,
    )
Beispiel #4
0
def task_docs():
    """build HTML docs"""
    env = "docs"
    run_in = P.RUN_IN[env]
    lockfile = P.get_lockfile(env)
    frozen = P.PIP_LISTS[env]

    clean, touch = P.get_ok_actions(P.RTD_ENV)

    def _env_from_lock():
        try:
            header, tarballs = lockfile.read_text().split("@EXPLICIT")
        except:
            header = "# NO LOCKFILE"
            tarballs = []

        header = (f"# Probably don't edit by hand! \n"
                  f"#\n"
                  f"# This was generated from {lockfile.relative_to(P.ROOT)}\n"
                  f"#\n"
                  f"#   doit docs:rtdenv\n"
                  f"#\n") + header

        P.RTD_ENV.write_text(header + P.safe_dump(
            dict(
                name="rtd",
                channels=["conda-forge", "nodefaults"],
                dependencies=[
                    line.strip() for line in tarballs.strip().splitlines()
                ],
            )))

    yield dict(
        name="rtd:env",
        doc="generate a readthedocs-compatible env",
        file_dep=[lockfile],
        actions=[clean, _env_from_lock],
        targets=[P.RTD_ENV],
    )

    yield dict(
        name="sphinx",
        doc="build the docs with sphinx",
        actions=[[
            *run_in,
            "sphinx-build",
            "-W",
            "-a",
            "-b",
            "html",
            "docs",
            "build/docs/html",
        ]],
        file_dep=[
            frozen, *P.ALL_DOCS_SRC, *P.SETUP_CRUFT, *P.ROBOT_SRC, P.DODO
        ],
        targets=[P.DOCS_BUILDINFO],
    )