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
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "alert-manager-api",
"image": "mcr.microsoft.com/devcontainers/rust:1",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"configureZshAsDefaultShell": true
}
},
"customizations": {
"vscode": {
"extensions": [
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates",
"vadimcn.vscode-lldb",
"streetsidesoftware.code-spell-checker",
"usernamehw.errorlens"
],
"settings": {
"rust-analyzer.checkOnSave.command": "clippy",
"rust-analyzer.checkOnSave.extraArgs": ["--all-features"],
"[rust]": {
"editor.formatOnSave": true
}
}
}
},
"postCreateCommand": "cargo build",
"remoteUser": "vscode"
}
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Code Owners
# These owners will be requested for review on pull requests

* @rlgrpe
42 changes: 42 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Bug Report
about: Report a bug to help us improve
title: "[BUG] "
labels: bug
assignees: ''
---

## Description

A clear and concise description of what the bug is.

## Steps to Reproduce

1. Use this code...
2. Call this method...
3. See error

## Expected Behavior

What you expected to happen.

## Actual Behavior

What actually happened.

## Environment

- Rust version: [e.g., 1.75.0]
- Crate version: [e.g., 0.1.2]
- OS: [e.g., Ubuntu 22.04]
- Alertmanager version: [e.g., 0.27.0]

## Additional Context

Add any other context about the problem here.

## Minimal Reproducible Example

```rust
// Paste your code here
```
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Feature Request
about: Suggest an idea for this project
title: "[FEATURE] "
labels: enhancement
assignees: ''
---

## Problem Statement

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

## Proposed Solution

A clear and concise description of what you want to happen.

## Alternatives Considered

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

## Use Case

Describe the use case that motivates this feature.

## Additional Context

Add any other context or screenshots about the feature request here.
30 changes: 30 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Summary

Brief description of the changes.

## Changes

- Change 1
- Change 2

## 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
- [ ] Refactoring (no functional changes)

## Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes

## Related Issues

Fixes #(issue number)
104 changes: 104 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings

jobs:
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-targets --all-features -- -D warnings -D clippy::cognitive_complexity

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --all-features -- --show-output

test-features:
name: Test Features
runs-on: ubuntu-latest
strategy:
matrix:
features:
- native-tls
- rustls-tls
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --no-default-features --features ${{ matrix.features }}

coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-tarpaulin
- run: cargo tarpaulin --all-features --out xml
- uses: codecov/codecov-action@v4
with:
files: cobertura.xml
fail_ci_if_error: false

security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo generate-lockfile
- uses: rustsec/audit-check@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

tech-debt:
name: Tech Debt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for TODO/FIXME
run: |
if grep -rn "TODO\|FIXME" --include="*.rs" src/; then
echo "::warning::Found TODO/FIXME comments in source code"
fi

large-files:
name: Large Files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for large files
run: |
find . -type f -size +1M -not -path "./.git/*" | while read file; do
echo "::error file=$file::File exceeds 1MB"
exit 1
done || true
96 changes: 96 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Release

on:
push:
tags:
- 'v*'

env:
CARGO_TERM_COLOR: always

jobs:
verify:
name: Verify Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get version from tag
id: tag_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Get version from Cargo.toml
id: cargo_version
run: |
VERSION=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT

- name: Verify versions match
env:
TAG_VERSION: ${{ steps.tag_version.outputs.VERSION }}
CARGO_VERSION: ${{ steps.cargo_version.outputs.VERSION }}
run: |
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi

test:
name: Test
needs: verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --all-features

release:
name: Create Release
needs: [verify, test]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get previous tag
id: prev_tag
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
echo "TAG=$PREV_TAG" >> $GITHUB_OUTPUT

- name: Generate changelog
id: changelog
env:
PREV_TAG: ${{ steps.prev_tag.outputs.TAG }}
run: |
if [ -n "$PREV_TAG" ]; then
CHANGELOG=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s" --no-merges)
else
CHANGELOG=$(git log --pretty=format:"- %s" --no-merges)
fi
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body: |
## Changes

${{ steps.changelog.outputs.CHANGELOG }}

## Installation

Add to your `Cargo.toml`:

```toml
[dependencies]
alert-manager-api = { git = "https://github.com/rlgrpe/alert-manager-api", tag = "${{ github.ref_name }}" }
```
draft: false
prerelease: ${{ contains(github.ref, '-') }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/target
.idea
Cargo.lock
Cargo.lock
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Pre-commit hooks configuration for alert-manager-api
# Install: pre-commit install
# Run manually: pre-commit run --all-files
# Update hooks: pre-commit autoupdate

repos:
# Rust code formatting with rustfmt
- repo: local
hooks:
- id: rustfmt
name: rustfmt
entry: cargo fmt --
language: system
types: [rust]
pass_filenames: false

# Rust linting with clippy
- repo: local
hooks:
- id: clippy
name: clippy
entry: cargo clippy --all-targets --all-features -- -D warnings
language: system
types: [rust]
pass_filenames: false

# Common pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
name: Trim trailing whitespace
- id: end-of-file-fixer
name: Fix end of file
- id: check-yaml
name: Check YAML
- id: check-json
name: Check JSON
- id: check-toml
name: Check TOML
- id: check-added-large-files
name: Check for large files
args: ['--maxkb=1000']
- id: check-merge-conflict
name: Check merge conflicts
- id: detect-private-key
name: Detect private keys
Loading
Loading