Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add consistency check in CI for cn&en docs #110

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ jobs:
name: Build And Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4

- name: Check documentation consistency
run: |
bash .github/workflows/consistency-check.sh

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
Expand Down
67 changes: 37 additions & 30 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
name: Build check

on:
push:
branches-ignore:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
name: Build check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: |
yarn

- name: Build website
run: |
make build

name: Build check

on:
push:
branches-ignore:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
name: Build check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check documentation consistency
run: |
bash .github/workflows/consistency-check.sh

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: |
yarn

- name: Build website
run: |
make build
40 changes: 40 additions & 0 deletions .github/workflows/consistency-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

IGNORE_FILES="来杯咖啡.md"

# Convert IGNORE_FILES to array
IFS=' ' read -r -a ignore_array <<< "$IGNORE_FILES"

# Find all markdown files in docs directory
missing_files=0
while IFS= read -r file; do
# Get relative path from docs directory
rel_path="${file#docs/}"

# Check if file should be ignored
should_ignore=0
for ignore_file in "${ignore_array[@]}"; do
if [[ "$rel_path" == *"$ignore_file" ]]; then
should_ignore=1
break
fi
done

# Skip check if file should be ignored
if [ $should_ignore -eq 1 ]; then
echo "Ignoring file: ${rel_path}"
continue
fi

# Check if corresponding English translation exists
if [ ! -f "i18n/en/docusaurus-plugin-content-docs/current/${rel_path}" ]; then
echo "Missing English translation for: ${rel_path}"
missing_files=$((missing_files + 1))
fi
done < <(find docs -name "*.md" -type f)

# Exit with error if any files are missing
if [ $missing_files -gt 0 ]; then
echo "Error: Found ${missing_files} files without English translations"
exit 1
fi
Loading