|
| 1 | +# Workspace Configuration |
| 2 | + |
| 3 | +Shared configuration files that should be placed in the **root** of each CAMARA API repository. |
| 4 | + |
| 5 | +These files standardize editor behavior, line-ending enforcement, and ignored-file patterns across all contributors, regardless of OS or IDE. |
| 6 | + |
| 7 | +## Files |
| 8 | + |
| 9 | +| File | Purpose | Placement in API repo | |
| 10 | +|------|---------|----------------------| |
| 11 | +| `.editorconfig` | Consistent indentation, charset, and line endings across editors ([spec](https://editorconfig.org)) | Copy as-is to repo root | |
| 12 | +| `.gitattributes` | Enforces LF line endings at the Git layer and marks binary formats | Copy as-is to repo root | |
| 13 | +| `.gitignore-template` | Common ignore patterns for OS, editor, and tooling artifacts | Copy to repo root **and rename** to `.gitignore` | |
| 14 | + |
| 15 | +> `.gitignore-template` is named with a `-template` suffix so that Git does not pick it up inside this tooling repository itself. |
| 16 | +
|
| 17 | +## Adoption |
| 18 | + |
| 19 | +To adopt these configurations in an API repository: |
| 20 | + |
| 21 | +1. Copy `.editorconfig` and `.gitattributes` into the repository root. |
| 22 | +2. Copy `.gitignore-template` to the repository root and rename it to `.gitignore`. Merge with any existing `.gitignore` entries the repo already has. |
| 23 | +3. Commit and push. |
| 24 | + |
| 25 | +If the repository already contains files with CRLF line endings, a separate normalization PR should be created after `.gitattributes` is in place — see [#113](https://github.com/camaraproject/tooling/issues/113) for the migration approach. |
| 26 | + |
| 27 | +## How the files work together |
| 28 | + |
| 29 | +- `.editorconfig` guides editors to use the correct settings **while editing**, so contributors produce correctly formatted files from the start. |
| 30 | +- `.gitattributes` acts as a **safety net at the Git layer** — even if an editor writes CRLF, Git normalizes to LF on commit. |
| 31 | +- `.gitignore` keeps OS junk and editor artifacts out of version control. |
| 32 | + |
| 33 | +## Alignment with linting rules |
| 34 | + |
| 35 | +The `.editorconfig` settings are derived from the existing linting configurations in [`linting/config/`](../linting/config/): |
| 36 | + |
| 37 | +- **YAML** indent/whitespace rules match [`.yamllint.yaml`](../linting/config/.yamllint.yaml) |
| 38 | +- **Gherkin** indent rules match [`.gherkin-lintrc`](../linting/config/.gherkin-lintrc) |
| 39 | + |
| 40 | +This keeps editor formatting and CI linting in sync, so contributors get feedback while editing rather than failing in CI. |
0 commit comments