forked from realm/SwiftLint
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (78 loc) · 2.95 KB
/
docs.yml
File metadata and controls
84 lines (78 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- uses: ruby/setup-ruby@d697be2f83c6234b20877c3b5eac7a7f342f0d0c # v1.269.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@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
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@v4
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@v4