-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (67 loc) · 2.13 KB
/
pr-validation.yml
File metadata and controls
76 lines (67 loc) · 2.13 KB
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
name: PR Validation
on:
pull_request:
types: [opened, synchronize, reopened]
branches: [main, master]
permissions:
contents: read
pull-requests: write
checks: write
jobs:
validate:
name: "🛡️ Bot Validation"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install Tools
run: |
pip install PyGithub requests pyyaml
- name: Validate Python Syntax
run: |
python -m py_compile bot.py workflow_manager.py comment_handler.py
- name: Validate YAML Files
run: |
python << 'EOF'
import yaml
import sys
for yaml_file in ['action.yml', 'config.yaml']:
try:
with open(yaml_file) as f:
yaml.safe_load(f)
print(f"✅ {yaml_file} is valid")
except FileNotFoundError:
print(f"⚠️ {yaml_file} not found, skipping")
except Exception as e:
print(f"❌ {yaml_file} validation failed: {e}")
sys.exit(1)
EOF
feedback:
needs: [validate]
runs-on: ubuntu-latest
if: always()
steps:
- name: Comment on PR
uses: actions/github-script@v8
with:
script: |
const status = '${{ needs.validate.result }}';
if (status === 'success') {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "✅ **PR Validation Passed!**\n\nAll checks passed successfully."
});
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "❌ **PR Validation Failed**\n\nPlease check the logs and fix the issues."
});
}