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
232 changes: 232 additions & 0 deletions .github/CI_CD_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
# CI/CD Setup Summary

This document provides a summary of the CI/CD infrastructure set up for the Miners Scheduler project.

## 📋 Overview

The project now includes a complete CI/CD pipeline using GitHub Actions that automatically:
- ✅ Runs all unit tests on every PR and push
- ✅ Measures code coverage
- ✅ Performs code quality checks (linting)
- ✅ Builds the binary to verify compilation
- ✅ Publishes coverage badges
- ✅ Archives test results and artifacts

## 📁 Files Added

### GitHub Actions Workflows

1. **`.github/workflows/test.yml`**
- Main CI/CD workflow
- Runs on: pushes to main/master/develop, all pull requests
- Jobs:
- `test`: Runs tests with coverage and race detection
- `lint`: Runs golangci-lint for code quality
- `build`: Compiles the binary
- Uploads coverage to Codecov
- Archives coverage reports as artifacts

2. **`.github/workflows/README.md`**
- Comprehensive documentation for the workflows
- Setup instructions for badges
- Troubleshooting guide
- Badge configuration options

### Configuration Files

4. **`.golangci.yml`**
- Configuration for golangci-lint
- Enables multiple linters:
- errcheck, gosimple, govet, ineffassign
- staticcheck, unused, gofmt, goimports
- misspell, revive, gosec, exportloopref, gocritic
- Custom rules and settings

### Documentation

5. **`CONTRIBUTING.md`**
- Complete contributing guide
- Development setup instructions
- Testing guidelines
- CI/CD pipeline explanation
- Pull request process
- Code standards and best practices

6. **`.github/SETUP_COVERAGE_BADGE.md`**
- Detailed Codecov badge setup instructions
- Step-by-step setup guide
- Troubleshooting section
- Badge customization options

7. **`README.md` (Updated)**
- Added badges section at the top:
- Tests status badge
- Coverage badge
- Go Report Card badge
- Go version badge
- License badge

## 🚀 What Happens Now

### On Every Pull Request:
1. Tests run automatically with race detection
2. Code is linted for quality issues
3. Binary is compiled to ensure no build errors
4. Coverage report is generated
5. All checks must pass before merge

### On Push to Main/Master:
1. All the above checks run
2. Coverage data is uploaded to Codecov
3. Artifacts are archived for 30 days

## 🎯 Next Steps

### Immediate (No Configuration Required):
The workflows will work immediately for:
- ✅ Running tests on PRs
- ✅ Linting code
- ✅ Building the binary
- ✅ Test status badge

### Optional Setup (2-3 minutes):

#### Codecov Badge Setup
1. Sign up at https://codecov.io with your GitHub account
2. Your repository will be automatically detected after the first workflow run
3. For private repos: Add `CODECOV_TOKEN` to GitHub secrets
4. Done! Badge updates automatically ✨

**See `.github/SETUP_COVERAGE_BADGE.md` for detailed instructions.**

## 📊 Coverage Goals

Current guidelines:
- Minimum: 40% (red badge)
- Good: 60% (yellow badge)
- Great: 80% (green badge)
- Target: Maintain or improve with each PR

## 🔧 Running Checks Locally

Before pushing, run these commands to simulate CI:

```bash
# Format code
make fmt

# Run linters
make lint

# Run tests with coverage
make test

# Build binary
make build

# Or all at once
make check test build
```

## 📈 Monitoring

### View Test Results:
1. Go to repository → Actions tab
2. Click on any workflow run
3. View logs for each job
4. Download artifacts if needed

### View Coverage:
- **Locally**: Run `make test-coverage` and open `coverage.html`
- **GitHub**: Download coverage artifact from Actions
- **Codecov**: View dashboard at codecov.io (if configured)

### View Lint Results:
- Check the `lint` job in Actions
- Run locally: `golangci-lint run`

## 🐛 Troubleshooting

### Tests Failing in CI but Passing Locally
- Ensure same Go version (1.25.1)
- Clear test cache: `go clean -testcache`
- Check for race conditions: `go test -race ./...`

### Lint Failing
- Run locally: `golangci-lint run`
- Check `.golangci.yml` for rules
- Auto-fix some issues: `golangci-lint run --fix`

### Badge Not Showing
- Verify secrets are set correctly
- Check workflow ran successfully
- Clear browser cache
- See `.github/SETUP_COVERAGE_BADGE.md`

## 📚 Additional Resources

- [GitHub Actions Docs](https://docs.github.com/en/actions)
- [golangci-lint Docs](https://golangci-lint.run/)
- [Codecov Docs](https://docs.codecov.com/)
- [Go Testing Docs](https://golang.org/pkg/testing/)

## 🎉 Benefits

This CI/CD setup provides:

1. **Automated Quality Assurance**
- Every change is tested automatically
- Catches bugs before they reach production
- Ensures code meets quality standards

2. **Code Coverage Tracking**
- Visibility into test coverage
- Encourages writing tests
- Prevents coverage regression

3. **Consistent Code Style**
- Automated linting
- Enforces best practices
- Reduces code review friction

4. **Fast Feedback**
- Know immediately if changes break tests
- Parallel job execution
- Quick iteration cycles

5. **Build Verification**
- Ensures code compiles for target platforms
- Catches dependency issues early
- Provides deployment-ready artifacts

## 🔐 Security Notes

- Never commit secrets or tokens to the repository
- Use GitHub Secrets for sensitive data
- Personal access tokens should have minimal scopes
- Rotate tokens periodically
- Review Actions logs for sensitive data leaks

## 🤝 Contributing

When contributing:
1. Ensure all CI checks pass
2. Add tests for new features
3. Maintain or improve coverage
4. Follow the guidelines in `CONTRIBUTING.md`

## 📝 Maintenance

The CI/CD setup requires minimal maintenance:
- Update Go version in workflows when upgrading
- Review and update linter rules as needed
- Rotate personal access tokens before expiration
- Monitor Actions usage (free tier limits)

---

**Setup Date**: 2024
**Maintainer**: DevSkill Team
**Last Updated**: When this file was created

For questions or issues with the CI/CD setup, please open an issue or see the documentation files listed above.
86 changes: 86 additions & 0 deletions .github/QUICK_START.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Quick Start Guide: CI/CD for Miners Scheduler

This guide will get your CI/CD pipeline running in less than 5 minutes.

## ✅ What's Already Working

Your repository now has:
- ✨ Automated tests on every PR
- 🔍 Code quality checks (linting)
- 🏗️ Build verification
- 📊 Coverage tracking

**No configuration needed** - these work out of the box!

## 🚀 Quick Setup (Optional Coverage Badge)

Want a coverage badge in your README showing the exact percentage?

### Codecov Setup (2-3 minutes)

1. Visit https://codecov.io and sign in with GitHub
2. Your repository will be automatically detected after the first workflow run
3. For private repos: Add `CODECOV_TOKEN` secret (get it from Codecov settings)
4. Done! Badge updates automatically

**That's it!** 🎉

For detailed instructions, see `.github/SETUP_COVERAGE_BADGE.md`

## 📖 Detailed Guides

- **Coverage badge setup**: `.github/SETUP_COVERAGE_BADGE.md`
- **CI/CD overview**: `.github/CI_CD_SETUP.md`
- **Contributing guide**: `CONTRIBUTING.md`
- **Workflow documentation**: `.github/workflows/README.md`

## 🧪 Test Locally Before Pushing

```bash
# Run all checks (same as CI)
make check test build

# Or individually
make fmt # Format code
make vet # Run go vet
make lint # Run linter
make test # Run tests with coverage
make build # Build binary
```

## 👀 View Results

1. Go to your repo → **Actions** tab
2. Click any workflow run
3. See test results, coverage, and build status
4. Download artifacts if needed

## 🎯 What Triggers CI?

- ✅ Every push to `main`, `master`, or `develop`
- ✅ Every pull request to these branches

## 📊 Current Test Status

Check your badges at the top of README.md:
- **Tests**: Shows if tests are passing ✅
- **Coverage**: Shows test coverage percentage (via Codecov)
- **Go Report**: Overall code quality score
- **Go Version**: Go version used
- **License**: Project license

## ❓ Need Help?

- Tests failing? Check the Actions logs
- Badge not working? See `.github/SETUP_COVERAGE_BADGE.md`
- Contributing? Read `CONTRIBUTING.md`
- Questions? Open an issue

## 🎉 You're All Set!

Your CI/CD pipeline is ready. Every PR will now be:
- ✅ Tested automatically
- ✅ Linted for quality
- ✅ Verified to build

Happy coding! 🚀
Loading