Files
codex/prs/bolinfest/study/PR-2242-study.md
2025-09-02 15:17:45 -07:00

65 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
**DOs**
- Build at least one release per OS: add one macOS and one Linux release job to catch conditional code (e.g., Landlock) and document why they exist.
```yaml
# One macOS release to mirror dev behavior
- runner: macos-14
target: aarch64-apple-darwin # Fastest macOS runner; keeps CI quick
profile: release
# One Linux release to catch Landlock/target-specific code
- runner: ubuntu-24.04
target: x86_64-unknown-linux-musl
profile: release
```
- Make release jobs obvious: reflect `profile` in the job name so release builds are easy to spot in CI.
```yaml
name: ${{ matrix.runner }} - ${{ matrix.target }}${{ matrix.profile == 'release' && ' (release)' || '' }}
```
- Pass `--profile` everywhere: ensure build and test steps respect the matrix profile.
```yaml
- run: find . -name Cargo.toml -mindepth 2 -maxdepth 2 -print0 \
| xargs -0 -n1 -I{} bash -c 'cd "$(dirname "{}")" && cargo build --profile ${{ matrix.profile }}'
- run: cargo test --all-features --target ${{ matrix.target }} --profile ${{ matrix.profile }}
```
- Align cache keys across workflows: include `profile` in CI and match it in release to maximize cache hits.
```yaml
# rust-ci.yml
with:
key: cargo-${{ matrix.runner }}-${{ matrix.target }}-${{ matrix.profile }}-${{ hashFiles('**/Cargo.lock') }}
# rust-release.yml
with:
key: cargo-release-${{ matrix.runner }}-${{ matrix.target }}-release-${{ hashFiles('**/Cargo.lock') }}
```
- Rebase after upstream merges: drop changes that already landed on `main` (e.g., imports) to keep diffs clean and avoid build breaks.
```bash
git fetch origin main
git rebase origin/main
# Resolve conflicts, ensure it builds locally, then:
git push --force-with-lease
```
**DONTs**
- Dont hide release coverage: avoid sneaking a single release job into the middle of the matrix without a comment explaining why its there.
```yaml
# Bad: release entry with no context
- runner: macos-14
target: aarch64-apple-darwin
profile: release # ← unexplained
```
- Dont mismatch cache keys: using different key formats between CI and release wastes caches.
```yaml
# Bad: missing profile token → poor cache reuse
key: cargo-${{ matrix.runner }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
```
- Dont rely only on dev builds: release-only or target-conditional code (e.g., Landlock on Linux) can break if not built in release.
```yaml
# Bad: tests/builds always run in dev profile
- run: cargo test --all-features --target ${{ matrix.target }}
```
- Dont keep stale changes post-merge: if `main` already includes an import or refactor, remove it from your PR via rebase instead of re-adding it.
```rust
// Bad (duplicate after rebase): already in main
use codex_core::user_agent::get_codex_user_agent;
```