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
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:
@@ -1,4 +1,4 @@
|
||||
name: Deploy Dashboard
|
||||
name: Deploy Dashboard (Main)
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
@@ -11,8 +11,15 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# Run tests first
|
||||
tests:
|
||||
name: Run Tests
|
||||
uses: ./.gitea/workflows/test.yml
|
||||
|
||||
deploy:
|
||||
name: Deploy to Production
|
||||
runs-on: ubuntu-latest
|
||||
needs: tests
|
||||
container:
|
||||
volumes:
|
||||
- /var/packages/ContainerManager/target/usr/bin/docker:/usr/bin/docker
|
||||
@@ -22,10 +29,10 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Warm mirror cache for base images
|
||||
run: |
|
||||
set -u
|
||||
# Use host.docker.internal or NAS IP to access registry mirror from container
|
||||
mirror_host="100.78.131.124:5501"
|
||||
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
@@ -40,6 +47,12 @@ jobs:
|
||||
|
||||
prewarm_base_image() {
|
||||
image_ref="$1"
|
||||
# Skip if image already exists locally
|
||||
if docker image inspect "${image_ref}" >/dev/null 2>&1; then
|
||||
echo "Image ${image_ref} already exists locally, skipping pre-pull"
|
||||
return 0
|
||||
fi
|
||||
|
||||
mirror_ref="${mirror_host}/library/${image_ref}"
|
||||
echo "Attempting mirror pre-pull: ${mirror_ref}"
|
||||
if timeout 120 docker pull "${mirror_ref}"; then
|
||||
@@ -57,13 +70,34 @@ jobs:
|
||||
run: |
|
||||
set -e
|
||||
export DOCKER_API_VERSION=1.43
|
||||
if ! DOCKER_BUILDKIT=0 docker build -t nas-dashboard:latest dashboard/; then
|
||||
if ! DOCKER_BUILDKIT=0 docker build --cache-from nas-dashboard:latest -t nas-dashboard:latest dashboard/; then
|
||||
echo "Build failed. Checking for network issues..."
|
||||
curl -I https://registry.npmmirror.com || echo "npmmirror unreachable"
|
||||
curl -I https://pypi.tuna.tsinghua.edu.cn || echo "Tsinghua PyPI unreachable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Sync runtime compose file
|
||||
run: cp dashboard/docker-compose.yml /nas-dashboard/docker-compose.yml
|
||||
|
||||
- name: Deploy
|
||||
run: docker compose -f /nas-dashboard/docker-compose.yml up -d --pull never
|
||||
run: |
|
||||
set -e
|
||||
export DOCKER_API_VERSION=1.43
|
||||
docker compose -f /nas-dashboard/docker-compose.yml up -d --pull never
|
||||
|
||||
- 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 2>/dev/null || echo "starting")
|
||||
if [ "$STATUS" = "healthy" ]; then
|
||||
echo "✅ Container is healthy"
|
||||
exit 0
|
||||
fi
|
||||
echo "Waiting... ($i/30) Status: $STATUS"
|
||||
sleep 2
|
||||
done
|
||||
echo "❌ Container failed to become healthy"
|
||||
docker logs nas-dashboard --tail 50
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user