[engine] Add ok_retcodes param to ctx.os.exec

This helps reduce boilerplate when handling exec'd subprocesses that
have multiple exit codes that are considered non-fatal.

Before:

  res = ctx.os.exec(["foo"], raise_on_failure = False).wait()
  if res.retcode not in [0, 1]:
    fail("foo returned unexpected retcode %d", res.retcode)

After:

  res = ctx.os.exec(["foo"], ok_retcodes = [0, 1]).wait()

We continue to support `raise_on_failure` for backwards compatibility,
and for any command where no exit codes should be considered fatal.

This was inspired by the `ok_ret` parameter to the recipe engine's
`api.step()` command:
https://chromium.googlesource.com/infra/luci/recipes-py/+/a72ad3ee2f4bc2f63f120a0ab4007afc1824feb6/recipe_modules/step/api.py#621

Change-Id: I31c41c8690f6078af939cab6ee0b24cb701a68d2
Reviewed-on: https://fuchsia-review.googlesource.com/c/shac-project/shac/+/869417
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Oliver Newman <olivernewman@google.com>
Reviewed-by: Marc-Antoine Ruel <maruel@google.com>
8 files changed
tree: 90a1d44f37a78a54699d93fe3da718640b0656e9
  1. .github/
  2. doc/
  3. images/
  4. internal/
  5. scripts/
  6. .gitignore
  7. AUTHORS
  8. check_doc.star
  9. codecov.yml
  10. CONTRIBUTING.md
  11. go.mod
  12. go.star
  13. go.sum
  14. LICENSE
  15. licenses.star
  16. main.go
  17. OWNERS
  18. PATENTS
  19. README.md
  20. shac.star
  21. shac.textproto
README.md

shac

Shac (Scalable Hermetic Analysis and Checks) is a unified and ergonomic tool and framework for writing and running static analysis checks.

Shac checks are written in Starlark.

usage demonstration

Usage

go install go.fuchsia.dev/shac-project/shac@latest
shac check
shac doc shac.star | less

Documentation

Contributing

⚠ The source of truth is at https://fuchsia.googlesource.com/shac-project/shac.git and uses Gerrit for code review.

See CONTRIBUTING.md to submit changes.