forked from KanuaK/triton-ascend
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (120 loc) · 4.97 KB
/
Copy pathdocumentation.yml
File metadata and controls
134 lines (120 loc) · 4.97 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Documentation
on:
pull_request:
paths:
- '*.md'
- 'docs/**/*.md'
- 'docs/**/*.mdx'
- 'docs/**/_toc.yaml'
- '.github/workflows/documentation.yml'
- '.github/docs-ci/**'
# Manual full scans (checkAll) to surface errors in existing docs
# that incremental PR runs never touch. These never block a PR.
workflow_dispatch:
permissions:
contents: read
concurrency:
group: docs-check-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/main' }}
jobs:
docs-check:
name: Docs gate
runs-on: linux-amd64-cpu-8-hk
container:
image: swr.cn-southwest-2.myhuaweicloud.com/modelfoundry/ascend/triton:github_action
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Full history is required for PR runs: the checker diffs <base>...HEAD
# to find the changed docs. (Harmless for full scans.)
fetch-depth: 0
- name: Fetch base branch
if: github.event_name == 'pull_request'
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git fetch --no-tags origin "${{ github.event.pull_request.base.ref }}"
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache cspell dictionaries
uses: actions/cache@v4
with:
path: .cache
key: docs-ci-${{ runner.os }}-${{ hashFiles('.github/docs-ci/docs-ci-v2.js', '.github/docs-ci/config.json') }}
- name: Run docs gate
shell: bash
env:
DOCS_TARGET_REPO: ${{ github.repository }}
# PR: incremental (changed files only). Manual/scheduled: full scan.
DOCS_BASE_REF: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.event.pull_request.base.ref) || github.ref_name }}
DOCS_CHECK_ALL: ${{ github.event_name != 'pull_request' }}
run: |
REPO_ROOT="$GITHUB_WORKSPACE"
BASE_REF="${DOCS_BASE_REF:-origin/main}"
TARGET_REPO="${DOCS_TARGET_REPO:-all}"
CI_CONFIG="${DOCS_CI_CONFIG:-$REPO_ROOT/.github/docs-ci/config.json}"
OUTPUT_COUNT="${DOCS_OUTPUT_COUNT:-50}"
OUTPUT_PATH="${DOCS_OUTPUT_PATH:-$REPO_ROOT/output.md}"
# The checker is vendored in this repo — no download needed.
CLI_PATH="${DOCS_CLI:-$REPO_ROOT/.github/docs-ci/docs-ci-v2.js}"
if [ ! -f "$CLI_PATH" ]; then
echo "::error::docs checker not found at $CLI_PATH"
exit 1
fi
# codespell-check relies on cspell-lib and its dictionaries, which the
# bundle resolves from node_modules next to itself. Install them on
# demand in .cache (cached across runs) and symlink into the vendored
# directory so the bundle can find them.
NEED_CSPELL="${DOCS_NEED_CSPELL:-}"
if [ -z "$NEED_CSPELL" ] && [ -f "$CI_CONFIG" ] && grep -q "codespell-check" "$CI_CONFIG"; then
NEED_CSPELL=1
fi
if [ -n "$NEED_CSPELL" ]; then
CSPELL_DIR="${DOCS_CSPELL_DIR:-$REPO_ROOT/.cache}"
if [ ! -d "$CSPELL_DIR/node_modules/cspell-lib" ]; then
echo "Installing cspell-lib@${DOCS_CSPELL_VERSION:-9.2.1} for codespell-check"
mkdir -p "$CSPELL_DIR"
[ -f "$CSPELL_DIR/package.json" ] || printf '{"name":"docs-ci-runtime","private":true}\n' > "$CSPELL_DIR/package.json"
( cd "$CSPELL_DIR" && npm i --no-audit --no-fund --loglevel=error "cspell-lib@${DOCS_CSPELL_VERSION:-9.2.1}" )
fi
# Symlink node_modules next to the checker so the bundle can resolve cspell-lib.
CLI_DIR="$(dirname "$CLI_PATH")"
if [ ! -e "$CLI_DIR/node_modules" ]; then
ln -s "$CSPELL_DIR/node_modules" "$CLI_DIR/node_modules"
fi
fi
ARGS=(
--repoPath="$REPO_ROOT"
--targetOwnerRepo="$TARGET_REPO"
--targetBranch="$BASE_REF"
--ciConfigUrl="$CI_CONFIG"
--outputCount="$OUTPUT_COUNT"
--outputPath="$OUTPUT_PATH"
)
if [ "${DOCS_CHECK_ALL:-}" = "true" ]; then
ARGS+=(--checkAll=true)
fi
rm -f "$OUTPUT_PATH"
cd "$REPO_ROOT"
node "$CLI_PATH" "${ARGS[@]}"
if [ ! -f "$OUTPUT_PATH" ]; then
echo "::error::docs checker produced no report at $OUTPUT_PATH"
exit 1
fi
if head -n 1 "$OUTPUT_PATH" | grep -q "❌"; then
echo "::error::Docs PR gate failed - see report below / job summary."
cat "$OUTPUT_PATH"
exit 1
fi
echo "Docs PR gate passed."
- name: Publish report
if: always()
run: |
if [ -f output.md ]; then
{
echo "## Docs Check"
echo ""
cat output.md
} >> "$GITHUB_STEP_SUMMARY"
fi