> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub Action

> Run loadwise check in pull requests with annotations and SARIF upload.

The repository root is a composite action that runs `loadwise check`, prints annotations on the pull request and uploads SARIF to code scanning.

```yaml theme={null}
name: loadwise
on: pull_request
permissions:
  contents: read
  security-events: write
jobs:
  loadwise:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: IbrahimHafez1/loadwise@v0
        with:
          changed-only: true
          fail-on: contract
```

| Input | Default | Meaning |
| - | - | - |
| `checkers` | all | Passed to `--only`, for example `perf,rel,a11y`. |
| `path` | `.` | Directory to check. |
| `changed-only` | `false` | Compare changed lines against the event base or `base-sha`. |
| `base-sha` | Event base | Full commit SHA to use for a changed-only run. |
| `fail-on` | checker default | Passed to `--fail-on` (`contract` or `all`). |
| `upload-sarif` | `true` | Uploads the SARIF report with `github/codeql-action/upload-sarif@v4`; needs `security-events: write`. |
| `annotations` | `true` | Prints findings as workflow annotations. |
| `config` | — | Loadwise config file relative to `path`. |
| `baseline` | — | Existing baseline file relative to `path`. |
| `workspaces` | all | Workspace names or paths, one per line. |
| `skip` | — | Comma-separated checkers to skip. |
| `min-impact` | checker default | Passed to `--min-impact`. |
| `ignore` | — | Rule IDs to ignore, one per line. |
| `include-contextual` | `false` | Include findings that need additional context. |
| `online` | `false` | Opt in to online dependency advisory checks. |

For `changed-only`, a pull request uses its base SHA, a push uses its `before` SHA, and a merge queue run uses the `merge_group` base SHA. Set `base-sha` to override the event, including for other triggers. Use `actions/checkout` with `fetch-depth: 0` and make sure it has the base commit. If the base is missing, all zeros, invalid, or cannot be compared with `HEAD`, the action warns and runs a full source scan.

An event-derived push base must be an ancestor of `HEAD`. Rollbacks and divergent force pushes fall back to a full source scan since a common ancestor can omit files reintroduced by the push. If you pass the previous tip as `base-sha` for such a push, the comparison starts at its common ancestor with `HEAD`.

When Reliability is selected, changed-only runs require a usable API comparison base for pull requests, explicit `base-sha` overrides, and any trigger using `fail-on: contract`. If the comparison is unavailable, the action runs the full source scan and reports exit code 2 without uploading incomplete SARIF. A new-branch push with an all-zero event base still uses the source-only fallback under the default or `all` threshold.

With `online: true` and Security selected, the action starts dependency discovery in the scan directory and searches eligible ancestors. The nearest npm, pnpm, or Yarn lockfile takes precedence. If none is found, the action selects the nearest Cargo, Deno, or Bun lockfile. Advisory lookups can send eligible package names, ecosystems, and pinned versions from that inventory to OSV, including when `changed-only` is enabled.

The action installs its locked runtime dependencies in a runner temporary directory and runs the source at the selected action ref. It caches that built runtime with `actions/cache`, keyed by the Action's own files and lock file, the runner OS and architecture, and the Node version. A later job restores the cache only after every file matches the manifest written by the build; any mismatch or cache failure falls back to a fresh install. Pull requests from forks read existing caches but never save one, and GitHub scopes pull request caches to their own ref. With only an `on: pull_request` trigger, as in the example above, each pull request saves its own copy, which only later runs of that pull request restore. To share one cache across pull requests and save cache quota, also run the workflow on `push` to the default branch. The log reports setup and scan time separately. The runtime and the cache staging directory are removed after each run, so persistent self-hosted runners do not accumulate them; the SARIF report stays in place until the upload step. SARIF, annotations and the job summary share one scan. The summary shows findings, skipped files and coverage by checker. When a workflow is cancelled, neither SARIF upload nor exit-code propagation runs.

Give the Action step an `id` to read its `exit-code` and `sarif-file` outputs. The exit code is the completed scan's status, `0`, `1` or `2`. It is empty if the scan never wrote a result. The SARIF path is empty when upload is disabled or the scan produces no usable report. A later step can read the outputs with an appropriate condition such as `if: failure()` after a failing scan.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.