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
+19 -7
View File
@@ -11,14 +11,21 @@ concurrency:
cancel-in-progress: true
jobs:
# Run tests first
tests:
name: Run Tests
uses: ./.gitea/workflows/test.yml
deploy-dev:
name: Deploy to Dev
runs-on: ubuntu-latest
needs: tests
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: Warm mirror cache for base images
run: |
set -u
@@ -55,10 +62,12 @@ jobs:
curl -I https://pypi.tuna.tsinghua.edu.cn || echo "Tsinghua PyPI unreachable"
exit 1
fi
- name: Sync runtime compose file
run: |
mkdir -p /volume1/docker/nas-dashboard
cp dashboard/docker-compose.dev.yml /volume1/docker/nas-dashboard/docker-compose.dev.yml
- name: Deploy dev
run: |
set -euo pipefail
@@ -80,13 +89,14 @@ jobs:
# Manually connect to networks after container is created
docker network connect nas-dashboard_internal nas-dashboard-dev || true
docker network connect gitea_gitea nas-dashboard-dev || true
- name: Wait for container to be healthy
run: |
echo "Waiting for container to be healthy..."
for i in {1..30}; do
STATUS=$(docker inspect --format='{{.State.Health.Status}}' nas-dashboard-dev 2>/dev/null || echo "starting")
if [ "$STATUS" = "healthy" ]; then
echo "Container is healthy"
echo "Container is healthy"
break
fi
echo "Waiting... ($i/30) Status: $STATUS"
@@ -95,16 +105,18 @@ jobs:
# Final check
STATUS=$(docker inspect --format='{{.State.Health.Status}}' nas-dashboard-dev 2>/dev/null || echo "unknown")
if [ "$STATUS" != "healthy" ]; then
echo "Container failed to become healthy: $STATUS"
echo "Container failed to become healthy: $STATUS"
docker logs nas-dashboard-dev --tail 50
exit 1
fi
- name: Run smoke tests
run: |
cd /volume1/repos/nas-tools
bash scripts/smoke-test-dashboard.sh dev
if [ $? -ne 0 ]; then
echo "Smoke tests failed! Check logs above."
echo "Smoke tests failed! Check logs above."
docker logs nas-dashboard-dev --tail 100
exit 1
fi
echo "✅ Smoke tests passed"