Skip to content

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.

Terminal window
gantry init --profile minimal

init 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:

Terminal window
$ gantry lint --strict
gantry.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 infos

Every 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.

A ruling is the one current answer for a pattern, with a cell per platform. Start a stub:

Terminal window
gantry new ruling --noun "Mobile tab bar" mobile-tab-bar

That writes docs/design/rulings/mobile-tab-bar.md with status: proposed. Fill it in and rule it:

---
id: mobile-tab-bar
noun: Mobile tab bar
status: ruled
owner: split
cells:
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.

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:

Terminal window
$ gantry lint --strict
docs/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 infos

The 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.
}
}
Terminal window
$ gantry generate
docs/design/generated/ledger.md
docs/design/generated/platforms/android.md
docs/design/generated/platforms/ios.md
docs/design/generated/platforms/web.md
$ gantry lint --strict
gantry.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 infos

generate 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.

Terminal window
gantry new defect --title "The tab bar clips under the home indicator" \
--class mistranslated --severity blocking --ruling mobile-tab-bar --platform ios

That 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:

Terminal window
$ gantry close D-0001
wrote docs/design/defects/D-0001.md
docs/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 generate

and exits 1. Add the line to docs/design/primers/ios.md, citing the defect:

---
platform: ios
lines:
- 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:

Terminal window
$ gantry close --owes primer:ios:pin-to-safe-area D-0001
wrote docs/design/defects/D-0001.md
generated pages may be stale; run gantry generate
$ gantry generate
docs/design/generated/platforms/ios.md
$ gantry lint --strict
…
0 errors, 0 warnings, 2 infos

The 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 rules lists 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/.