-
Notifications
You must be signed in to change notification settings - Fork 41
157 lines (155 loc) · 6.74 KB
/
python-app.yml
File metadata and controls
157 lines (155 loc) · 6.74 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Developer Docs Validation
'on':
pull_request_target:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
permissions: read-all
outputs:
message: '${{ steps.check_changes.outputs.comment_message }}'
validation_message: '${{ steps.validation.outputs.validation_message }}'
validation_failed: '${{ steps.validation.outputs.validation_failed }}'
codeblock_message: '${{ steps.code_blocks.outputs.codeblock_message }}'
codeblock_failed: '${{ steps.code_blocks.outputs.codeblock_failed }}'
steps:
- uses: actions/checkout@v4
with:
ref: '${{ github.event.pull_request.head.sha }}'
fetch-depth: 0
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ci/requirements.txt
- name: Check Readme Changes
id: check_changes
run: python ci/check_readme_changes.py
env:
GH_SHA_MAIN_HEAD: '${{ github.sha }}'
GH_SHA_PR_HEAD: '${{ github.event.pull_request.head.sha }}'
- name: Validate Files V3
id: validation
continue-on-error: true
run: |
if python -m ci.validate_v3 2>&1 | tee validation_output.txt; then
echo "validation_failed=false" >> $GITHUB_OUTPUT
echo "validation_message=" >> $GITHUB_OUTPUT
else
echo "validation_failed=true" >> $GITHUB_OUTPUT
echo "validation_message<<EOF" >> $GITHUB_OUTPUT
echo "## ❌ Validation Failed" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "Your pull request has validation errors that need to be fixed. Please review the details below:" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
# Generate summary report
cat validation_output.txt | python ci/generate_cleanup_report.py >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "---" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "## 📋 Detailed Error Messages" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "<details>" >> $GITHUB_OUTPUT
echo "<summary>Click to expand full validation output with suggested fixes</summary>" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "\`\`\`" >> $GITHUB_OUTPUT
cat validation_output.txt >> $GITHUB_OUTPUT
echo "\`\`\`" >> $GITHUB_OUTPUT
echo "</details>" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "---" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "### 📚 Need Help?" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "- Review our [CONTRIBUTING.md](https://github.com/moveworks/developer-docs/blob/main/CONTRIBUTING.md) guide" >> $GITHUB_OUTPUT
echo "- The detailed error output includes suggested fixes you can copy/paste" >> $GITHUB_OUTPUT
echo "- Each error shows the exact field to add/remove/change" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
exit 1
fi
- name: Generate Code Blocks
id: code_blocks
continue-on-error: true
run: |
if python ci/copy_code_blocks.py 2>&1 | tee codeblock_output.txt; then
echo "codeblock_failed=false" >> $GITHUB_OUTPUT
echo "codeblock_message=" >> $GITHUB_OUTPUT
else
echo "codeblock_failed=true" >> $GITHUB_OUTPUT
echo "codeblock_message<<EOF" >> $GITHUB_OUTPUT
echo "## ⚠️ Code Block Changes Detected" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "Your pull request contains changes to code blocks that need to be regenerated." >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "### Files with code block changes:" >> $GITHUB_OUTPUT
echo "\`\`\`" >> $GITHUB_OUTPUT
cat codeblock_output.txt | grep -A 100 "Change detected" >> $GITHUB_OUTPUT
echo "\`\`\`" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "### What to do:" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "1. Pull the latest changes from your PR branch" >> $GITHUB_OUTPUT
echo "2. The \`.codeblocks/\` directories have been automatically updated" >> $GITHUB_OUTPUT
echo "3. Review the changes to ensure they're correct" >> $GITHUB_OUTPUT
echo "4. Commit the updated \`.codeblocks/\` files and push" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "Alternatively, run \`python ci/copy_code_blocks.py\` locally to regenerate them." >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
exit 1
fi
comment:
runs-on: ubuntu-latest
needs: build
permissions:
pull-requests: write
steps:
- name: Add Validation Comment
if: needs.build.outputs.validation_failed == 'true'
uses: actions/github-script@v7
env:
message: '${{needs.build.outputs.validation_message}}'
with:
github-token: '${{secrets.GITHUB_TOKEN}}'
script: |
const issue_number = context.issue.number;
const comment_message = process.env.message;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: comment_message
});
- name: Add Code Block Comment
if: needs.build.outputs.codeblock_failed == 'true'
uses: actions/github-script@v7
env:
message: '${{needs.build.outputs.codeblock_message}}'
with:
github-token: '${{secrets.GITHUB_TOKEN}}'
script: |
const issue_number = context.issue.number;
const comment_message = process.env.message;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: comment_message
});
- name: Add Preview Comment
if: needs.build.outputs.message != ''
uses: actions/github-script@v7
env:
message: '${{needs.build.outputs.message}}'
with:
github-token: '${{secrets.GITHUB_TOKEN}}'
script: |
const issue_number = context.issue.number;
const comment_message = process.env.message;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: comment_message
});