Build servers

TrailsBI runs on a build server as it does on your machine: it needs Python 3.9 or later, no sign-in and no network. This is what is different there, and an example for GitHub Actions.

What is different

  • No runs are saved when CI, TF_BUILD or GITHUB_ACTIONS is set. So trailsbi diff needs two folders there: the old version and the new one. To save runs all the same, set TRAILSBI_HISTORY to the full path of a folder that stays.
  • Findings don't fail the build. TrailsBI ends with 0 when it did its work, whatever it found. Fail the build yourself with the JSON.
Exit code When
0 It did what was asked
1 A file could not be read or written
2 The arguments are wrong, or there is nothing to work on

The impact of a pull request

Check out both versions next to each other and compare them. This shows the report in the summary of the run:

name: Impact
on: pull_request
permissions:
  contents: read
jobs:
  impact:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.base.sha }}
          path: old
      - uses: actions/checkout@v4
        with:
          path: new
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: python -m pip install trailsbi
      - run: trailsbi diff old new --md --json -o impact
      - run: cat impact.md >> "$GITHUB_STEP_SUMMARY"

When the repository holds one project, give diff its folder in both, such as old/Sales and new/Sales.

Markdown shows names and code from the project to everyone who can see the run. Check for secrets first, and treat it like the project itself.

Fail the build when something breaks

impact.json lists what the change breaks in broken. This step ends with 1 when there is anything in it:

      - run: python -c "import json, sys; sys.exit(bool(json.load(open('impact.json', encoding='utf-8'))['broken']))"

The same works for the security check, which lists secrets in findings:

      - run: trailsbi scan new --json -o scan.json
      - run: python -c "import json, sys; sys.exit(any(f['section'] == 'secret' for f in json.load(open('scan.json', encoding='utf-8'))['findings']))"

The diff's JSON and the scan's JSON describe what else is in them.

A page for every commit

  • trailsbi "$PWD" -o lineage.html

The page is one file that loads nothing, so you can publish it or keep it with the build. It shows the project as it is, so publish it only where the project may go.

Without installing

Each release has the whole tool as one file. Trust shows how to check its SHA-256.

  • python trailsbi.pyz "$PWD" -o lineage.html