|
| 1 | +name: Verify FFI Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'key-wallet-ffi/src/**/*.rs' |
| 7 | + - 'key-wallet-ffi/FFI_API.md' |
| 8 | + - 'key-wallet-ffi/scripts/generate_ffi_docs.py' |
| 9 | + - 'dash-spv-ffi/src/**/*.rs' |
| 10 | + - 'dash-spv-ffi/FFI_API.md' |
| 11 | + - 'dash-spv-ffi/scripts/generate_ffi_docs.py' |
| 12 | + - '.github/workflows/verify-ffi-docs.yml' |
| 13 | + pull_request: |
| 14 | + paths: |
| 15 | + - 'key-wallet-ffi/src/**/*.rs' |
| 16 | + - 'key-wallet-ffi/FFI_API.md' |
| 17 | + - 'key-wallet-ffi/scripts/generate_ffi_docs.py' |
| 18 | + - 'dash-spv-ffi/src/**/*.rs' |
| 19 | + - 'dash-spv-ffi/FFI_API.md' |
| 20 | + - 'dash-spv-ffi/scripts/generate_ffi_docs.py' |
| 21 | + - '.github/workflows/verify-ffi-docs.yml' |
| 22 | + |
| 23 | +jobs: |
| 24 | + verify-key-wallet-docs: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + - name: Set up Python |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: '3.10' |
| 33 | + - name: Generate key-wallet-ffi documentation |
| 34 | + run: | |
| 35 | + cd key-wallet-ffi |
| 36 | + python3 scripts/generate_ffi_docs.py |
| 37 | + - name: Check if key-wallet-ffi documentation is up to date |
| 38 | + run: | |
| 39 | + cd key-wallet-ffi |
| 40 | + if ! git diff --exit-code FFI_API.md; then |
| 41 | + echo "❌ key-wallet-ffi documentation is out of date!" |
| 42 | + echo "" |
| 43 | + echo "The FFI_API.md file needs to be regenerated." |
| 44 | + echo "Please run the following command and commit the changes:" |
| 45 | + echo "" |
| 46 | + echo " cd key-wallet-ffi && make update-docs" |
| 47 | + echo "" |
| 48 | + echo "Changes detected:" |
| 49 | + git diff FFI_API.md |
| 50 | + exit 1 |
| 51 | + else |
| 52 | + echo "✅ key-wallet-ffi documentation is up to date" |
| 53 | + fi |
| 54 | +
|
| 55 | + verify-dash-spv-docs: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - name: Checkout repository |
| 59 | + uses: actions/checkout@v4 |
| 60 | + - name: Set up Python |
| 61 | + uses: actions/setup-python@v5 |
| 62 | + with: |
| 63 | + python-version: '3.10' |
| 64 | + - name: Generate dash-spv-ffi documentation |
| 65 | + run: | |
| 66 | + cd dash-spv-ffi |
| 67 | + python3 scripts/generate_ffi_docs.py |
| 68 | + - name: Check if dash-spv-ffi documentation is up to date |
| 69 | + run: | |
| 70 | + cd dash-spv-ffi |
| 71 | + if ! git diff --exit-code FFI_API.md; then |
| 72 | + echo "❌ dash-spv-ffi documentation is out of date!" |
| 73 | + echo "" |
| 74 | + echo "The FFI_API.md file needs to be regenerated." |
| 75 | + echo "Please run the following command and commit the changes:" |
| 76 | + echo "" |
| 77 | + echo " cd dash-spv-ffi && make update-docs" |
| 78 | + echo "" |
| 79 | + echo "Changes detected:" |
| 80 | + git diff FFI_API.md |
| 81 | + exit 1 |
| 82 | + else |
| 83 | + echo "✅ dash-spv-ffi documentation is up to date" |
| 84 | + fi |
| 85 | +
|
| 86 | + update-docs-comment: |
| 87 | + runs-on: ubuntu-latest |
| 88 | + if: failure() && github.event_name == 'pull_request' |
| 89 | + needs: |
| 90 | + - verify-key-wallet-docs |
| 91 | + - verify-dash-spv-docs |
| 92 | + permissions: |
| 93 | + pull-requests: write |
| 94 | + steps: |
| 95 | + - name: Comment on PR |
| 96 | + uses: actions/github-script@v7 |
| 97 | + with: |
| 98 | + script: | |
| 99 | + github.rest.issues.createComment({ |
| 100 | + issue_number: context.issue.number, |
| 101 | + owner: context.repo.owner, |
| 102 | + repo: context.repo.repo, |
| 103 | + body: `## ⚠️ FFI Documentation Update Required |
| 104 | +
|
| 105 | + The FFI API documentation is out of date. Please regenerate it by running: |
| 106 | +
|
| 107 | + For key-wallet-ffi: |
| 108 | + \`\`\`bash |
| 109 | + cd key-wallet-ffi |
| 110 | + make update-docs |
| 111 | + \`\`\` |
| 112 | +
|
| 113 | + For dash-spv-ffi: |
| 114 | + \`\`\`bash |
| 115 | + cd dash-spv-ffi |
| 116 | + make update-docs |
| 117 | + \`\`\` |
| 118 | +
|
| 119 | + Then commit the changes: |
| 120 | + \`\`\`bash |
| 121 | + git add */FFI_API.md |
| 122 | + git commit -m "docs: update FFI API documentation" |
| 123 | + \`\`\` |
| 124 | +
|
| 125 | + This ensures the documentation stays in sync with the actual FFI functions.` |
| 126 | + }) |
0 commit comments