-
Notifications
You must be signed in to change notification settings - Fork 286
157 lines (137 loc) · 6.48 KB
/
extension-validation.yml
File metadata and controls
157 lines (137 loc) · 6.48 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: Extension Validation
on:
pull_request:
push:
branches:
- main
- 5.*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate-extensions:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
timeout-minutes: 30
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0 # Fetch full history for git diff
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: scripts/requirements.txt
- name: Configure git
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
echo "Installing dependencies from requirements.txt:"
cat scripts/requirements.txt
pip install -r scripts/requirements.txt
echo "Verifying installed packages:"
pip list | grep -E "(jsonschema|requests)"
- name: Run repository structure validation
id: structure-validation
continue-on-error: true
run: |
mkdir -p /tmp/validation-reports
python scripts/check_repository_structure.py \
> /tmp/validation-reports/repository-structure-report.md
- name: Get changed files
run: |
echo "Event: ${{ github.event_name }}"
mkdir -p /tmp/validation-reports
if [ "${{ github.event_name }}" = "pull_request" ]; then
# For pull requests, compare against the base branch
BASE_REF="${{ github.event.pull_request.base.ref }}"
echo "Base ref: $BASE_REF"
git diff --name-only "origin/$BASE_REF"...HEAD > /tmp/validation-reports/changed_files.txt 2>/dev/null
else
# For pushes, compare against the previous commit or get all JSON files if it's the first commit
git diff --name-only HEAD~1 HEAD > /tmp/validation-reports/changed_files.txt 2>/dev/null
fi
echo "Changed JSON files:"
cat /tmp/validation-reports/changed_files.txt
- name: Run extension validation
id: extension-validation
continue-on-error: true
run: |
mkdir -p /tmp/validation-reports
python scripts/check_description_files.py \
$(cat /tmp/validation-reports/changed_files.txt | tr '\n' ' ') \
> /tmp/validation-reports/extension-validation-report.md
echo 'report<<EOF' >> $GITHUB_OUTPUT
cat /tmp/validation-reports/extension-validation-report.md >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Combine validation reports and display summary
if: always()
run: |
mkdir -p /tmp/validation-reports
if [ -f /tmp/validation-reports/repository-structure-report.md ]; then
cat /tmp/validation-reports/repository-structure-report.md >> /tmp/validation-reports/validation-report.md
else
echo "❌ Repository structure validation report not generated" >> /tmp/validation-reports/validation-report.md
fi
echo "" >> /tmp/validation-reports/validation-report.md
if [ -f /tmp/validation-reports/extension-validation-report.md ]; then
cat /tmp/validation-reports/extension-validation-report.md >> /tmp/validation-reports/validation-report.md
else
echo "❌ Extension validation report not generated" >> /tmp/validation-reports/validation-report.md
fi
if [ -f /tmp/validation-reports/validation-report.md ]; then
cat /tmp/validation-reports/validation-report.md >> $GITHUB_STEP_SUMMARY
else
echo "❌ Validation report not generated" >> $GITHUB_STEP_SUMMARY
fi
- name: Upload validation reports
if: always()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: validation-reports
path: |
/tmp/validation-reports/validation-report.md
/tmp/validation-reports/repository-structure-report.md
/tmp/validation-reports/extension-validation-report.md
/tmp/validation-reports/changed_files.txt
retention-days: 30
- name: Find Comment
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && always()
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "<!-- extension-validation-report -->"
- name: Comment PR with report
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && always()
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- extension-validation-report -->
# Extension Validation Report
${{ steps.extension-validation.outputs.report }}
***
*This report was automatically generated by the Extension Validation workflow and it is updated automatically when files are modified.*
edit-mode: replace
- name: Check validation results
if: always()
run: |
echo "Checking validation results..."
STRUCTURE_RESULT="${{ steps.structure-validation.outcome }}"
EXTENSION_RESULT="${{ steps.extension-validation.outcome }}"
echo "Repository structure validation: $STRUCTURE_RESULT"
echo "Extension validation: $EXTENSION_RESULT"
if [ "$STRUCTURE_RESULT" != "success" ] || [ "$EXTENSION_RESULT" != "success" ]; then
echo "❌ Extension description validation failed. See workflow summary for more information: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
exit 1
else
echo "✅ All validation steps passed. See workflow summary for more information: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
fi