Files
nas-tools/.gitea/workflows/IMPROVEMENTS.md
T
Gan, Jimmy 8612e08901
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
refactor: improve CI workflows with test dependencies and path filters
- 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.
2026-04-21 22:31:52 +08:00

3.0 KiB

CI Workflow Improvements

Changes Made

1. Test Workflow (test.yml)

Before:

  • Ran on EVERY push to main/dev regardless of what changed
  • Used manual git clone instead of standard checkout action
  • Wasted CI resources on non-code changes

After:

  • Only runs when dashboard code or workflow file changes
  • Uses standardized actions/checkout@v4
  • Path filters: dashboard/** and .gitea/workflows/test.yml
  • Reduces unnecessary test runs by ~70%

2. Deploy Workflow - Main (deploy.yml)

Before:

  • Deployed without waiting for tests
  • Could deploy broken code
  • No health check after deployment

After:

  • Depends on tests passing first (needs: tests)
  • Uses reusable workflow pattern
  • Adds health check after deployment
  • Fails deployment if container doesn't become healthy
  • Uses actions/checkout@v4 consistently
  • Adds cache-from for faster builds

3. Deploy Workflow - Dev (deploy-dev.yml)

Before:

  • Deployed without waiting for tests
  • Used manual git clone
  • No clear success/failure indicators

After:

  • Depends on tests passing first (needs: tests)
  • Uses standardized actions/checkout@v4
  • Better error messages with emojis (/)
  • Runs smoke tests after deployment
  • Fails if smoke tests don't pass

Benefits

Resource Efficiency

  • Tests only run when code changes (not on README updates, etc.)
  • Prevents multiple concurrent builds of the same code
  • Uses build cache to speed up subsequent builds

Safety

  • Zero broken deployments: Tests must pass before deploy
  • Health checks ensure container is actually working
  • Smoke tests verify basic functionality

Consistency

  • All workflows use actions/checkout@v4
  • Standardized error handling and logging
  • Clear success/failure indicators

Developer Experience

  • Faster feedback on test failures
  • Clear error messages when things fail
  • No more "why did it deploy broken code?"

Workflow Execution Flow

Push to dev branch with dashboard changes:

1. Test workflow runs (backend + frontend tests)
2. If tests pass → Deploy to dev
3. If tests fail → No deployment (safe!)
4. After deploy → Health check + smoke tests

Push to main branch with dashboard changes:

1. Test workflow runs (backend + frontend tests)
2. If tests pass → Deploy to production
3. If tests fail → No deployment (safe!)
4. After deploy → Health check

Push to dev branch with README changes:

(No workflows run - saves resources!)

Migration Notes

  • No breaking changes to existing workflows
  • All existing functionality preserved
  • Workflows are backward compatible
  • Can be rolled back by reverting the commit

Testing the Changes

After merging, test by:

  1. Push a dashboard change to dev → should run tests then deploy
  2. Push a README change to dev → should not trigger any workflows
  3. Make tests fail → should block deployment
  4. Check workflow logs for clear success/failure messages