Skip to content

Commit 352c960

Browse files
committed
Add API reference validation workflow (manual trigger only for now)
1 parent d48d2f2 commit 352c960

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: API Reference Validation
2+
3+
on:
4+
# schedule:
5+
# # Every Thursday at 8 PM UTC
6+
# - cron: '0 20 * * 4'
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: api-reference-validation
11+
cancel-in-progress: false
12+
13+
jobs:
14+
validate:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.11'
29+
30+
- name: Install dependencies
31+
run: pip install pyyaml
32+
33+
- name: Run validation
34+
env:
35+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
36+
E2B_ACCESS_TOKEN: ${{ secrets.E2B_ACCESS_TOKEN }}
37+
run: |
38+
python3 scripts/validate_api_reference.py \
39+
--output openapi-validation-report.md \
40+
--verbose
41+
42+
- name: Check for changes
43+
id: changes
44+
run: |
45+
if git diff --quiet openapi-validation-report.md 2>/dev/null; then
46+
echo "changed=false" >> $GITHUB_OUTPUT
47+
else
48+
echo "changed=true" >> $GITHUB_OUTPUT
49+
fi
50+
51+
- name: Create PR
52+
if: steps.changes.outputs.changed == 'true'
53+
env:
54+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: |
56+
BRANCH="api-validation-$(date +%Y-%m-%d)"
57+
git config user.name "github-actions[bot]"
58+
git config user.email "github-actions[bot]@users.noreply.github.com"
59+
60+
git checkout -b "$BRANCH"
61+
git add openapi-validation-report.md
62+
git commit -m "docs: update API validation report $(date +%Y-%m-%d)"
63+
git push -u origin "$BRANCH"
64+
65+
gh pr create \
66+
--title "API validation report $(date +%Y-%m-%d)" \
67+
--body "$(cat <<'EOF'
68+
## Automated API Reference Validation
69+
70+
Weekly validation of `openapi-public.yml` against the live E2B API.
71+
72+
Review the updated `openapi-validation-report.md` for any new findings.
73+
EOF
74+
)" \
75+
--base main
76+
77+
- name: Summary
78+
run: |
79+
echo "## API Reference Validation" >> $GITHUB_STEP_SUMMARY
80+
echo "" >> $GITHUB_STEP_SUMMARY
81+
if [ -f openapi-validation-report.md ]; then
82+
# Extract critical findings count
83+
CRITICAL=$(grep -c "critical" openapi-validation-report.md 2>/dev/null || echo "0")
84+
echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY
85+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
86+
echo "| Critical findings | $CRITICAL |" >> $GITHUB_STEP_SUMMARY
87+
echo "| Report | openapi-validation-report.md |" >> $GITHUB_STEP_SUMMARY
88+
fi

0 commit comments

Comments
 (0)