feat: add a script for generate a DocC documentation #6
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: Test Action | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| test-single-scheme: | |
| name: Test Single Scheme | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout action repo | |
| uses: actions/checkout@v4 | |
| with: | |
| path: docc-action | |
| - name: Create test Swift project | |
| run: | | |
| mkdir -p test-project | |
| cd test-project | |
| swift package init --type library --name TestLib | |
| cat > Sources/TestLib/TestLib.swift << 'EOF' | |
| /// A test library for DocC generation | |
| /// | |
| /// This library demonstrates DocC documentation generation. | |
| public struct TestLib { | |
| /// Creates a new instance | |
| public init() {} | |
| /// A test function | |
| /// - Returns: A greeting string | |
| public func greet() -> String { | |
| return "Hello, DocC!" | |
| } | |
| } | |
| EOF | |
| - name: Build Documentation | |
| uses: ./docc-action/test-project | |
| with: | |
| schemes: '["TestLib"]' | |
| version: 'v1.0.0' | |
| keep-old-versions: 'false' | |
| - name: Verify Output | |
| run: | | |
| cd test-project | |
| echo "📋 Checking documentation structure..." | |
| if [ ! -d "docs/v1.0.0/TestLib" ]; then | |
| echo "❌ Documentation directory not found" | |
| exit 1 | |
| fi | |
| if [ ! -f "docs/v1.0.0/TestLib/index.html" ]; then | |
| echo "❌ index.html not found" | |
| exit 1 | |
| fi | |
| if [ ! -d "docs/v1.0.0/TestLib/documentation" ]; then | |
| echo "❌ documentation directory not found" | |
| exit 1 | |
| fi | |
| echo "✅ Single scheme test passed" | |
| echo "📁 Generated structure:" | |
| tree -L 4 docs/ || find docs/ -type f | head -20 | |
| test-summary: | |
| name: Test Summary | |
| needs: [test-single-scheme] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Generate Summary | |
| run: | | |
| echo "# 📊 Test Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Test | Status |" >> $GITHUB_STEP_SUMMARY | |
| echo "|------|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Single Scheme | ${{ needs.test-single-scheme.result }} |" >> $GITHUB_STEP_SUMMARY | |
| # Проверяем, все ли тесты прошли | |
| if [ "${{ needs.test-single-scheme.result }}" == "success" ] && \ | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## ✅ All tests passed!" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## ❌ Some tests failed" >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| fi |