Skip to content

Commit 894ed2c

Browse files
CI/CD rule updates
1 parent 873937a commit 894ed2c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.cursor/rules/cicd-patterns.mdc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ alwaysApply: false
66

77
# CI/CD Workflow Guidelines
88

9+
## Security: Pin Actions by Commit Hash
10+
11+
**ALWAYS pin GitHub Actions to specific commit SHAs** instead of version tags for enhanced security. This prevents supply chain attacks where tags could be moved to malicious commits.
12+
13+
Example:
14+
15+
```yaml
16+
# ✅ CORRECT - Pinned by hash with version comment
17+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
18+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # 4.6.2
19+
20+
# ❌ INCORRECT - Using version tag
21+
- uses: actions/checkout@v4
22+
- uses: actions/upload-artifact@v4.6.2
23+
```
24+
25+
The comment after the hash helps maintainability by showing which version is pinned.
26+
927
## Reusable Workflow Pattern
1028

1129
- Main `ci.yml` calls separate workflows (`lint.yml`, `test.yml`, etc.)
@@ -57,3 +75,24 @@ When adding new CI checks:
5775

5876
- `RUSTFLAGS: -Dwarnings` enforced in CI
5977
- Cross-platform matrix: Ubuntu 24.04, macOS 14, Windows 2022
78+
79+
## Container-Based Builds
80+
81+
For cross-compilation (e.g., Linux musl targets):
82+
83+
- Use GitHub Actions' native `container` field instead of manual Docker commands
84+
- Prefer `messense/rust-musl-cross` images for Linux musl builds
85+
- Structure:
86+
```yaml
87+
jobs:
88+
build:
89+
container:
90+
image: messense/rust-musl-cross:${{ matrix.container }}
91+
options: --user root
92+
steps:
93+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
94+
- uses: actions/cache@1a9e2138d905efd099035b49d8b7a3888c653ca8 # v4.0.2
95+
```
96+
- Benefits: Better caching, cleaner logs, simpler conditionals
97+
- Use GitHub Actions cache for Cargo dependencies instead of Docker volumes
98+
- Remember to pin all actions by commit hash as per security guidelines

0 commit comments

Comments
 (0)