Your first project
This walks through a new project from gantry init to a closed defect. Run
it in a git repository; every command takes --dir <path> to work
somewhere else.
Set up
Section titled “Set up”gantry init --profile minimalinit writes gantry.yaml (three platforms, web, ios and android),
the content directories under docs/design/, a .gitattributes that keeps
evidence in Git LFS, and the generated pages. The reference profile is a
larger start: five platforms, a shared core and example apps and gates.
Lint it:
$ gantry lint --strictgantry.yaml:8: info test-globs-empty: web: no file matches "**/*.test.ts" (platforms.web.tests[0])…assertions test-globs-empty: examined 4, findings 4…0 errors, 0 warnings, 4 infosEvery run ends with a tally that names each rule, what it examined and what
it found (shortened here). The infos say that no test file matches a
platform’s tests globs in gantry.yaml yet: point the globs at your
tests. --strict fails on warnings as well as errors.
Rule a pattern
Section titled “Rule a pattern”A ruling is the one current answer for a pattern, with a cell per platform. Start a stub:
gantry new ruling --noun "Mobile tab bar" mobile-tab-barThat writes docs/design/rulings/mobile-tab-bar.md with status: proposed.
Fill it in and rule it:
---id: mobile-tab-barnoun: Mobile tab barstatus: ruledowner: splitcells: web: "n/a: the web app has no tab bar" ios: "A bottom tab bar of five destinations." android: "A navigation bar of five destinations."assertions: - {kind: ui-test, ref: TabBarUITests.testFiveDestinations, platform: ios} - {kind: ui-test, ref: TabBarTest.fiveDestinations, platform: android}---Five destinations fit one thumb's reach; a sixth goes under More.Every platform has a cell: an answer, or n/a: <reason>. Each assertion
names a test that holds the ruling. See
rulings and cells.
Write the tests it names
Section titled “Write the tests it names”Lint finds each assertion’s symbol in that platform’s test files, matched by
the tests globs in gantry.yaml. It searches for the declaration; it never
runs the tests. Until the tests exist, lint fails:
$ gantry lint --strictdocs/design/generated/ledger.md: error generated-stale: docs/design/generated/ledger.md is out of date…docs/design/rulings/mobile-tab-bar.md:11: error assertion-unresolved: ui-test TabBarUITests.testFiveDestinations is not declared in the ios test files (**/*UITests*/**/*.swift) (assertions[0])docs/design/rulings/mobile-tab-bar.md:12: error assertion-unresolved: ui-test TabBarTest.fiveDestinations is not declared in the android test files (**/src/*Test/**/*.kt) (assertions[1])…6 errors, 0 warnings, 4 infosThe four generated-stale errors go away in the next step; the two
assertion-unresolved errors need the tests.
In your app the tests already exist; here, write two that match the
minimal profile’s globs. ios/TabBarUITests/TabBarUITests.swift:
import XCTest
final class TabBarUITests: XCTestCase { func testFiveDestinations() throws { // Launch the app and count the tab bar's buttons. }}and android/app/src/androidTest/TabBarTest.kt:
class TabBarTest { @Test fun fiveDestinations() { // Launch the app and count the navigation bar's items. }}Generate and lint
Section titled “Generate and lint”$ gantry generatedocs/design/generated/ledger.mddocs/design/generated/platforms/android.mddocs/design/generated/platforms/ios.mddocs/design/generated/platforms/web.md$ gantry lint --strictgantry.yaml:8: info test-globs-empty: web: no file matches "**/*.test.ts" (platforms.web.tests[0])gantry.yaml:8: info test-globs-empty: web: no file matches "**/e2e/**/*.ts" (platforms.web.tests[1])…0 errors, 0 warnings, 2 infosgenerate rewrites docs/design/generated/ and lists the files it
changed: ledger.md, the page to read before changing a UI, with one row
per pattern; defects.md; and a page per platform. Lint fails with generated-stale whenever those pages are out of
date, so run generate after every change to the records. The two infos
remain because the web platform has no tests yet; they never fail a run.
File and close a defect
Section titled “File and close a defect”gantry new defect --title "The tab bar clips under the home indicator" \ --class mistranslated --severity blocking --ruling mobile-tab-bar --platform iosThat writes docs/design/defects/D-0001.md, open. A defect’s class says what
went wrong, and what closing it owes: in the minimal profile, a
mistranslated defect (the ruling was right, the platform got it wrong)
owes a primer line. Closing it with nothing owed fails:
$ gantry close D-0001wrote docs/design/defects/D-0001.mddocs/design/defects/D-0001.md:8: error defect-closed-owing: a closed defect owes nothing: it closes by discharging a gate check, a primer line, an assertion or a ruling amendment (owes)generated pages may be stale; run gantry generateand exits 1. Add the line to docs/design/primers/ios.md, citing the
defect:
---platform: ioslines: - id: pin-to-safe-area wrong: Pin a bar to the screen edge. right: Pin it to the safe area. defect: D-0001---What keeps going wrong on iOS.then close the defect with that owe, regenerate and lint:
$ gantry close --owes primer:ios:pin-to-safe-area D-0001wrote docs/design/defects/D-0001.mdgenerated pages may be stale; run gantry generate$ gantry generatedocs/design/generated/platforms/ios.md$ gantry lint --strict…0 errors, 0 warnings, 2 infosThe iOS page now carries the primer line, and lint exits 0.
See defects and owes and primers.
- Run the same checks on every pull request: Gantry in CI.
gantry ruleslists every lint rule;gantry explain <rule-id>says what one checks and how to fix it.- Two complete projects to read are in the repository’s
examples/.