#task-runner #build #outputs #smart #run #script #hash

app faster-build

简单且智能的多语言任务运行器

4 个版本 (破坏性更新)

0.5.0 2022年5月16日
0.4.0 2022年5月8日
0.3.0 2022年4月25日
0.2.0 2022年4月24日

开发工具 中排名 1503

GPL-3.0-or-later

75KB
2K SLoC

Faster – Language-agnostic task runner

GitHub Actions workflow status Code coverage report Crates.io version

更快的构建 是一个适用于具有许多可动部分的存储库的多语言任务运行器。它旨在简单透明,但非常可配置,适用于各种用途。

更快的构建与 make 类似,您可以定义目标和它们之间的依赖关系,但它会哈希所有依赖项,并仅重新运行更改过的目标,智能地并行运行不冲突的任务,并为您保留最近的构建工件和日志以供检查。

哦,而且它非常 快速

安装

使用 asdf-vm

asdf plugin add faster https://github.com/happenslol/asdf-faster
asdf install faster latest
asdf global faster latest

要手动安装更快的构建,您可以下载最新版本中的一个二进制文件并将其移动到您的路径中

# Make sure you have `jq` installed!
export FASTER_VERSION=curl -s https://api.github.com/repos/happenslol/faster/releases/latest | jq -r '.tag_name'
export FASTER_ARCH=x86_64-unknown-linux-musl
curl -Lo faster.tar.gz https://github.com/happenslol/faster/releases/download/${FASTER_VERSION}/faster-${FASTER_ARCH}.tar.gz
tar xvf faster.tar.gz
sudo mv faster /usr/local/bin/

您也可以通过 cargo 安装更快的构建

cargo install faster-build --locked

用法

在您的存储库根目录中创建一个 faster.yaml 文件来配置您的任务。以下是一个带有说明的示例文件

environment:
  # Globally set env variables for
  # all tasks that can be run
  FOO: "literal value"
  BAR: "${VALUE_FROM_HOST_ENV}"
  BAZ: "$(echo 'value from a command')"

tasks:
  generate:
    # Shell script which will generate your outputs
    script: |
      echo "Outputting code into testfile"
      echo "foo" > gen/my-output
      echo "Succeeded!"

    # Outputs that will be generated by your script
    # Globs are possible here
    outputs:
      - gen/**

    # Input files that should trigger a rerun of the task
    # Globs are possible here
    inputs:
      - go.mod
      - go.sum
      - ./**/*.go

  # Tasks without any outputs are also possible
  lint:
    script: ./run-linter.sh
    inputs:
      - ./**/*.go

  build:
    script: go build -o foo
    inputs:
      - ./**/*.go
      - go.mod
      - go.sum

    # Define other tasks that must be up-to-date before
    # this task can be run
    dependencies:
      - generate

    environment:
      # Set an env variable just for this task
      FOO: "bar"

  # Tasks without any outputs or files can be
  # used to group other tasks as a meta-target
  all:
    dependencies:
      - lint
      - build

使用此配置,faster run all 将构建一个依赖图并构建所有目标。

运行 faster help 查看所有命令行选项。

环境变量

您可以为全局任务和每个任务设置环境变量,这些变量将在任务脚本中可用。这些值将使用 shell 进行评估,这意味着您可以包括使用 $(my_command) 或使用 $}FOO:-default} 的命令或默认值。

请注意,评估的变量 将包含在哈希中,这意味着全局环境变量应使用得少,因为它们可能会使所有存储的任务结果无效。

贡献

欢迎提交拉取请求。对于重大更改,请首先提交一个问题以讨论您想要更改的内容。

请确保适当地更新测试。

许可

GPL 3.0

依赖

~9–20MB
~264K SLoC