diff --git a/.github/actions/setup-python/action.yaml b/.github/actions/setup-python/action.yaml index bb91951..19367a9 100644 --- a/.github/actions/setup-python/action.yaml +++ b/.github/actions/setup-python/action.yaml @@ -1,5 +1,5 @@ name: 'Setup Python' -description: 'Prints a greeting message' +description: 'Sets up Python, uv, and installs backend dependencies' inputs: python-version: required: true @@ -16,7 +16,8 @@ runs: with: python-version: ${{ inputs.python-version }} enable-cache: true - cache-dependency-path: ./uv.lock - - name: Install visitran-cloud dependencies + cache-dependency-path: backend/uv.lock + - name: Install backend dependencies shell: bash - run: uv sync + working-directory: backend + run: uv sync --group test diff --git a/.github/workflows/core-backend-tests.yaml b/.github/workflows/core-backend-tests.yaml index 6864906..52c6612 100644 --- a/.github/workflows/core-backend-tests.yaml +++ b/.github/workflows/core-backend-tests.yaml @@ -1,73 +1,71 @@ --- +name: Minimal Tests + +on: + workflow_dispatch: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +concurrency: + group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} + cancel-in-progress: true + +env: + FORCE_COLOR: "1" + +jobs: + minimal_tests: name: Minimal Tests + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + python-version: ["3.10"] + defaults: + run: + working-directory: backend + steps: + - uses: actions/checkout@v4 + with: + lfs: true + + - name: Setup Python + uses: ./.github/actions/setup-python/ + with: + python-version: ${{ matrix.python-version }} - on: - workflow_dispatch: - push: - branches: ["main"] - pull_request: - branches: [ "main"] + # pre-commit checks handled by pre-commit.ci - concurrency: - group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - env: - FORCE_COLOR: "1" - jobs: - minimal_tests: - name: Minimal Tests - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - python-version: ["3.11"] #,"3.9","3.10"] - steps: - #---------------------------------------------- - # check-out repo and set-up python - #---------------------------------------------- - - uses: actions/checkout@v4 - with: - lfs: true - - name: Setup Python - uses: ./.github/actions/setup-python/ - with: - python-version: ${{ matrix.python-version }} - - name: Cache pre-commit hooks - uses: actions/cache@v4 - if: github.ref != 'refs/heads/main' - with: - path: ~/.cache/pre-commit - key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + - name: Run tests + env: + DJANGO_SETTINGS_MODULE: backend.server.settings.dev + run: | + uv run coverage run --rcfile=pyproject.toml --source=. -m \ + pytest -x -vv ../tests/unit \ + --ignore=../tests/unit/test_logs.py \ + --ignore=../tests/unit/test_visitran_adapters \ + --ignore=../tests/unit/test_visitran_backend \ + -m "not snowflake and not bigquery and not trino and not postgres" - - name: Check pre-commit - if: github.ref != 'refs/heads/main' - run: | - uv run pre-commit run --all-files - - name: Run minimal core tests - run: | - uv run coverage run --rcfile=pyproject.toml --data-file=minimal.cov --context="minimal" --source=. -m \ - pytest -x -vv -m "not snowflake and not bigquery and not trino and not postgres" - - name: Run backend tests - run: | - uv run coverage run --rcfile=pyproject.toml --data-file=backend.cov --context="backend" --source=. -m \ - pytest -x -vv ./visitran_backend + - name: Generate coverage report + run: | + uv run coverage report -m + uv run coverage xml - - name: Combine to coverage xml - run: | - uv run coverage combine backend.cov minimal.cov - uv run coverage report -m - uv run coverage xml - - name: Git fetch unshallow - run: | - git fetch --unshallow + - name: Git fetch unshallow + working-directory: . + run: git fetch --unshallow - - name: Core SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - if: ${{ github.actor != 'dependabot[bot]' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - projectBaseDir: ./ - args: > - -Dproject.settings=./sonar-project.properties + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@v3 + if: ${{ github.actor != 'dependabot[bot]' }} + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + projectBaseDir: ./ + args: > + -Dproject.settings=./sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties index 3823834..3d779de 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,7 @@ -sonar.projectKey=zipstack_visitran_python +sonar.projectKey=Zipstack_visitran sonar.organization=zipstack sonar.python.version=3.10 -sonar.python.coverage.reportPaths=./coverage.xml +sonar.python.coverage.reportPaths=backend/coverage.xml sonar.exclusions=visitran_ui/** sonar.scm.provider=git sonar.verbose=false diff --git a/tests/unit/test_incremental_validation.py b/tests/unit/test_incremental_validation.py index 36ee53a..dffafdf 100644 --- a/tests/unit/test_incremental_validation.py +++ b/tests/unit/test_incremental_validation.py @@ -69,15 +69,11 @@ def test_valid_incremental_model(self): # Should not raise any exceptions model._validate_incremental_config() - def test_invalid_model_no_primary_key(self): - """Test that model without primary key raises error.""" + def test_model_no_primary_key_uses_append_mode(self): + """Test that model without primary key uses APPEND mode (no error).""" model = InvalidIncrementalModelNoPrimaryKey() - - with pytest.raises(ValueError) as exc_info: - model._validate_incremental_config() - - assert "Primary key is required" in str(exc_info.value) - assert "self.primary_key" in str(exc_info.value) + # primary_key is optional — without it, incremental uses APPEND mode + model._validate_incremental_config() def test_invalid_model_no_delta_strategy(self): """Test that model without delta strategy raises error."""