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
65 changes: 65 additions & 0 deletions .github/BRANCH_PROTECTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Branch Protection Configuration

To enforce CI checks and code reviews before merging to `main`, configure the following settings in your GitHub repository.

## Steps to Configure

1. Go to your repository on GitHub
2. Navigate to **Settings** → **Branches**
3. Click **Add branch protection rule**
4. Configure the following:

### Branch name pattern
```
main
```

### Protection Rules

#### Require a pull request before merging
- ✅ Enable this option
- **Required approvals**: 1 (minimum)
- ✅ Dismiss stale pull request approvals when new commits are pushed
- ✅ Require review from Code Owners (optional, if you have CODEOWNERS file)

#### Require status checks to pass before merging
- ✅ Enable this option
- ✅ Require branches to be up to date before merging
- **Required status checks** (add these):
- `build-test`
- `sast-sbom`

#### Additional Recommended Settings
- ✅ Require conversation resolution before merging
- ✅ Do not allow bypassing the above settings
- ✅ Restrict who can push to matching branches (optional - for stricter control)

## What This Achieves

- **Automated Quality Gates**: All PRs must pass Maven tests, Go tests, linting, and security scans
- **Human Review**: At least one team member must review and approve changes
- **Security**: Trivy catches high/critical vulnerabilities before merge
- **Traceability**: SBOM artifacts track dependencies for each build
- **Consistency**: Prevents direct pushes to main, enforcing the PR workflow

## Testing the Setup

1. Create a test branch: `git checkout -b test/ci-validation`
2. Make a small change and push
3. Open a PR to `main`
4. Verify that CI jobs run automatically
5. Confirm that merge is blocked until:
- All CI checks pass (green)
- At least one approval is given

## CI Job Details

### build-test
- Runs Maven tests for Java backend
- Runs Go unit tests for CLI
- Runs golangci-lint for Go code quality

### sast-sbom
- Trivy security scan (HIGH + CRITICAL vulnerabilities)
- Generates Software Bill of Materials (SBOM) with Syft
- Uploads SBOM as workflow artifact
92 changes: 92 additions & 0 deletions .github/CI_STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# CI Status & Known Issues

## Current Test Status

### Backend (Java/Maven)
- **Local Build**: ❌ Fails (requires Java 21, local has Java 11)
- **CI Build**: ✅ Will work (GitHub Actions uses Java 21)
- **Tests**: Need Java 21 to run

### CLI (Go)
- **Build**: ✅ Compiles successfully
- **Tests**: ❌ Some failures detected:
- `main_test.go`: undefined rootCmd references (5 failures)
- `client_test.go`: timeout test failure
- `parser_property_test.go`: empty intent validation failure
- `repair_decision_test.go`: multiple repair strategy failures
- `repair_strategies_test.go`: flag normalization and typo correction failures

## What the CI Workflow Does

The `.github/workflows/ci.yml` will:

1. **Setup Environment**
- Java 21 (Temurin distribution)
- Go 1.21

2. **Run Tests**
- Backend: `mvn -B -DskipTests=false test`
- CLI: `go test ./...`
- Linting: `golangci-lint run ./...`

3. **Security Scanning**
- Trivy filesystem scan (HIGH + CRITICAL vulnerabilities)
- SBOM generation with Syft

## Action Required Before CI Will Pass

### Fix Go Test Failures
The CLI has test failures that need to be fixed:

```bash
cd cli
go test ./... -v
```

Key issues:
- `main_test.go` references undefined `rootCmd` variable
- Parser property tests failing on edge cases
- Repair engine tests failing on specific strategies

### Verify Java Tests
Once you have Java 21 installed locally:

```bash
cd backend
mvn test
```

## CI Will Block Merges If:
- Maven tests fail
- Go tests fail
- golangci-lint reports issues
- Trivy finds HIGH or CRITICAL vulnerabilities

## Recommendation

Before enabling branch protection:
1. Fix the Go test failures in the CLI
2. Ensure all tests pass locally with Java 21
3. Push to a test branch and verify CI runs successfully
4. Then enable branch protection rules

## Testing the CI Locally

You can test parts of the CI locally:

```bash
# Backend tests (requires Java 21)
cd backend
mvn clean test

# CLI tests
cd cli
go test ./...

# CLI linting
cd cli
golangci-lint run ./...

# Security scan
trivy fs --severity HIGH,CRITICAL .
```
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CI

on:
push:
branches: [ "main", "develop" ]
pull_request:
types: [opened, synchronize, reopened, edited]

jobs:
build-test:
name: build-test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Backend - Maven test
working-directory: backend
run: mvn -B -DskipTests=false test

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: CLI - Go test
working-directory: cli
run: go test ./...
continue-on-error: false

- name: CLI - golangci-lint
working-directory: cli
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.58.0
golangci-lint run ./...

sast-sbom:
name: sast-sbom
runs-on: ubuntu-latest
needs: build-test
steps:
- uses: actions/checkout@v4

- name: Install Trivy
run: |
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -

- name: Trivy filesystem scan (high+critical)
run: trivy fs --severity HIGH,CRITICAL .

- name: Generate SBOM with Syft
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -
syft packages . -o json > sbom.json

- name: Upload SBOM artifact
uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.json
Loading