Skip to content
weft-sdkPublic

About

GitHub Action that checks Weft contracts for breaking changes and stale generated code

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Weft

Weft Action

Catch breaking contract changes, stale generated code and unformatted contracts in a pull request.

Test License

Weft  ·  weft check  ·  Contract evolution


Use it

name: contracts
on: pull_request

jobs:
  weft:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0        # weft check compares with your latest release tag
      - uses: weft-sdk/action@main

On every pull request it runs three checks and writes the result to the job summary:

Check Command Fails when
Breaking changes weft check A change breaks a sender or a receiver, and the package version does not say so
Generated code weft gen --check weft.gen.* does not match the contracts
Formatting weft fmt --check A .weft file is not in the canonical style

Each breaking change is also written as an error annotation on the run, with the place in the contract and what to do about it.

Inputs

Input Default What it does
version latest The weft version to install, like v0.1.0
working-directory . The folder that holds weft.yaml
check true Run weft check
baseline the latest tag Compare with this git ref: a tag, a branch or a commit
gen-check true Run weft gen --check
fmt-check true Run weft fmt --check

Outputs

Output What it is
passes true when every check that ran passed

Examples

Compare with the main branch instead of the latest tag:

- uses: weft-sdk/action@main
  with:
    baseline: origin/main

Only check that the generated code is current, in a repository with contracts in a subfolder:

- uses: weft-sdk/action@main
  with:
    working-directory: services/orders
    check: "false"
    fmt-check: "false"

Pin the version:

- uses: weft-sdk/action@main
  with:
    version: v0.1.0

How it installs weft

The action downloads the prebuilt weft binary for the runner (Linux, macOS or Windows, on x86-64 or arm64) from the releases of the Weft repository, and puts it on the PATH. When a release does not exist, it builds weft from source with cargo, which takes a few minutes.

When the repository has no release tag yet, weft check is skipped with a notice and the other two checks still run.

License

Apache License 2.0.

About

GitHub Action that checks Weft contracts for breaking changes and stale generated code

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages