-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-actions.yml
More file actions
103 lines (92 loc) · 3.01 KB
/
Copy pathgithub-actions.yml
File metadata and controls
103 lines (92 loc) · 3.01 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
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
name: fallow-py
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
fallow-py-cleanup:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install fallow-py
run: pip install fallow-py
- name: Run fallow-py
shell: bash
run: |
set +e
if [ "${{ github.event_name }}" = "pull_request" ]; then
fallow-py analyze \
--root . \
--since "${{ github.event.pull_request.base.sha }}" \
--format agent-fix-plan \
--output pyfallow-report.json \
--fail-on warning \
--min-confidence medium
else
fallow-py analyze \
--root . \
--format agent-fix-plan \
--output pyfallow-report.json \
--fail-on warning \
--min-confidence medium
fi
echo "$?" > pyfallow-exit-code.txt
exit 0
- name: Render fallow-py comment
if: always()
shell: bash
run: |
if [ -f pyfallow-report.json ]; then
python examples/ci/render_pyfallow_comment.py pyfallow-report.json > pyfallow-comment.md
else
echo "## fallow-py analysis" > pyfallow-comment.md
echo "" >> pyfallow-comment.md
echo "fallow-py did not produce a JSON report. Check the CI logs." >> pyfallow-comment.md
fi
- name: Post GitHub PR comment
if: github.event_name == 'pull_request' && always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
shell: bash
run: |
python - <<'PY'
import json
from pathlib import Path
Path("pyfallow-comment.json").write_text(
json.dumps({"body": Path("pyfallow-comment.md").read_text(encoding="utf-8")}) + "\n",
encoding="utf-8",
)
PY
curl -fsS \
-X POST \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--data @pyfallow-comment.json \
"https://api.github.com/repos/${REPOSITORY}/issues/${PR_NUMBER}/comments"
- name: Upload fallow-py artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: fallow-py
path: |
pyfallow-report.json
pyfallow-comment.md
pyfallow-exit-code.txt
if-no-files-found: ignore
- name: Fail on blocking fallow-py findings
if: always()
shell: bash
run: exit "$(cat pyfallow-exit-code.txt 2>/dev/null || echo 0)"