[CI] disable unnecessary ci and update pre-commit (#80)
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
This commit is contained in:
1 parent
5707fc78d5
commit
9ccff6c710
4 files changed
+30
-184
No files matched your search
@@ -1,60 +0,0 @@
|
||||
name: CI All Files
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test-changed:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["3.12", "3.13"]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Need full history to detect changes
|
||||
|
||||
- name: Free disk space
|
||||
run: |
|
||||
# Remove large, preinstalled toolchains we don't need on the runner
|
||||
sudo rm -rf /usr/share/dotnet
|
||||
sudo rm -rf /opt/ghc
|
||||
sudo rm -rf /usr/local/lib/android
|
||||
sudo rm -rf /opt/hostedtoolcache/CodeQL
|
||||
# Prune docker to reclaim space (safe on GH runners)
|
||||
docker system prune -af || true
|
||||
df -h
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Prepare environment with uv
|
||||
run: |
|
||||
python -m pip install --upgrade pip uv
|
||||
uv venv --python "${{ matrix.python-version }}" --seed
|
||||
echo "VIRTUAL_ENV=${PWD}/.venv" >> "$GITHUB_ENV"
|
||||
echo "PATH=${PWD}/.venv/bin:$PATH" >> "$GITHUB_ENV"
|
||||
source .venv/bin/activate
|
||||
uv pip install -e ".[dev]"
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
if [ ! -d tests ]; then
|
||||
echo "tests/ directory not found. Skipping pytest run."
|
||||
|
||||
|
||||
exit 0
|
||||
fi
|
||||
TEST_FILES=$(find tests -type f \( -name "test_*.py" -o -name "*_test.py" \))
|
||||
if [ -z "$TEST_FILES" ]; then
|
||||
echo "No pytest-compatible test files detected under tests/. Skipping pytest run."
|
||||
exit 0
|
||||
fi
|
||||
pytest tests/ -v -m "not slow"
|
||||
@@ -1,124 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
test_changed_only:
|
||||
description: 'Only test changed files (true) or all files (false)'
|
||||
required: false
|
||||
default: 'true'
|
||||
type: choice
|
||||
options:
|
||||
- 'true'
|
||||
- 'false'
|
||||
enable_changed_files_detection:
|
||||
description: 'Enable changed files detection feature'
|
||||
required: false
|
||||
default: 'true'
|
||||
type: choice
|
||||
options:
|
||||
- 'true'
|
||||
- 'false'
|
||||
workflow_call:
|
||||
inputs:
|
||||
test_changed_only:
|
||||
description: 'Only test changed files (true) or all files (false)'
|
||||
required: false
|
||||
type: string
|
||||
default: 'true'
|
||||
enable_changed_files_detection:
|
||||
description: 'Enable changed files detection feature'
|
||||
required: false
|
||||
type: string
|
||||
default: 'true'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["3.12", "3.13"]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Free disk space
|
||||
run: |
|
||||
# Remove large, preinstalled toolchains we don't need on the runner
|
||||
sudo rm -rf /usr/share/dotnet
|
||||
sudo rm -rf /opt/ghc
|
||||
sudo rm -rf /usr/local/lib/android
|
||||
sudo rm -rf /opt/hostedtoolcache/CodeQL
|
||||
# Prune docker to reclaim space (safe on GH runners)
|
||||
docker system prune -af || true
|
||||
df -h
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Prepare environment with uv
|
||||
run: |
|
||||
python -m pip install --upgrade pip uv
|
||||
uv venv --python "${{ matrix.python-version }}" --seed
|
||||
echo "VIRTUAL_ENV=${PWD}/.venv" >> "$GITHUB_ENV"
|
||||
echo "PATH=${PWD}/.venv/bin:${PATH}" >> "$GITHUB_ENV"
|
||||
# Activate env to ensure subsequent commands succeed in this step
|
||||
source .venv/bin/activate
|
||||
uv pip install -e ".[dev]"
|
||||
|
||||
- name: Determine test scope
|
||||
id: test-scope
|
||||
env:
|
||||
ENABLE_CHANGED_FILES_DETECTION: ${{ inputs.enable_changed_files_detection || 'true' }}
|
||||
TEST_CHANGED_ONLY: ${{ inputs.test_changed_only || 'true' }}
|
||||
run: |
|
||||
# Determine if we should test only changed files
|
||||
# If detection is disabled, always test all files
|
||||
if [ "$ENABLE_CHANGED_FILES_DETECTION" != "true" ]; then
|
||||
TEST_CHANGED_ONLY="false"
|
||||
fi
|
||||
|
||||
echo "test_changed_only=$TEST_CHANGED_ONLY" >> "$GITHUB_OUTPUT"
|
||||
echo "enable_detection=$ENABLE_CHANGED_FILES_DETECTION" >> "$GITHUB_OUTPUT"
|
||||
echo "Test scope: $TEST_CHANGED_ONLY"
|
||||
echo "Changed files detection: $ENABLE_CHANGED_FILES_DETECTION"
|
||||
|
||||
- name: Get changed test files
|
||||
id: changed-tests
|
||||
if: steps.test-scope.outputs.test_changed_only == 'true' && steps.test-scope.outputs.enable_detection == 'true'
|
||||
env:
|
||||
GITHUB_BASE_REF: ${{ github.event.pull_request.base.sha || '' }}
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
chmod +x .github/scripts/detect_changed_tests.sh
|
||||
.github/scripts/detect_changed_tests.sh \
|
||||
"${{ github.event.pull_request.base.sha || github.event.before || '' }}" \
|
||||
"${{ github.sha }}" \
|
||||
"${{ github.event_name }}"
|
||||
|
||||
- name: Run tests (changed files only)
|
||||
if: steps.test-scope.outputs.test_changed_only == 'true' && steps.changed-tests.outputs.has_tests == 'true'
|
||||
run: |
|
||||
pytest "${{ steps.changed-tests.outputs.test_files }}" -v -m "not slow"
|
||||
|
||||
- name: Run tests (all files)
|
||||
if: steps.test-scope.outputs.test_changed_only == 'false' || steps.changed-tests.outputs.has_tests == 'false'
|
||||
run: |
|
||||
if [ ! -d tests ]; then
|
||||
echo "tests/ directory not found. Skipping pytest run."
|
||||
exit 0
|
||||
fi
|
||||
TEST_FILES=$(find tests -type f \( -name "test_*.py" -o -name "*_test.py" \))
|
||||
if [ -z "$TEST_FILES" ]; then
|
||||
echo "No pytest-compatible test files detected under tests/. Skipping pytest run."
|
||||
exit 0
|
||||
fi
|
||||
pytest tests/ -v -m "not slow"
|
||||
@@ -3,6 +3,8 @@ name: pre-commit
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch: # for manual trigger
|
||||
|
||||
concurrency:
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
default_install_hook_types:
|
||||
- pre-commit
|
||||
- commit-msg
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.6.0
|
||||
@@ -30,3 +33,28 @@ repos:
|
||||
hooks:
|
||||
- id: actionlint
|
||||
files: ^\.github/workflows/.*\.ya?ml$
|
||||
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: signoff-commit
|
||||
name: Sign-off Commit
|
||||
entry: bash
|
||||
args:
|
||||
- -c
|
||||
- |
|
||||
if ! grep -q "^Signed-off-by: $(git config user.name) <$(git config user.email)>" "$(git rev-parse --git-path COMMIT_EDITMSG)"; then
|
||||
printf "\nSigned-off-by: $(git config user.name) <$(git config user.email)>\n" >> "$(git rev-parse --git-path COMMIT_EDITMSG)"
|
||||
fi
|
||||
language: system
|
||||
verbose: true
|
||||
stages: [commit-msg]
|
||||
|
||||
# Keep `suggestion` last
|
||||
- id: suggestion
|
||||
name: Suggestion
|
||||
entry: bash -c 'echo "To bypass all the pre-commit hooks, add --no-verify to git commit. To skip a specific hook, prefix the commit command with SKIP=<hook-id>."'
|
||||
language: system
|
||||
verbose: true
|
||||
pass_filenames: false
|
||||
# Insert new entries above the `suggestion` entry
|
||||
Reference in new issue
Block a user