mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
chore: refactor GitHub Actions workflow to improve backend change detection and job dependencies
This commit is contained in:
parent
a786574484
commit
844b8ba609
1 changed files with 45 additions and 37 deletions
82
.github/workflows/backend-tests.yml
vendored
82
.github/workflows/backend-tests.yml
vendored
|
|
@ -10,10 +10,30 @@ concurrency:
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
changes:
|
||||||
|
name: Changes
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
backend: ${{ steps.filter.outputs.backend }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Check changed files
|
||||||
|
id: filter
|
||||||
|
uses: dorny/paths-filter@v4
|
||||||
|
with:
|
||||||
|
filters: |
|
||||||
|
backend:
|
||||||
|
- 'surfsense_backend/**'
|
||||||
|
- '.github/workflows/backend-tests.yml'
|
||||||
|
|
||||||
unit-tests:
|
unit-tests:
|
||||||
name: Unit Tests
|
name: Unit Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event.pull_request.draft == false
|
needs: changes
|
||||||
|
if: ${{ github.event.pull_request.draft == false && needs.changes.outputs.backend == 'true' }}
|
||||||
env:
|
env:
|
||||||
EMBEDDING_MODEL: sentence-transformers/all-MiniLM-L6-v2
|
EMBEDDING_MODEL: sentence-transformers/all-MiniLM-L6-v2
|
||||||
|
|
||||||
|
|
@ -21,26 +41,15 @@ jobs:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Check if backend files changed
|
|
||||||
id: backend-changes
|
|
||||||
uses: dorny/paths-filter@v3
|
|
||||||
with:
|
|
||||||
filters: |
|
|
||||||
backend:
|
|
||||||
- 'surfsense_backend/**'
|
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
uses: actions/setup-python@v6
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
with:
|
||||||
python-version: '3.12'
|
python-version: '3.12'
|
||||||
|
|
||||||
- name: Install UV
|
- name: Install UV
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
uses: astral-sh/setup-uv@v8.1.0
|
||||||
uses: astral-sh/setup-uv@v7
|
|
||||||
|
|
||||||
- name: Cache dependencies
|
- name: Cache dependencies
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
|
|
@ -51,26 +60,24 @@ jobs:
|
||||||
python-deps-
|
python-deps-
|
||||||
|
|
||||||
- name: Cache HuggingFace models
|
- name: Cache HuggingFace models
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/huggingface
|
path: ~/.cache/huggingface
|
||||||
key: hf-models-${{ env.EMBEDDING_MODEL }}
|
key: hf-models-${{ env.EMBEDDING_MODEL }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
|
||||||
working-directory: surfsense_backend
|
working-directory: surfsense_backend
|
||||||
run: uv sync
|
run: uv sync
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
|
||||||
working-directory: surfsense_backend
|
working-directory: surfsense_backend
|
||||||
run: uv run pytest -m unit
|
run: uv run pytest -m unit
|
||||||
|
|
||||||
integration-tests:
|
integration-tests:
|
||||||
name: Integration Tests
|
name: Integration Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event.pull_request.draft == false
|
needs: changes
|
||||||
|
if: ${{ github.event.pull_request.draft == false && needs.changes.outputs.backend == 'true' }}
|
||||||
env:
|
env:
|
||||||
EMBEDDING_MODEL: sentence-transformers/all-MiniLM-L6-v2
|
EMBEDDING_MODEL: sentence-transformers/all-MiniLM-L6-v2
|
||||||
|
|
||||||
|
|
@ -93,26 +100,15 @@ jobs:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Check if backend files changed
|
|
||||||
id: backend-changes
|
|
||||||
uses: dorny/paths-filter@v3
|
|
||||||
with:
|
|
||||||
filters: |
|
|
||||||
backend:
|
|
||||||
- 'surfsense_backend/**'
|
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
uses: actions/setup-python@v6
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
with:
|
||||||
python-version: '3.12'
|
python-version: '3.12'
|
||||||
|
|
||||||
- name: Install UV
|
- name: Install UV
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
uses: astral-sh/setup-uv@v8.1.0
|
||||||
uses: astral-sh/setup-uv@v7
|
|
||||||
|
|
||||||
- name: Cache dependencies
|
- name: Cache dependencies
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
|
|
@ -123,19 +119,16 @@ jobs:
|
||||||
python-deps-
|
python-deps-
|
||||||
|
|
||||||
- name: Cache HuggingFace models
|
- name: Cache HuggingFace models
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/huggingface
|
path: ~/.cache/huggingface
|
||||||
key: hf-models-${{ env.EMBEDDING_MODEL }}
|
key: hf-models-${{ env.EMBEDDING_MODEL }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
|
||||||
working-directory: surfsense_backend
|
working-directory: surfsense_backend
|
||||||
run: uv sync
|
run: uv sync
|
||||||
|
|
||||||
- name: Run integration tests
|
- name: Run integration tests
|
||||||
if: steps.backend-changes.outputs.backend == 'true'
|
|
||||||
working-directory: surfsense_backend
|
working-directory: surfsense_backend
|
||||||
env:
|
env:
|
||||||
TEST_DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense_test
|
TEST_DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense_test
|
||||||
|
|
@ -146,14 +139,29 @@ jobs:
|
||||||
test-gate:
|
test-gate:
|
||||||
name: Test Gate
|
name: Test Gate
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [unit-tests, integration-tests]
|
needs: [changes, unit-tests, integration-tests]
|
||||||
if: always()
|
if: always()
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check all test jobs
|
- name: Check all test jobs
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ needs.unit-tests.result }}" == "failure" ||
|
if [[ "${{ needs.changes.result }}" == "failure" || "${{ needs.changes.result }}" == "cancelled" ]]; then
|
||||||
"${{ needs.integration-tests.result }}" == "failure" ]]; then
|
echo "Backend change detection failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${{ github.event.pull_request.draft }}" == "true" ]]; then
|
||||||
|
echo "Draft PR; backend tests skipped"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${{ needs.changes.outputs.backend }}" != "true" ]]; then
|
||||||
|
echo "No backend changes detected; backend tests skipped"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${{ needs.unit-tests.result }}" != "success" ||
|
||||||
|
"${{ needs.integration-tests.result }}" != "success" ]]; then
|
||||||
echo "Backend tests failed"
|
echo "Backend tests failed"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue