Skip to content

Commit 34654e1

Browse files
authored
Merge pull request #1 from akshay5995/feat/storage-backend
feat: add storage backend support and CI/CD workflows
2 parents 76f86da + ed850dc commit 34654e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+5472
-916
lines changed

.bandit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
skips:
2+
- B105 # hardcoded_password_string - OAuth protocol constants
3+
- B106 # hardcoded_password_funcarg - OAuth protocol constants
4+
- B104 # hardcoded_bind_all_interfaces - Intentional for containers

.github/workflows/lint.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: "3.11"
21+
cache: 'pip'
22+
23+
- name: Install linting dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install black>=23.0.0 ruff>=0.1.0
27+
28+
- name: Check code formatting with Black
29+
run: |
30+
black --check --diff src/ tests/ demo/
31+
32+
- name: Lint with Ruff
33+
run: |
34+
ruff check src/ tests/ demo/
35+
36+
- name: Check for security issues with Bandit
37+
run: |
38+
pip install bandit[toml]>=1.7.0
39+
bandit -r src/ --configfile .bandit -f json -o bandit-report.json || true
40+
bandit -r src/ --configfile .bandit
41+
42+
- name: Type checking with mypy (optional)
43+
run: |
44+
pip install mypy>=1.0.0 types-PyYAML types-requests
45+
mypy src/ --ignore-missing-imports --no-strict-optional || true

.github/workflows/pr-release.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: PR Pre-release
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
issues: write
11+
packages: write
12+
id-token: write
13+
14+
jobs:
15+
pre-release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
ref: ${{ github.event.pull_request.head.ref }}
23+
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: "3.11"
29+
cache: 'pip'
30+
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install python-semantic-release
35+
36+
- name: Configure git
37+
run: |
38+
git config --global user.name "github-actions[bot]"
39+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
40+
41+
- name: Generate RC version
42+
id: version
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
run: |
46+
# Get the current version
47+
CURRENT_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
48+
49+
# Generate RC version based on PR number
50+
RC_VERSION="${CURRENT_VERSION}-rc.${{ github.event.pull_request.number }}"
51+
echo "RC_VERSION=${RC_VERSION}" >> $GITHUB_OUTPUT
52+
53+
# Update version in files
54+
sed -i "s/version = \"${CURRENT_VERSION}\"/version = \"${RC_VERSION}\"/" pyproject.toml
55+
sed -i "s/__version__ = \"${CURRENT_VERSION}\"/__version__ = \"${RC_VERSION}\"/" src/__init__.py
56+
57+
# Create pre-release tag (delete if exists)
58+
git add pyproject.toml src/__init__.py
59+
git commit -m "chore: bump version to ${RC_VERSION} [skip ci]" || echo "No changes to commit"
60+
61+
# Delete existing tag if it exists (locally and remotely)
62+
git tag -d "v${RC_VERSION}" 2>/dev/null || true
63+
git push --delete origin "v${RC_VERSION}" 2>/dev/null || true
64+
65+
# Create new tag
66+
git tag -a "v${RC_VERSION}" -m "Pre-release version ${RC_VERSION}"
67+
68+
- name: Push tag to trigger Docker build
69+
run: |
70+
git push origin "v${{ steps.version.outputs.RC_VERSION }}"
71+
72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v3
74+
75+
- name: Log in to Container Registry
76+
uses: docker/login-action@v3
77+
with:
78+
registry: ghcr.io
79+
username: ${{ github.actor }}
80+
password: ${{ secrets.GITHUB_TOKEN }}
81+
82+
- name: Build and push Docker image
83+
uses: docker/build-push-action@v5
84+
with:
85+
context: .
86+
platforms: linux/amd64,linux/arm64
87+
push: true
88+
tags: ghcr.io/${{ github.repository_owner }}/mcp-oauth-gateway:v${{ steps.version.outputs.RC_VERSION }}
89+
cache-from: type=gha
90+
cache-to: type=gha,mode=max
91+
92+
- name: Create GitHub pre-release
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
run: |
96+
gh release create "v${{ steps.version.outputs.RC_VERSION }}" \
97+
--title "Pre-release v${{ steps.version.outputs.RC_VERSION }}" \
98+
--notes "Pre-release version for PR #${{ github.event.pull_request.number }}" \
99+
--prerelease \
100+
--target ${{ github.event.pull_request.head.sha }}
101+
102+
- name: Comment on PR
103+
uses: actions/github-script@v7
104+
with:
105+
script: |
106+
const rcVersion = '${{ steps.version.outputs.RC_VERSION }}';
107+
const comment = `🚀 **Pre-release version created: \`v${rcVersion}\`**
108+
109+
This pre-release version can be used for testing this PR.
110+
111+
**Docker image**: \`ghcr.io/${{ github.repository }}:v${rcVersion}\``;
112+
113+
github.rest.issues.createComment({
114+
issue_number: context.issue.number,
115+
owner: context.repo.owner,
116+
repo: context.repo.repo,
117+
body: comment
118+
});

.github/workflows/release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
pull-requests: write
12+
issues: write
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: "3.11"
28+
cache: 'pip'
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install python-semantic-release
34+
35+
- name: Configure git
36+
run: |
37+
git config --global user.name "github-actions[bot]"
38+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
39+
40+
- name: Run semantic release
41+
id: release
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
semantic-release version
46+
semantic-release publish
47+
48+
# Get the new version for Docker tagging
49+
NEW_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
50+
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_OUTPUT
51+
52+
- name: Set up Docker Buildx
53+
if: steps.release.outputs.NEW_VERSION != ''
54+
uses: docker/setup-buildx-action@v3
55+
56+
- name: Log in to Container Registry
57+
if: steps.release.outputs.NEW_VERSION != ''
58+
uses: docker/login-action@v3
59+
with:
60+
registry: ghcr.io
61+
username: ${{ github.actor }}
62+
password: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Extract Docker metadata
65+
if: steps.release.outputs.NEW_VERSION != ''
66+
id: meta
67+
uses: docker/metadata-action@v5
68+
with:
69+
images: ghcr.io/${{ github.repository_owner }}/mcp-oauth-gateway
70+
tags: |
71+
type=semver,pattern={{version}},value=v${{ steps.release.outputs.NEW_VERSION }}
72+
type=semver,pattern={{major}}.{{minor}},value=v${{ steps.release.outputs.NEW_VERSION }}
73+
type=semver,pattern={{major}},value=v${{ steps.release.outputs.NEW_VERSION }}
74+
type=raw,value=latest,enable={{is_default_branch}}
75+
76+
- name: Build and push Docker image
77+
if: steps.release.outputs.NEW_VERSION != ''
78+
uses: docker/build-push-action@v5
79+
with:
80+
context: .
81+
platforms: linux/amd64,linux/arm64
82+
push: true
83+
tags: ${{ steps.meta.outputs.tags }}
84+
labels: ${{ steps.meta.outputs.labels }}
85+
cache-from: type=gha
86+
cache-to: type=gha,mode=max

.github/workflows/test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
cache: 'pip'
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -r requirements-dev.txt
30+
31+
- name: Run tests with coverage
32+
run: |
33+
python -m pytest -v --tb=short --cov=src --cov-report=xml --cov-report=term-missing
34+
35+
- name: Test CLI entry point
36+
run: |
37+
python -m src.gateway --help
38+
39+

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ data/
341341
!config/*.example.yaml
342342
!config/*.example.yml
343343
!config.example.yaml
344+
!.github/workflows/*.yml
344345

345346
# =============================================================================
346347
# Project Specific
@@ -374,7 +375,6 @@ development/
374375
# =============================================================================
375376

376377
# CI/CD specific files (keep templates)
377-
.github/workflows/*.yml
378378
!.github/workflows/*.example.yml
379379

380380
# Coverage reports
@@ -398,3 +398,6 @@ perf.data.old
398398
.claude/
399399

400400
.ruff_cache/
401+
402+
# Docker compose
403+
!docker-compose.yml

0 commit comments

Comments
 (0)