name: Documentation on: push: branches: [main] pull_request: jobs: create-docs: name: Create runs-on: ubuntu-24.04 permissions: contents: read steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0 with: bundler-cache: true - name: Build SwiftLint and SourceKitten uses: ./.github/actions/bazel-linux-build with: target: "//:swiftlint @SourceKittenFramework//:sourcekitten" env: CI_BAZELRC_FILE_CONTENT: ${{ secrets.CI_BAZELRC_FILE_CONTENT }} - name: Get Swift version id: swift_version run: echo "version=$(swift --version | grep '[5-9]\.[0-9]\+\(\.[0-9]\)\?' -o | head -1)" >> "$GITHUB_OUTPUT" - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: key: ubuntu-24.04-spm-${{ steps.swift_version.outputs.version }}-${{ hashFiles('Package.resolved', 'Package.swift') }} restore-keys: ubuntu-24.04-spm-${{ steps.swift_version.outputs.version }}- path: .build - name: Generate documentation run: | export PATH="/usr/share/swift/usr/bin:$PATH" make docs_linux - name: Process documentation violations run: | if [ -f "docs/undocumented.json" ]; then violation_count=$(ruby -rjson -e "puts JSON.parse(File.read('docs/undocumented.json'))['warnings'].length") if [ "$violation_count" -gt 0 ]; then echo "⚠️ Found $violation_count documentation violations" # Create GitHub annotations for each violation ruby -rjson -e " data = JSON.parse(File.read('docs/undocumented.json')) data['warnings'].each do |warning| # Convert absolute path to relative path for the annotation file_path = warning['file'].gsub('/home/runner/work/SwiftLint/SwiftLint/', '') puts \"::error file=#{file_path},line=#{warning['line']}::Undocumented #{warning['symbol_kind'].split('.').last}: #{warning['symbol']}\" end " exit 1 else echo "✅ No documentation violations found" fi else echo "❌ undocumented.json file not found" fi - name: Upload documentation if: github.event_name == 'push' uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 with: path: docs deploy-docs: name: Deploy runs-on: ubuntu-slim needs: create-docs if: github.event_name == 'push' permissions: pages: write id-token: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - name: Deploy documentation id: deployment uses: actions/deploy-pages@v5