Check the rules in CI
mortise check reads an app the way the window does and fails when a rule breaks. It runs no PHP and
writes nothing in the app, so a CI job needs only the files of the app and the tool.
The rules come from mortise.json; without the file the defaults apply.
-
Check the app on your machine first. From the app folder:
Terminal window mortise checkEach problem is one line with its file and line. The exit code is 1 when a problem is found. To get the tool, see Install the command line tool.
-
Add a job to your workflow. This one is for GitHub Actions, with the app at the root of the repository:
jobs:boundaries:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v5- uses: mortise-dev/setup-mortise@v1- run: mortise check --format githubmortise-dev/setup-mortisedownloads the tool of the latest release, checks its SHA-256 and puts it onPATH, in a few seconds and with no Rust toolchain. On another CI, download the archive of the release or runcargo install --locked mortise-cli.--format githubprints each problem as a workflow command, so GitHub marks the line in the pull request. A file that reads an internal class of another module gets a mark of its own. -
Commit
mortise.jsonwith the workflow, so that CI checks the rules your team chose.
The job fails on every problem in the commit it checks, not only on the problems the pull request adds. Fix the problems that are there first, or start with Fail CI when a rule breaks off.
Check on Windows or macOS
Section titled “Check on Windows or macOS”The tool and the action work on Linux, macOS and Windows runners. Only runs-on changes:
jobs: boundaries: runs-on: windows-latest steps: - uses: actions/checkout@v5 - uses: mortise-dev/setup-mortise@v1 with: version: v0.3.0 - run: mortise check --format githubThe paths in the report use / on every platform, so GitHub marks the same lines on each runner.
version pins a release. Without it the action installs the latest one.
Report without failing
Section titled “Report without failing”To see the problems in the CI log without failing the job, turn off Fail CI when a rule breaks in
the rules box of the Boundary tab, or set it in mortise.json:
{ "ci": { "fail": false }}mortise check then prints the same report, says on standard error that the check passes, and exits 0.
Fail on warnings too
Section titled “Fail on warnings too”A warning, such as a module under the coverage limit, does not fail the check. Add --fail-on warnings
to make it fail. The coverage limit and report come from the coverage object of mortise.json, or
from the flags --coverage-limit and --coverage, which win over the file.
The flags and exit codes are in Command line tool.
To send each read to Mortise Cloud as well, see Send a read to Mortise Cloud.