Skip to content

v0.1.0

Latest

Choose a tag to compare

@github-actions github-actions released this 14 Nov 09:19
· 35 commits to main since this release
e7814df

do-anything v0.1.0

English

This project was originally named test-anything and its command was ta. It
does more than test: one case can call an API, run a command-line program,
observe a log file and read a database, so the project is now do-anything, the
command is da, and the version starts again at 0.1.0.

Features

  • http.request calls an HTTP or HTTPS API and returns status, headers and
    body, parsed when the response is JSON.
  • cli.run runs a command-line program without a shell and returns exit_code,
    stdout, stderr and json, with a timeout.
  • db.query runs one read-only statement against SQLite (sqlite:path) or
    PostgreSQL (postgres://) and returns columns, rows, row_count and
    truncated for expect and save. Writes and statement lists are refused at
    two layers, and the database is never created.
  • observe: declares read-only observers that run around every step; their
    results appear under observed.<name> before the assertions run and in
    failure bundles. The built-in log.file reports the lines a step added to a
    log file.
  • A case can hold long-lived resources through a session contract: a plugin
    declares its own type, implements Session, and stores it under a kind it
    chooses. The resource belongs to one case, is created on first use and is
    closed when the case ends, including on failure and under --jobs; the core
    knows no concrete session type.
  • vars, save, --var name=value and --vars-file supply values, referenced
    as ${name}. ${env:NAME} reads the environment, and every value read that
    way is replaced with *** in text and JSON output, error messages and failure
    bundles.
  • --jobs N runs up to N cases at once. Results, output order, failure bundles
    and exit codes are the same as a serial run.
  • Cases may declare project, suite, layer and tags; da run selects
    them with repeatable --project, --suite, --layer, --tag and
    --skip-tag.
  • equals, not_equals, contains and exists assert on any JSONPath, and a
    structural mistake in a case names its line and column.
  • da lint validates cases without running them and reports every problem at
    once; da schema prints a JSON Schema of the case format with every
    registered step.
  • --output json writes exactly one JSON object. Every case that does not pass
    leaves a failure bundle with case.yaml, report.json and meta.json
    (written last).

Renamed

  • The package is do-anything, the library is do_anything, and the binary is
    da.
  • meta.json carries da_version instead of ta_version, and the case schema
    title is da case file.
  • Failure bundles go to .da/failures by default, and .da/ is ignored by git.
  • The install scripts read DA_VERSION, DA_INSTALL_DIR, DA_DOWNLOAD_URL and
    DA_NO_MODIFY_PATH.
  • Release archives are named da-v<version>-<platform>, and releases start
    again at v0.1.0.

Notes

  • Each capability is behind a cargo feature: http, cli, log and db, all
    enabled by default. Build a smaller binary with --no-default-features and
    the features you need.

Install

Linux and macOS:

curl -fsSL https://raw.githubusercontent.com/LnYo-Cly/do-anything/main/install.sh | sh

Windows:

irm https://raw.githubusercontent.com/LnYo-Cly/do-anything/main/install.ps1 | iex

Or download the archive for your platform below, extract it, and put da on
your PATH. Verify the download with SHA256SUMS.

Platform Archive
Linux x86_64 da-v0.1.0-x86_64-unknown-linux-musl.tar.gz
Linux arm64 da-v0.1.0-aarch64-unknown-linux-musl.tar.gz
macOS Intel da-v0.1.0-x86_64-apple-darwin.tar.gz
macOS Apple silicon da-v0.1.0-aarch64-apple-darwin.tar.gz
Windows x86_64 da-v0.1.0-x86_64-pc-windows-msvc.zip
Windows arm64 da-v0.1.0-aarch64-pc-windows-msvc.zip

The binaries are not code-signed. On macOS, run xattr -d com.apple.quarantine da
if the system blocks a manually downloaded binary.

中文

本项目原名 test-anything,命令原为 ta。它不只做测试:一个用例可以同时调用接口、
运行命令行程序、观察日志文件并读取数据库,所以项目现在叫 do-anything,命令是 da,
版本从 0.1.0 重新开始。

功能

  • http.request 调用 HTTP 或 HTTPS 接口,返回 status、headers 和 body,
    响应是 JSON 时自动解析。
  • cli.run 不经 shell 运行命令行程序,返回 exit_code、stdout、stderr 和
    json,并支持超时。
  • db.query 对 SQLite(sqlite:路径)或 PostgreSQL(postgres://)执行一条只读
    语句,返回 columns、rows、row_count 和 truncated,可用于 expect 与
    save。写语句和多条语句在两层被拒绝,数据库文件不会被创建。
  • observe: 声明只读观察者,在每个步骤前后运行;结果在断言之前并入
    observed.<名字>,也写入失败包。内置的 log.file 报告步骤期间日志文件新增的行。
  • 用例可以通过会话契约持有长期资源:插件声明自己的类型、实现 Session,并以自己
    选择的名字存放。资源属于单个用例,首次使用时创建,用例结束时关闭,失败路径和
    --jobs 下也一样;核心不知道任何具体会话类型。
  • vars、save、--var name=value 和 --vars-file 提供变量,以 ${name} 引用。
    ${env:NAME} 读取环境变量,这样读到的值在文本与 JSON 输出、错误信息和失败包中
    都替换为 ***。
  • --jobs N 同时运行最多 N 个用例;结果、输出顺序、失败包与退出码和串行一致。
  • 用例可以声明 project、suite、layer 和 tags,da run 用可重复的
    --project、--suite、--layer、--tag 和 --skip-tag 选择要运行的部分。
  • equals、not_equals、contains 和 exists 可断言任意 JSONPath;用例的结构性
    错误会给出行号和列号。
  • da lint 不执行用例就完成校验,并一次报出所有问题;da schema 输出用例格式的
    JSON Schema,包含所有已注册的步骤。
  • --output json 只输出一个 JSON 对象。每个未通过的用例都会留下失败包,含
    case.yaml、report.json 和 meta.json(最后写入)。

改名

  • 包名为 do-anything,库名为 do_anything,命令为 da。
  • meta.json 的字段 ta_version 改为 da_version,用例 schema 的标题改为
    da case file。
  • 失败包默认写入 .da/failures,.da/ 已被 git 忽略。
  • 安装脚本读取 DA_VERSION、DA_INSTALL_DIR、DA_DOWNLOAD_URL 和
    DA_NO_MODIFY_PATH。
  • 发布压缩包命名为 da-v<版本>-<平台>,版本从 v0.1.0 重新开始。

说明

  • 每项能力各在一个 cargo feature 后面:http、cli、log、db,默认全部开启。
    需要更小的二进制时,用 --no-default-features 加上所需 feature 自行构建。

安装

Linux 与 macOS:

curl -fsSL https://raw.githubusercontent.com/LnYo-Cly/do-anything/main/install.sh | sh

Windows:

irm https://raw.githubusercontent.com/LnYo-Cly/do-anything/main/install.ps1 | iex

或下载对应平台的压缩包,解压后把 da 放到 PATH 中。可用 SHA256SUMS 校验下载
文件。

平台 压缩包
Linux x86_64 da-v0.1.0-x86_64-unknown-linux-musl.tar.gz
Linux arm64 da-v0.1.0-aarch64-unknown-linux-musl.tar.gz
macOS Intel da-v0.1.0-x86_64-apple-darwin.tar.gz
macOS Apple silicon da-v0.1.0-aarch64-apple-darwin.tar.gz
Windows x86_64 da-v0.1.0-x86_64-pc-windows-msvc.zip
Windows arm64 da-v0.1.0-aarch64-pc-windows-msvc.zip

二进制文件没有代码签名。手动下载的二进制在 macOS 上被拦截时,执行
xattr -d com.apple.quarantine da。