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
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
title: '[BUG] '
labels: bug
assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Code example**
```go
// Please provide a minimal code example that reproduces the issue
```

**Environment:**
- Go version: [e.g. 1.22.0]
- OS: [e.g. Ubuntu 22.04]
- SentinelRBAC version: [e.g. v1.0.0]

**Additional context**
Add any other context about the problem here.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Feature request
about: Suggest an idea for this project
title: '[FEATURE] '
labels: enhancement
assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Use case**
Describe a specific use case where this feature would be helpful.

**Additional context**
Add any other context or screenshots about the feature request here.
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Description
Brief description of the changes in this PR.

## Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Test improvements

## Testing
- [ ] Tests pass locally
- [ ] New tests added for new functionality
- [ ] All existing tests still pass

## Checklist
- [ ] Code follows the project's style guidelines
- [ ] Self-review of the code has been performed
- [ ] Code is properly commented
- [ ] Documentation has been updated (if applicable)
- [ ] No new warnings or errors introduced

## Related Issues
Fixes #(issue number)

## Additional Notes
Any additional information that reviewers should know.
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: CI

on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]

jobs:
test:
name: Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Download dependencies
run: go mod download

- name: Run tests
run: go test -v -race

- name: Run tests with coverage
run: go test -cover

- name: Generate coverage report
run: |
go test -coverprofile=coverage.out
go tool cover -func=coverage.out

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Run gofmt
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "The following files are not formatted:"
gofmt -s -l .
exit 1
fi

- name: Run go vet
run: go vet ./...

- name: Run staticcheck
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck ./... || echo "Staticcheck found issues, but continuing..."

build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Build
run: go build -v ./...

- name: Build example
run: |
if [ -d "./cmd" ]; then
go build -v -o example ./cmd/...
else
echo "No cmd directory found, skipping example build"
fi
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Run tests
run: go test -v

- name: Build
run: go build -v ./...

- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
18 changes: 17 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
cmd
# Test coverage files
coverage.out
coverage.html

# Go build artifacts
*.exe
*.exe~
*.dll
*.so
*.dylib

# Go test binary
*.test

# Go coverage files
*.cover
*.coverprofile
81 changes: 81 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
.PHONY: test test-race test-coverage lint build clean help

# Default target
all: test lint build

# Run tests
test:
go test -v ./...

# Run tests with race detection
test-race:
go test -v -race ./...

# Run tests with coverage
test-coverage:
go test -v -cover ./...

# Generate detailed coverage report
coverage:
go test -coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"

# Run linters
lint:
@echo "Running gofmt..."
@if [ "$$(gofmt -s -l . | wc -l)" -gt 0 ]; then \
echo "The following files are not formatted:"; \
gofmt -s -l .; \
exit 1; \
fi
@echo "Running go vet..."
go vet ./...
@echo "Running staticcheck..."
@if command -v staticcheck >/dev/null 2>&1; then \
staticcheck ./... || echo "Staticcheck found issues, but continuing..."; \
else \
echo "staticcheck not installed, skipping..."; \
fi

# Build the project
build:
go build -v ./...

# Build example
build-example:
@if [ -d "./cmd" ]; then \
go build -v -o example ./cmd/...; \
else \
echo "No cmd directory found, skipping example build"; \
fi

# Clean build artifacts
clean:
go clean
rm -f coverage.out coverage.html example

# Install dependencies
deps:
go mod download
go mod verify

# Update dependencies
update-deps:
go get -u ./...
go mod tidy

# Show help
help:
@echo "Available targets:"
@echo " test - Run tests"
@echo " test-race - Run tests with race detection"
@echo " test-coverage - Run tests with coverage"
@echo " coverage - Generate detailed coverage report"
@echo " lint - Run linters (gofmt, go vet, staticcheck)"
@echo " build - Build the project"
@echo " build-example - Build the example"
@echo " clean - Clean build artifacts"
@echo " deps - Download and verify dependencies"
@echo " update-deps - Update dependencies"
@echo " help - Show this help message"
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,42 @@ func main() {
}
```

## Development

### Running Tests
```bash
# Run all tests
make test

# Run tests with race detection
make test-race

# Run tests with coverage
make test-coverage

# Generate detailed coverage report
make coverage
```

### Code Quality
```bash
# Run linters
make lint

# Build the project
make build

# Clean build artifacts
make clean
```

### CI/CD
This project uses GitHub Actions for continuous integration:
- **Tests**: Run on every push and pull request
- **Linting**: Code formatting and quality checks
- **Build**: Ensures the project builds successfully
- **Coverage**: Test coverage reporting

## Action Gate Policy (AGP)

As you can see `Authorize()` function actually has 3 arguments, we already know about first two - context and roles, but what about the last one?
Expand Down
Loading
Loading