mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Unit Test Improvements (#5087)
* Disable migration testing - Compare how long the unit tests take * Change file - To get unit tests to run * Fix format * Consolidate tasks.py - Remove coverage task - Add --coverage flag to test task * Fix typo * Run migration unit tests if migration files are updated * Fix * Touch migration file - Should cause migration unit tests to be run * Force migration checks for docker build * Prevent default report creation in unit tests - Should save some time * Add simple profiling for plugin loading - Display time taken to load each plugin * Fix to invoke test * Disable get_git_log (for testing) * Disable get_git_path in CI - Might remove this entirely? - For now, bypass for unit testing * Add debug for unit registry - Display time taken to load registry * Don't full-reload unit registry * Adjust migration test workflow - env var updates - change paths-filter output * Fix for migration_test.yaml - Actually need to set the output * env fix * db name * Prevent sleep if in test mode * Reduce sleep time on wait_for_db
This commit is contained in:
		
							
								
								
									
										1
									
								
								.github/workflows/docker.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/workflows/docker.yaml
									
									
									
									
										vendored
									
									
								
							@@ -78,6 +78,7 @@ jobs:
 | 
			
		||||
        run: |
 | 
			
		||||
          echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> docker.dev.env
 | 
			
		||||
          docker-compose run inventree-dev-server invoke test --disable-pty
 | 
			
		||||
          docker-compose run inventree-dev-server invoke test --migrations --disable-pty
 | 
			
		||||
          docker-compose down
 | 
			
		||||
      - name: Set up QEMU
 | 
			
		||||
        if: github.event_name != 'pull_request'
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										55
									
								
								.github/workflows/migration_test.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										55
									
								
								.github/workflows/migration_test.yaml
									
									
									
									
										vendored
									
									
								
							@@ -16,11 +16,11 @@ on:
 | 
			
		||||
env:
 | 
			
		||||
  python_version: 3.9
 | 
			
		||||
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 | 
			
		||||
  INVENTREE_DB_ENGINE: sqlite3
 | 
			
		||||
  INVENTREE_DB_NAME: /home/runner/work/InvenTree/db.sqlite3
 | 
			
		||||
  INVENTREE_MEDIA_ROOT: ../test_inventree_media
 | 
			
		||||
  INVENTREE_STATIC_ROOT: ../test_inventree_static
 | 
			
		||||
  INVENTREE_BACKUP_DIR: ../test_inventree_backup
 | 
			
		||||
  INVENTREE_DEBUG: info
 | 
			
		||||
  INVENTREE_PLUGINS_ENABLED: false
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  paths-filter:
 | 
			
		||||
@@ -28,7 +28,7 @@ jobs:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
 | 
			
		||||
    outputs:
 | 
			
		||||
      server: ${{ steps.filter.outputs.server }}
 | 
			
		||||
      migrations: ${{ steps.filter.outputs.migrations }}
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
 | 
			
		||||
@@ -36,17 +36,54 @@ jobs:
 | 
			
		||||
      id: filter
 | 
			
		||||
      with:
 | 
			
		||||
        filters: |
 | 
			
		||||
          server:
 | 
			
		||||
            - 'InvenTree/**'
 | 
			
		||||
            - 'requirements.txt'
 | 
			
		||||
            - 'requirements-dev.txt'
 | 
			
		||||
            - '.github/**'
 | 
			
		||||
          migrations:
 | 
			
		||||
            - '**/migrations/**'
 | 
			
		||||
            - '.github/workflows**'
 | 
			
		||||
 | 
			
		||||
  migration-tests:
 | 
			
		||||
    name: Run Migration Unit Tests
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    needs: paths-filter
 | 
			
		||||
    if: needs.paths-filter.outputs.migrations == 'true'
 | 
			
		||||
 | 
			
		||||
    env:
 | 
			
		||||
      INVENTREE_DB_ENGINE: django.db.backends.postgresql
 | 
			
		||||
      INVENTREE_DB_NAME: inventree
 | 
			
		||||
      INVENTREE_DB_USER: inventree
 | 
			
		||||
      INVENTREE_DB_PASSWORD: password
 | 
			
		||||
      INVENTREE_DB_HOST: '127.0.0.1'
 | 
			
		||||
      INVENTREE_DB_PORT: 5432
 | 
			
		||||
 | 
			
		||||
    services:
 | 
			
		||||
      postgres:
 | 
			
		||||
        image: postgres:14
 | 
			
		||||
        env:
 | 
			
		||||
          POSTGRES_USER: inventree
 | 
			
		||||
          POSTGRES_PASSWORD: password
 | 
			
		||||
        ports:
 | 
			
		||||
          - 5432:5432
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
 | 
			
		||||
      - name: Environment Setup
 | 
			
		||||
        uses: ./.github/actions/setup
 | 
			
		||||
        with:
 | 
			
		||||
          apt-dependency: gettext poppler-utils libpq-dev
 | 
			
		||||
          pip-dependency: psycopg2
 | 
			
		||||
          dev-install: true
 | 
			
		||||
          update: true
 | 
			
		||||
      - name: Run Tests
 | 
			
		||||
        run: invoke test --migrations --report
 | 
			
		||||
 | 
			
		||||
  migrations-checks:
 | 
			
		||||
    name: Run Database Migrations
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    needs: paths-filter
 | 
			
		||||
    if: needs.paths-filter.outputs.server == 'true'
 | 
			
		||||
    if: needs.paths-filter.outputs.migrations == 'true'
 | 
			
		||||
 | 
			
		||||
    env:
 | 
			
		||||
      INVENTREE_DB_ENGINE: sqlite3
 | 
			
		||||
      INVENTREE_DB_NAME: /home/runner/work/InvenTree/db.sqlite3
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v3
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								.github/workflows/qc_checks.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/qc_checks.yaml
									
									
									
									
										vendored
									
									
								
							@@ -204,7 +204,7 @@ jobs:
 | 
			
		||||
      - name: Check Migration Files
 | 
			
		||||
        run: python3 ci/check_migration_files.py
 | 
			
		||||
      - name: Coverage Tests
 | 
			
		||||
        run: invoke coverage
 | 
			
		||||
        run: invoke test --coverage
 | 
			
		||||
      - name: Upload Coverage Report
 | 
			
		||||
        uses: coverallsapp/github-action@v2
 | 
			
		||||
        with:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user