Skip to content

Commit 36b4dec

Browse files
committed
configure advanced ci/cd
1 parent d71e75a commit 36b4dec

32 files changed

+1783
-58
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text=auto
2+
*.py text eol=lf
3+
*.toml text eol=lf
4+
*.yaml text eol=lf

.github/SECURITY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Security Policy
2+
3+
If you found a security vulnerability, please reach out to akromjonrustamov56@gmail.com (or open a private issue).
4+
We will respond within 72 hours.
5+
6+
Preferred disclosure: private report to the above address.

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
open-pull-requests-limit: 10
8+
rebase-strategy: "auto"
9+
# optional: ignore dev deps or certain packages
10+
- package-ecosystem: "github-actions"
11+
directory: "/"
12+
schedule:
13+
interval: "daily"
14+
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,76 @@ jobs:
1212
strategy:
1313
matrix:
1414
python-version: [3.12]
15+
1516
steps:
1617
- name: Checkout repository
17-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1819

1920
- name: Set up Python
2021
uses: actions/setup-python@v4
2122
with:
2223
python-version: ${{ matrix.python-version }}
23-
24+
cache: "pip"
25+
2426
- name: Install UV
2527
run: |
2628
python -m pip install --upgrade pip
2729
pip install uv
2830
31+
- name: Cache UV virtualenv
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
.venv
36+
~/.cache/uv
37+
key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml') }}
38+
restore-keys: |
39+
${{ runner.os }}-uv-
40+
2941
- name: Sync dependencies
3042
run: uv sync
3143

3244
- name: Run Pre-commit checks
3345
uses: pre-commit/action@v3.0.0
3446
with:
3547
extra_args: --all-files
36-
48+
3749
- name: Clear pre-commit cache
3850
run: pre-commit clean
3951

40-
- name: Run type checking
52+
- name: Run Mypy
4153
run: uv run mypy src/
4254

43-
- name: Run linter
55+
- name: Run Ruff
4456
run: uv run ruff check src/
4557

46-
- name: Run tests
58+
- name: Run Tests
4759
env:
48-
# Для CI подставляем тестовые значения
60+
ENV: test
4961
MAIL_USERNAME: test@example.com
5062
MAIL_PASSWORD: testpass
51-
run: uv run pytest -v tests
63+
run: uv run pytest -v --disable-warnings --maxfail=1
64+
65+
# - name: Install security tools
66+
# run: |
67+
# python -m pip install --upgrade pip
68+
# pip install pip-audit bandit safety
69+
70+
- name: Dependency security audit (pip-audit)
71+
run: |
72+
pip-audit --format=human
73+
74+
- name: Static security scan (Bandit)
75+
run: |
76+
bandit -r src -ll
77+
78+
- name: Safety check (optional)
79+
run: |
80+
safety check
81+
82+
- name: Upload pytest cache
83+
if: failure()
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: pytest-cache
87+
path: .pytest_cache/
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: "0 3 * * 0"
10+
11+
jobs:
12+
analyze:
13+
name: Analyze (CodeQL)
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Initialize CodeQL
24+
uses: github/codeql-action/init@v2
25+
with:
26+
languages: python
27+
28+
- name: Autobuild (if needed)
29+
uses: github/codeql-action/autobuild@v2
30+
31+
- name: Run CodeQL analysis
32+
uses: github/codeql-action/analyze@v2
Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,28 @@
11
name: Telegram Notifications
22

33
on:
4-
push:
5-
branches: [ main ]
6-
pull_request:
4+
workflow_run:
5+
workflows: ["CI Pipeline"]
6+
types:
7+
- completed
78

89
jobs:
910
notify:
1011
runs-on: ubuntu-latest
1112
steps:
12-
- name: Push Notification
13-
if: github.event_name == 'push'
13+
- name: Send Telegram Message
1414
uses: appleboy/telegram-action@master
1515
with:
1616
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
1717
to: ${{ secrets.TELEGRAM_CHAT_ID }}
1818
format: markdown
1919
message: |
20-
📌 *Push Event*
21-
Repository: [${{ github.repository }}](https://github.com/${{ github.repository }})
22-
Branch: `${{ github.ref }}`
23-
Author: `${{ github.actor }}`
20+
🚀 *CI Pipeline Finished*
21+
Repository: [${{ github.repository }}](https://github.com/${{ github.repository }})
22+
Status: *${{ github.event.workflow_run.conclusion }}*
23+
Branch: `${{ github.event.workflow_run.head_branch }}`
24+
Commit: `${{ github.event.workflow_run.head_sha }}`
2425
25-
- name: Pull Request Notification
26-
if: github.event_name == 'pull_request'
27-
uses: appleboy/telegram-action@master
28-
with:
29-
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
30-
to: ${{ secrets.TELEGRAM_CHAT_ID }}
31-
format: markdown
32-
message: |
33-
🔀 *Pull Request Event*
34-
Repository: [${{ github.repository }}](https://github.com/${{ github.repository }})
35-
Action: `${{ github.event.action }}`
36-
PR: [#${{ github.event.number }} - ${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})
37-
Author: `${{ github.event.pull_request.user.login }}`
26+
👤 Author: `${{ github.event.workflow_run.actor }}`
27+
28+
🔗 [Open Workflow Run](${{ github.event.workflow_run.html_url }})

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ dmypy.json
142142
cython_debug/
143143
.ruff_cache/
144144
database.db
145-
__pycache__/
145+
__pycache__/

.pre-commit-config.yaml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
11
repos:
2-
# - repo: https://github.com/pre-commit/mirrors-isort
3-
# rev: v5.10.1
4-
# hooks:
5-
# - id: isort
6-
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-ast
7+
- id: end-of-file-fixer
8+
9+
- repo: https://github.com/Yelp/detect-secrets
10+
rev: v1.5.0
11+
hooks:
12+
- id: detect-secrets
13+
args: [--baseline, .secrets.baseline]
14+
715
- repo: https://github.com/psf/black
8-
rev: 24.1.0
16+
rev: 25.12.0
917
hooks:
1018
- id: black
1119

12-
- repo: https://github.com/charliermarsh/ruff-pre-commit
13-
rev: v0.14.7
20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
rev: v0.14.8
1422
hooks:
1523
- id: ruff
24+
args: [--fix]
1625

1726
- repo: https://github.com/pre-commit/mirrors-mypy
1827
rev: v1.19.0
1928
hooks:
2029
- id: mypy
30+
# repos:
31+
# - repo: https://github.com/psf/black
32+
# rev: 24.1.0
33+
# hooks:
34+
# - id: black
35+
36+
# - repo: https://github.com/astral-sh/ruff-pre-commit
37+
# rev: v0.4.7
38+
# hooks:
39+
# - id: ruff
40+
# args: [--fix]
41+
42+
# - repo: https://github.com/pre-commit/mirrors-mypy
43+
# rev: v1.19.0
44+
# hooks:
45+
# - id: mypy
46+
# args: [--ignore-missing-imports]

0 commit comments

Comments
 (0)