-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (91 loc) · 3.78 KB
/
monitor_changes.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Monitor Changes, Lint, and Send Notifications
on:
push:
branches: [ dev ] # Adjust this to the branch you want to monitor
workflow_dispatch:
jobs:
lint_and_notify:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Get Commit Details
id: commit_details
run: |
# Escape special characters in commit message
message=$(git log -1 --pretty=%B | sed 's/"/\\"/g')
author=$(git log -1 --pretty=%an | sed 's/"/\\"/g')
echo "message=$message" >> $GITHUB_OUTPUT
echo "author=$author" >> $GITHUB_OUTPUT
- name: Check for changes
id: check_changes
run: |
rm -f changes.txt
# Fetch both branches
git fetch origin main dev || true
# Compare changes between dev and main branches
git diff --name-only origin/main origin/dev > changes.txt
changes=$(cat changes.txt | tr '\n' ', ' | sed 's/,$//')
echo "files_changed=$changes" >> $GITHUB_OUTPUT
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8 pytest torch torchvision
- name: Run flake8
id: flake8
run: |
# Check if files exist before running flake8
files_to_lint=(
"scripts/auto_commit.py"
"pl_models.py"
"test.py"
"train.py"
"models/unet_fft.py"
"xrd_transformer.py"
"model.py"
)
existing_files=()
for file in "${files_to_lint[@]}"; do
if [ -f "$file" ]; then
existing_files+=("$file")
fi
done
if [ ${#existing_files[@]} -eq 0 ]; then
echo "lint_results=No Python files found to lint" >> $GITHUB_OUTPUT
else
# Only check for bugs (E9**, F***) and ignore style issues
flake8_output=$(flake8 --select=E9,F "${existing_files[@]}" || true)
echo "$flake8_output" > flake8_output.txt
lint_results=$(head -n 5 flake8_output.txt | sed ':a;N;$!ba;s/\n/%0A/g' | sed 's/"/\\"/g')
echo "lint_results=$lint_results" >> $GITHUB_OUTPUT
fi
- name: Run basic tests
id: basic_tests
run: |
test_output=$(python github_tests.py)
echo "test_results<<EOF" >> $GITHUB_OUTPUT
echo "$test_output" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Send Telegram Notification
if: always()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
message: |
🔄 Новые изменения обнаружены! 🎉
📝 Сообщение коммита: ${{ steps.commit_details.outputs.message || 'Нет сообщения' }}
👤 Автор: ${{ steps.commit_details.outputs.author || 'Неизвестный автор' }}
📂 Измененные файлы:
${{ steps.check_changes.outputs.files_changed || 'Нет измененных файлов' }}
📚 Репозиторий: ${{ github.repository }}
🔗 Ссылка: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
⚠️ Результаты линтинга:
${{ steps.flake8.outputs.lint_results || 'Нет замечаний линтера' }} ✨
🧪 Результаты тестов:
${{ steps.basic_tests.outputs.test_results || 'Тесты не были выполнены' }} 🚀