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

ci: add workflows of website build and markdown lint #36

Merged
merged 4 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build

on:
push:
branches:
- '*'
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: '3.13'

- name: Install dependencies
run: pip3 install -r requirements.txt

- name: Build docs
run: |
mkdocs -v build
50 changes: 50 additions & 0 deletions .github/workflows/lint-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Lint All

on:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install zhlint
run: yarn global add zhlint

- name: Lint all Markdown files
run: |
mkdir -p linted_output
file_list="linted_output/file_list.txt"
linted_failed_file=$(mktemp)
echo 0 > "$linted_failed_file"
find . -type f -name '*.md' | while read -r file; do
set +e
zhlint --config "$GITHUB_WORKSPACE"/ci/.zhlintrc "$file"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path is unmatched with line 30.

if [ $? -ne 0 ]; then
echo 1 > "$linted_failed_file"
echo "$file" >> "$file_list"
output_file="linted_output/report_and_suggested_fixes/$file"
mkdir -p "$(dirname "$output_file")"
zhlint --config "$GITHUB_WORKSPACE"/ci/.zhlintrc "$file" --output="$output_file" > "$output_file.log" 2>&1
fi
set -e
done
linted_failed=$(cat "$linted_failed_file")
rm "$linted_failed_file"
echo "linted_failed=$linted_failed" >> "$GITHUB_ENV"

- name: Upload linted Markdown
uses: actions/upload-artifact@v4
with:
name: linted-markdown
path: linted_output/

- name: Check lint errors
run: |
set -e
if [ "${{ env.linted_failed }}" -ne 0 ]; then
echo "Linting errors found. Please check the reports and suggested fixes in uploaded artifact."
exit 1
fi
63 changes: 63 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Lint

on:
push:
branches:
- '*'
pull_request:
branches:
- main
paths:
- '**/*.md' # Only run on Markdown file changes

jobs:
markdown-lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install zhlint
run: yarn global add zhlint

- name: Get changed Markdown files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: '**/*.md'

- name: Lint Markdown files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
mkdir -p linted_output
file_list="linted_output/file_list.txt"
linted_failed=0
for file in ${{ env.ALL_CHANGED_FILES }}; do
set +e
zhlint --config "$GITHUB_WORKSPACE"/ci/.zhlintrc "$file"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path is unmatched with line 45.

if [ $? -ne 0 ]; then
linted_failed=1
echo "$file" >> "$file_list"
output_file="linted_output/report_and_suggested_fixes/$file"
mkdir -p "$(dirname "$output_file")"
zhlint --config "$GITHUB_WORKSPACE"/ci/.zhlintrc "$file" --output="$output_file" > "$output_file.log" 2>&1
fi
set -e
done
echo "linted_failed=$linted_failed" >> "$GITHUB_ENV"

- name: Upload Linted Markdown
uses: actions/upload-artifact@v4
with:
name: linted-markdown
path: linted_output/

- name: Check lint errors
run: |
set -e
if [ "${{ env.linted_failed }}" -ne 0 ]; then
echo "Linting errors found. Please check the reports and suggested fixes in the job [Lint Markdown files]. Otherwise, you can download report files in uploaded artifact."
exit 1
fi
Loading