|
| 1 | +# New repository checklist |
| 2 | + |
| 3 | +Conventions used by sara-*, flotilla, and isar-* repositories in `equinor/`. When creating a new service repo (usually from [`equinor/sara-python-template`](https://github.com/equinor/sara-python-template)), work through this checklist. |
| 4 | + |
| 5 | +Every item includes a `gh`/`gh api` command to verify it. Run these against an existing well-configured repo (e.g. `equinor/sara-timeseries`) if you're unsure what the target state looks like. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 0. Prerequisites |
| 10 | + |
| 11 | +- Repo exists under `equinor/`. |
| 12 | +- You have `Admin` on the repo (needed for most items below). |
| 13 | +- `gh` is authenticated (`gh auth status`). |
| 14 | + |
| 15 | +```bash |
| 16 | +REPO=equinor/sara-your-service |
| 17 | +``` |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## 1. Repository settings |
| 22 | + |
| 23 | +| Setting | Value | Rationale | |
| 24 | +|---|---|---| |
| 25 | +| Allow squash merging | off | Rebase-only keeps linear history matching the required-linear-history ruleset | |
| 26 | +| Allow merge commits | off | Same | |
| 27 | +| Allow rebase merging | on | Only supported merge method | |
| 28 | +| Automatically delete head branches | on | Keeps branch list clean | |
| 29 | + |
| 30 | +**Set:** |
| 31 | +```bash |
| 32 | +gh api -X PATCH "/repos/$REPO" \ |
| 33 | + -F allow_squash_merge=false \ |
| 34 | + -F allow_merge_commit=false \ |
| 35 | + -F allow_rebase_merge=true \ |
| 36 | + -F delete_branch_on_merge=true |
| 37 | +``` |
| 38 | + |
| 39 | +**Verify:** |
| 40 | +```bash |
| 41 | +gh api "/repos/$REPO" --jq '{squash:.allow_squash_merge, merge:.allow_merge_commit, rebase:.allow_rebase_merge, del:.delete_branch_on_merge}' |
| 42 | +# Expected: {"squash":false,"merge":false,"rebase":true,"del":true} |
| 43 | +``` |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## 2. Branch ruleset on `main` |
| 48 | + |
| 49 | +We use a **repository ruleset** (not the legacy "branch protection" API) named `main`, targeting the default branch. |
| 50 | + |
| 51 | +Rules: |
| 52 | +- `deletion` — block deletion of `main` |
| 53 | +- `non_fast_forward` — block force-pushes |
| 54 | +- `required_linear_history` |
| 55 | +- `pull_request` — require a PR before merging, with: |
| 56 | + - `required_approving_review_count: 1` |
| 57 | + - `require_code_owner_review: false` |
| 58 | + - `allowed_merge_methods: ["rebase"]` |
| 59 | + |
| 60 | +**Set (adjust `bypass_actors` team id to match your admin/dev team):** |
| 61 | +```bash |
| 62 | +gh api -X POST "/repos/$REPO/rulesets" \ |
| 63 | + -H "Accept: application/vnd.github+json" \ |
| 64 | + --input - <<'JSON' |
| 65 | +{ |
| 66 | + "name": "main", |
| 67 | + "target": "branch", |
| 68 | + "enforcement": "active", |
| 69 | + "conditions": {"ref_name": {"include": ["~DEFAULT_BRANCH"], "exclude": []}}, |
| 70 | + "rules": [ |
| 71 | + {"type": "deletion"}, |
| 72 | + {"type": "non_fast_forward"}, |
| 73 | + {"type": "required_linear_history"}, |
| 74 | + {"type": "pull_request", "parameters": { |
| 75 | + "required_approving_review_count": 1, |
| 76 | + "dismiss_stale_reviews_on_push": false, |
| 77 | + "require_code_owner_review": false, |
| 78 | + "require_last_push_approval": false, |
| 79 | + "required_review_thread_resolution": false, |
| 80 | + "allowed_merge_methods": ["rebase"] |
| 81 | + }} |
| 82 | + ] |
| 83 | +} |
| 84 | +JSON |
| 85 | +``` |
| 86 | + |
| 87 | +**Verify:** |
| 88 | +```bash |
| 89 | +gh api "/repos/$REPO/rulesets" --jq '.[] | {name, target, enforcement, rules: [.rules[]?.type]}' |
| 90 | +``` |
| 91 | + |
| 92 | +Expected output includes a ruleset with `["deletion","non_fast_forward","required_linear_history","pull_request"]`. |
| 93 | + |
| 94 | +**Known drift across existing repos:** |
| 95 | +- `sara-utilities`, `sara-stid` have no ruleset — need one added. |
| 96 | +- `sara-anonymizer` uses `required_approving_review_count: 0`; the convention is `1`. |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## 3. Required status checks |
| 101 | + |
| 102 | +Once the workflows have run at least once (so the check contexts are visible), add them to the ruleset. Standard checks for a Python service using the template: |
| 103 | + |
| 104 | +- `test-and-lint-python-package / build (3.14)` |
| 105 | +- `trivy-scan / Scan with Trivy` |
| 106 | + |
| 107 | +**Add to the existing ruleset:** |
| 108 | +```bash |
| 109 | +RULESET_ID=$(gh api "/repos/$REPO/rulesets" --jq '.[] | select(.name=="main") | .id') |
| 110 | +gh api -X PUT "/repos/$REPO/rulesets/$RULESET_ID" \ |
| 111 | + -H "Accept: application/vnd.github+json" \ |
| 112 | + --input - <<'JSON' |
| 113 | +{ |
| 114 | + "rules": [ |
| 115 | + {"type": "deletion"}, |
| 116 | + {"type": "non_fast_forward"}, |
| 117 | + {"type": "required_linear_history"}, |
| 118 | + {"type": "pull_request", "parameters": { |
| 119 | + "required_approving_review_count": 1, |
| 120 | + "dismiss_stale_reviews_on_push": false, |
| 121 | + "require_code_owner_review": false, |
| 122 | + "require_last_push_approval": false, |
| 123 | + "required_review_thread_resolution": false, |
| 124 | + "allowed_merge_methods": ["rebase"] |
| 125 | + }}, |
| 126 | + {"type": "required_status_checks", "parameters": { |
| 127 | + "strict_required_status_checks_policy": true, |
| 128 | + "required_status_checks": [ |
| 129 | + {"context": "test-and-lint-python-package / build (3.14)"}, |
| 130 | + {"context": "trivy-scan / Scan with Trivy"} |
| 131 | + ] |
| 132 | + }} |
| 133 | + ] |
| 134 | +} |
| 135 | +JSON |
| 136 | +``` |
| 137 | + |
| 138 | +**Verify:** |
| 139 | +```bash |
| 140 | +gh api "/repos/$REPO/rulesets/$RULESET_ID" \ |
| 141 | + --jq '.rules[] | select(.type=="required_status_checks") | .parameters.required_status_checks[].context' |
| 142 | +``` |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +## 4. GitHub Environments |
| 147 | + |
| 148 | +Optional, but required if the deploy workflows are called with `environment_name: Development`. |
| 149 | + |
| 150 | +| Environment | Required reviewers | Deployment branch policy | |
| 151 | +|---|---|---| |
| 152 | +| `Development` | usually none | `main` only | |
| 153 | +| `Staging` | usually none | tags matching `v*` | |
| 154 | +| `Production` | 1+ reviewers | tags matching `v*` | |
| 155 | + |
| 156 | +**Create (example, `Development`):** |
| 157 | +```bash |
| 158 | +gh api -X PUT "/repos/$REPO/environments/Development" \ |
| 159 | + -F 'deployment_branch_policy[protected_branches]=false' \ |
| 160 | + -F 'deployment_branch_policy[custom_branch_policies]=true' |
| 161 | +``` |
| 162 | + |
| 163 | +**Verify environments exist:** |
| 164 | +```bash |
| 165 | +gh api "/repos/$REPO/environments" --jq '.environments[].name' |
| 166 | +``` |
| 167 | + |
| 168 | +**Known drift:** most sara repos have zero environments; `sara-anonymizer` has `Development` and `Staging` but no `Production`. Set up all three or none, but keep consistent. |
| 169 | + |
| 170 | +--- |
| 171 | + |
| 172 | +## 5. Actions secrets |
| 173 | + |
| 174 | +The deploy workflows in `equinor/armada` expect these **repository secrets** (or org-inherited). Only add per-repo secrets if the values are actually specific to this repo — otherwise inherit from the org. |
| 175 | + |
| 176 | +Required: |
| 177 | + |
| 178 | +- `ROBOTICS_ROBOTICSDEVACR_USERNAME` / `_PASSWORD` — dev registry |
| 179 | +- `ROBOTICS_ROBOTICSSTAGINGACR_USERNAME` / `_PASSWORD` — staging registry |
| 180 | +- `ROBOTICS_ROBOTICSPRODACR_USERNAME` / `_PASSWORD` — prod registry |
| 181 | +- `ANALYTICS_INFRASTRUCTURE_DEPLOY_KEY` or `ROBOTICS_INFRASTRUCTURE_DEPLOY_KEY` — SSH deploy key on the target infrastructure repo |
| 182 | + |
| 183 | +**Verify (names only, values never surface):** |
| 184 | +```bash |
| 185 | +gh api "/repos/$REPO/actions/secrets" --jq '.secrets[].name' |
| 186 | +``` |
| 187 | + |
| 188 | +**Known drift:** several sara repos still have obsolete secrets (`ROBOTICS_AURORADEVACR_*`, `ROBOTICS_AURORAPRODACR_*`) left over from before the registry consolidation. Safe to delete: |
| 189 | + |
| 190 | +```bash |
| 191 | +gh api -X DELETE "/repos/$REPO/actions/secrets/ROBOTICS_AURORADEVACR_USERNAME" |
| 192 | +# ...repeat for other obsolete ones |
| 193 | +``` |
| 194 | + |
| 195 | +--- |
| 196 | + |
| 197 | +## 6. Actions variables |
| 198 | + |
| 199 | +Set only if the service needs environment-specific values that are safe to expose. |
| 200 | + |
| 201 | +- `AZURE_SUBSCRIPTION_ID` — required only if the workflow calls `run_dotnet_migrations.yml` (flotilla/sara pattern; not needed for typical Python services). |
| 202 | + |
| 203 | +**Verify:** |
| 204 | +```bash |
| 205 | +gh api "/repos/$REPO/actions/variables" --jq '.variables[].name' |
| 206 | +``` |
| 207 | + |
| 208 | +Empty is fine for most Python services. |
| 209 | + |
| 210 | +--- |
| 211 | + |
| 212 | +## 7. Labels |
| 213 | + |
| 214 | +Standard label set is managed by `synchronize_labels.yml` (already in the template). Trigger it once after the repo is created: |
| 215 | + |
| 216 | +```bash |
| 217 | +gh workflow run "Execute label synchronization" --repo "$REPO" |
| 218 | +``` |
| 219 | + |
| 220 | +**Verify:** |
| 221 | +```bash |
| 222 | +gh label list --repo "$REPO" |
| 223 | +``` |
| 224 | + |
| 225 | +Expected labels include `bug`, `enhancement`, `documentation`, `stale`, etc. — the exact list is defined in `equinor/armada/.github/workflows/synchronize_labels.yml`. |
| 226 | + |
| 227 | +--- |
| 228 | + |
| 229 | +## 8. Dependabot |
| 230 | + |
| 231 | +Ships with the template as `.github/dependabot.yml` if you want it — otherwise not enabled by default. Verify a config is present: |
| 232 | + |
| 233 | +```bash |
| 234 | +gh api "/repos/$REPO/contents/.github/dependabot.yml" --jq '.path' 2>/dev/null \ |
| 235 | + || echo "No dependabot.yml (optional)" |
| 236 | +``` |
| 237 | + |
| 238 | +--- |
| 239 | + |
| 240 | +## 9. CODEOWNERS (optional) |
| 241 | + |
| 242 | +If a specific team should be auto-requested on PRs, add `.github/CODEOWNERS`. Not standard across the sara-* repos today, so skip unless you have a reason. |
| 243 | + |
| 244 | +--- |
| 245 | + |
| 246 | +## 10. Register in infrastructure |
| 247 | + |
| 248 | +Not a GitHub setting, but easily forgotten: |
| 249 | + |
| 250 | +- Add overlays for `development`, `staging`, `production` in `equinor/analytics-infrastructure` (sara services) or `equinor/robotics-infrastructure` (flotilla/isar services) under `k8s_kustomize/overlays/*/kustomization.yaml`. |
| 251 | +- Registry image path must match what the workflow passes as `image_name` (e.g. `robotics/sara-your-service`). |
| 252 | + |
| 253 | +--- |
| 254 | + |
| 255 | +## Compliance check for existing repos |
| 256 | + |
| 257 | +Quick one-shot verification against an existing repo: |
| 258 | + |
| 259 | +```bash |
| 260 | +REPO=equinor/sara-your-service |
| 261 | + |
| 262 | +# Repo settings |
| 263 | +gh api "/repos/$REPO" --jq '{ |
| 264 | + squash:.allow_squash_merge, merge:.allow_merge_commit, |
| 265 | + rebase:.allow_rebase_merge, del:.delete_branch_on_merge |
| 266 | +}' |
| 267 | + |
| 268 | +# Rulesets |
| 269 | +gh api "/repos/$REPO/rulesets" --jq '.[] | {name, rules: [.rules[]?.type]}' |
| 270 | + |
| 271 | +# Environments |
| 272 | +gh api "/repos/$REPO/environments" --jq '.environments[].name' |
| 273 | + |
| 274 | +# Secrets |
| 275 | +gh api "/repos/$REPO/actions/secrets" --jq '.secrets[].name' |
| 276 | +``` |
| 277 | + |
| 278 | +--- |
| 279 | + |
| 280 | +## Notes |
| 281 | + |
| 282 | +- These values are **conventions**, not enforced by tooling. If enforcement matters, promote them to an **org-level ruleset** targeting `sara-*` / `flotilla` / `isar-*`; that removes the per-repo drift problem entirely. |
| 283 | +- Repos created before this document exists likely deviate. See the "Known drift" callouts under each section. |
0 commit comments