Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.3"
".": "0.1.5"
}
249 changes: 249 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
# Reusable CI/CD Patterns for Code-Guardian

This directory contains reusable GitHub Actions workflows, composite actions, and templates to standardize CI/CD processes across the project.

## Structure

```
.github/
β”œβ”€β”€ actions/ # Composite actions
β”‚ β”œβ”€β”€ setup-rust/ # Rust toolchain setup
β”‚ β”œβ”€β”€ setup-cache/ # Cargo caching
β”‚ β”œβ”€β”€ run-clippy/ # Clippy linting
β”‚ β”œβ”€β”€ run-tests/ # Test execution
β”‚ β”œβ”€β”€ generate-coverage/ # Coverage reports
β”‚ β”œβ”€β”€ build-workspace/ # Workspace building
β”‚ └── run-security-scan/ # Security scanning
β”œβ”€β”€ workflows/
β”‚ └── reusable/ # Reusable workflows
β”‚ β”œβ”€β”€ _quality-checks.yml
β”‚ β”œβ”€β”€ _test.yml
β”‚ └── _security-scan.yml
β”œβ”€β”€ workflow-templates/ # Workflow templates
β”‚ β”œβ”€β”€ basic-ci.yml
β”‚ └── comprehensive-ci.yml
β”œβ”€β”€ config/ # Shared configurations
β”‚ └── test-matrix.json
└── README.md # This file
```

## Composite Actions

### setup-rust
Sets up Rust toolchain with sccache and optional components.

```yaml
- uses: ./.github/actions/setup-rust
with:
toolchain: 'stable' # or 'beta', 'nightly', or specific version
components: 'rustfmt,clippy'
targets: 'x86_64-unknown-linux-gnu'
```

### setup-cache
Configures caching for Cargo registry and target directories.

```yaml
- uses: ./.github/actions/setup-cache
with:
cache-target: true
cache-registry: true
cache-key-suffix: 'optional-suffix'
```

### run-clippy
Runs cargo clippy with configurable options.

```yaml
- uses: ./.github/actions/run-clippy
with:
args: '--all-targets --all-features -- -D warnings'
fix: false
allow-dirty: false
```

### run-tests
Runs cargo tests with nextest support.

```yaml
- uses: ./.github/actions/run-tests
with:
package: 'code_guardian_core' # optional
features: '--all-features'
nextest: true
```

### generate-coverage
Generates test coverage reports.

```yaml
- uses: ./.github/actions/generate-coverage
with:
format: 'lcov' # or 'html', 'text'
threshold: 82
```

### build-workspace
Builds the entire Cargo workspace.

```yaml
- uses: ./.github/actions/build-workspace
with:
release: false
features: '--all-features'
targets: '--all-targets'
```

### run-security-scan
Runs comprehensive security scanning.

```yaml
- uses: ./.github/actions/run-security-scan
with:
audit: true
deny: true
gitleaks: true
clippy-security: true
```

## Reusable Workflows

### _quality-checks.yml
Runs formatting, clippy, and workspace checks.

```yaml
jobs:
quality:
uses: ./.github/workflows/reusable/_quality-checks.yml
with:
auto-fix: false
fail-on-warnings: true
```

### _test.yml
Runs cross-platform testing with coverage.

```yaml
jobs:
test:
uses: ./.github/workflows/reusable/_test.yml
with:
os: '["ubuntu-latest", "windows-latest", "macos-latest"]'
rust-version: '["stable"]'
coverage: true
coverage-threshold: 82
```

### _security-scan.yml
Runs security scanning tools.

```yaml
jobs:
security:
uses: ./.github/workflows/reusable/_security-scan.yml
with:
audit: true
deny: true
gitleaks: true
clippy-security: true
```

## Workflow Templates

### Basic CI Template
For simple projects needing basic quality checks and testing.

```yaml
# Copy from .github/workflow-templates/basic-ci.yml
name: Basic CI
# ... rest of template
```

### Comprehensive CI Template
For production-ready projects with full CI/CD features.

```yaml
# Copy from .github/workflow-templates/comprehensive-ci.yml
name: Comprehensive CI
# ... rest of template
```

## Shared Configurations

### test-matrix.json
Contains predefined test matrices for different scenarios.

```json
{
"os": ["ubuntu-latest", "windows-latest", "macos-latest"],
"rust": ["stable"],
"include": [
{
"os": "ubuntu-latest",
"rust": "beta"
}
]
}
```

## Usage Examples

### Simple CI Pipeline
```yaml
name: CI
on: [push, pull_request]

jobs:
quality:
uses: ./.github/workflows/reusable/_quality-checks.yml

test:
uses: ./.github/workflows/reusable/_test.yml
with:
os: '["ubuntu-latest"]'
coverage: true
```

### Advanced CI Pipeline
```yaml
name: Advanced CI
on: [push, pull_request]

jobs:
changes:
# Change detection logic
outputs:
src: ${{ steps.filter.outputs.src }}

quality:
uses: ./.github/workflows/reusable/_quality-checks.yml
with:
auto-fix: ${{ github.ref == 'refs/heads/main' }}

test:
uses: ./.github/workflows/reusable/_test.yml
needs: [changes, quality]
if: needs.changes.outputs.src == 'true'

security:
uses: ./.github/workflows/reusable/_security-scan.yml
needs: changes
if: needs.changes.outputs.src == 'true'
```

## Best Practices

1. **Use reusable workflows** for common patterns to reduce duplication
2. **Leverage composite actions** for repeated setup steps
3. **Configure caching** to improve build times
4. **Use change detection** to skip unnecessary jobs
5. **Implement auto-fixing** only on protected branches
6. **Set appropriate permissions** with least privilege
7. **Use concurrency controls** to prevent overlapping runs

## Maintenance

- Keep actions and workflows updated with latest best practices
- Test changes in a separate branch before merging
- Document any breaking changes
- Review and update shared configurations regularly
84 changes: 84 additions & 0 deletions .github/RELEASE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Release Template for Code Guardian

This template ensures consistent, professional release descriptions across all versions.

## Template Structure

```markdown
## Code Guardian v{VERSION} {EMOJI}

### {SECTION_EMOJI} {SECTION_NAME}
- {CHANGE_DESCRIPTION}

### πŸ“¦ Assets
- Pre-built binaries for Linux (x86_64), macOS (Intel & Apple Silicon), and Windows
- Full source code archives

### πŸš€ Installation
```bash
# Download and extract the appropriate binary for your platform
# Or install from source:
cargo install --git https://github.com/d-oit/code-guardian
```

### πŸ”— Links
- [Installation Guide](https://github.com/d-oit/code-guardian#installation)
- [Documentation](https://github.com/d-oit/code-guardian/tree/main/docs)
- [Changelog](https://github.com/d-oit/code-guardian/blob/main/CHANGELOG.md)
```

## Section Mapping

| Change Type | Emoji | Section Name |
|-------------|-------|--------------|
| feat | ✨ | Added |
| fix | πŸ› | Fixed |
| perf | ⚑ | Performance |
| docs | πŸ“š | Documentation |
| style | 🎨 | Style |
| refactor | ♻️ | Refactor |
| test | πŸ§ͺ | Tests |
| chore | πŸ”§ | Maintenance |
| breaking | ⚠️ | Breaking Changes |

## Special Release Types

### Initial Release (v0.1.0)
- Use πŸŽ‰ emoji in title
- Include "Initial Release" section with feature overview
- Add celebration language

### Alpha/Beta Releases
- Include ⚠️ Note section explaining the pre-release nature
- Add testing and feedback encouragement

### Major Releases
- Include migration guide if needed
- Highlight breaking changes prominently
- Add upgrade instructions

## Examples

### Standard Release
```
## Code Guardian v1.2.3

### ✨ Added
- New feature X for enhanced scanning
- Support for additional file formats

### πŸ› Fixed
- Memory leak in scanner engine
- CLI argument parsing edge case
```

### Pre-release
```
## Code Guardian v1.3.0-alpha

### ⚠️ Note
This is an alpha release for testing new features. Please report any issues.

### ✨ Added
- Experimental AI-powered detection
```
Loading
Loading