refactor: improve CI workflows with test dependencies and path filters
Deploy Dashboard (Dev) / Run Tests (push) Has been cancelled
Deploy Dashboard (Dev) / Deploy to Dev (push) Has been cancelled
Run Tests / Test Summary (push) Failing after 17s
Run Tests / Backend Tests (pull_request) Failing after 11m30s
Run Tests / Backend Tests (push) Failing after 5m6s
Run Tests / Frontend Tests (push) Failing after 3m22s
Run Tests / Frontend Tests (pull_request) Failing after 1m44s
Run Tests / Test Summary (pull_request) Failing after 17s

- Add path filters to test.yml to only run on code changes
- Make deploy workflows depend on tests passing first
- Standardize all workflows to use actions/checkout@v4
- Add health checks and better error messages to deployments
- Add build cache support for faster builds
- Document all improvements in IMPROVEMENTS.md

This prevents broken code from being deployed and reduces unnecessary CI runs.
This commit is contained in:
Gan, Jimmy
2026-04-21 22:31:52 +08:00
parent e35319f881
commit 8612e08901
4 changed files with 171 additions and 24 deletions
+12 -13
View File
@@ -3,8 +3,14 @@ name: Run Tests
on:
push:
branches: [main, dev]
paths:
- 'dashboard/**'
- '.gitea/workflows/test.yml'
pull_request:
branches: [main]
paths:
- 'dashboard/**'
- '.gitea/workflows/test.yml'
jobs:
backend-tests:
@@ -15,10 +21,9 @@ jobs:
steps:
- name: Checkout repository
run: |
git clone --depth 1 http://gitea:3000/jimmy/nas-tools.git .
git fetch --depth 1 origin ${{ github.sha }}
git checkout ${{ github.sha }}
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Python
run: |
@@ -54,11 +59,9 @@ jobs:
echo "Installing fresh dependencies..."
python3 -m venv venv
. venv/bin/activate
# Use Tsinghua PyPI mirror for faster downloads in China
pip install --cache-dir=$PIP_CACHE_DIR -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
pip install --cache-dir=$PIP_CACHE_DIR -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements-dev.txt
pip install --cache-dir=$PIP_CACHE_DIR -i https://pypi.tuna.tsinghua.edu.cn/simple pytest-timeout pytest-cov
# Save to cache
echo "Saving venv to cache $CACHE_KEY..."
cp -a venv $CACHE_DIR/
fi
@@ -72,7 +75,6 @@ jobs:
--junit-xml=test-results.xml \
--cov-fail-under=49
# Explicitly check exit code
if [ $? -ne 0 ]; then
echo "❌ Backend tests failed!"
exit 1
@@ -103,10 +105,9 @@ jobs:
steps:
- name: Checkout repository
run: |
git clone --depth 1 http://gitea:3000/jimmy/nas-tools.git .
git fetch --depth 1 origin ${{ github.sha }}
git checkout ${{ github.sha }}
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Node.js
run: |
@@ -140,7 +141,6 @@ jobs:
else
echo "Installing fresh dependencies..."
npm ci
# Save to cache
echo "Saving to cache $CACHE_KEY..."
cp -a node_modules $CACHE_DIR/
fi
@@ -152,7 +152,6 @@ jobs:
cd dashboard/frontend
npm run test:coverage -- --reporter=verbose --run --pool=forks --poolOptions.forks.maxForks=2
# Explicitly check exit code
if [ $? -ne 0 ]; then
echo "❌ Frontend tests failed!"
exit 1