Add CLI documentation auto-generator #160
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '*.md' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Lint | |
| run: pnpm lint | |
| - name: Install Sprites CLI | |
| run: | | |
| curl -fsSL https://sprites.dev/install.sh | bash | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| - name: Setup Sprites auth | |
| run: sprite auth setup --token "$SPRITES_TEST_TOKEN" | |
| env: | |
| SPRITES_TEST_TOKEN: ${{ secrets.SPRITES_TEST_TOKEN }} | |
| - name: Generate CLI Docs | |
| run: pnpm generate:cli-docs | |
| - name: Build | |
| run: pnpm build | |
| - name: Comment CLI Test Results on PR | |
| if: always() && github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = './cli-test-report.json'; | |
| let body = '### CLI Documentation Generator\n\n'; | |
| if (!fs.existsSync(path)) { | |
| body += '⚠️ No test report found (tests may have been skipped)\n'; | |
| } else { | |
| const report = JSON.parse(fs.readFileSync(path, 'utf8')); | |
| const allPassed = report.testsFailed === 0; | |
| const emoji = allPassed ? '✅' : '❌'; | |
| body += `| Metric | Value |\n`; | |
| body += `|--------|-------|\n`; | |
| body += `| CLI Version | \`${report.cliVersion}\` |\n`; | |
| body += `| Commands Generated | ${report.commandsGenerated.length} |\n`; | |
| body += `| Tests | ${emoji} ${report.testsPassed}/${report.testsRun} passed |\n`; | |
| if (report.errors.length > 0) { | |
| body += `\n<details><summary>❌ ${report.errors.length} Error(s)</summary>\n\n`; | |
| for (const error of report.errors) { | |
| body += `- **${error.command}** (${error.phase}): ${error.message}\n`; | |
| } | |
| body += `\n</details>\n`; | |
| } | |
| if (report.commandsGenerated.length > 0) { | |
| body += `\n<details><summary>📚 Commands documented</summary>\n\n`; | |
| body += report.commandsGenerated.map(c => `- \`${c}\``).join('\n'); | |
| body += `\n</details>\n`; | |
| } | |
| } | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existing = comments.find(c => c.body.includes('### CLI Documentation Generator')); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| } | |
| - name: Setup flyctl | |
| uses: superfly/flyctl-actions/setup-flyctl@master | |
| - name: Build Fly app | |
| run: flyctl deploy --build-only | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |