ci: migrate unittests and coverage
This commit is contained in:
		
							
								
								
									
										26
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								README.md
									
									
									
									
									
								
							@ -50,31 +50,7 @@ pipenv sync -d
 | 
				
			|||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Since passbook uses PostgreSQL-specific fields, you also need a local PostgreSQL instance to develop. passbook also uses redis for caching and message queueing.
 | 
					Since passbook uses PostgreSQL-specific fields, you also need a local PostgreSQL instance to develop. passbook also uses redis for caching and message queueing.
 | 
				
			||||||
For these databases you can use [Postgres.app](https://postgresapp.com/) and [Redis.app](https://jpadilla.github.io/redisapp/) on macOS or use it via docker-comppose:
 | 
					For these databases you can use [Postgres.app](https://postgresapp.com/) and [Redis.app](https://jpadilla.github.io/redisapp/) on macOS or use it the docker-compose file in `scripts/docker-compose.yml`.
 | 
				
			||||||
 | 
					 | 
				
			||||||
```yaml
 | 
					 | 
				
			||||||
version: '3.7'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
services:
 | 
					 | 
				
			||||||
  postgresql:
 | 
					 | 
				
			||||||
    container_name: postgres
 | 
					 | 
				
			||||||
    image: postgres:11
 | 
					 | 
				
			||||||
    volumes:
 | 
					 | 
				
			||||||
    - db-data:/var/lib/postgresql/data
 | 
					 | 
				
			||||||
    ports:
 | 
					 | 
				
			||||||
    - 127.0.0.1:5432:5432
 | 
					 | 
				
			||||||
    restart: always
 | 
					 | 
				
			||||||
  redis:
 | 
					 | 
				
			||||||
    container_name: redis
 | 
					 | 
				
			||||||
    image: redis
 | 
					 | 
				
			||||||
    ports:
 | 
					 | 
				
			||||||
    - 127.0.0.1:6379:6379
 | 
					 | 
				
			||||||
    restart: always
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
volumes:
 | 
					 | 
				
			||||||
  db-data:
 | 
					 | 
				
			||||||
    driver: local
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
To tell passbook about these databases, create a file in the project root called `local.env.yml` with the following contents:
 | 
					To tell passbook about these databases, create a file in the project root called `local.env.yml` with the following contents:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -57,7 +57,7 @@ stages:
 | 
				
			|||||||
                pipenv install --dev prospector --skip-lock
 | 
					                pipenv install --dev prospector --skip-lock
 | 
				
			||||||
          - task: CmdLine@2
 | 
					          - task: CmdLine@2
 | 
				
			||||||
            inputs:
 | 
					            inputs:
 | 
				
			||||||
              script: pipenv run prospector --check passbook
 | 
					              script: pipenv run prospector passbook
 | 
				
			||||||
      - job: bandit
 | 
					      - job: bandit
 | 
				
			||||||
        pool:
 | 
					        pool:
 | 
				
			||||||
          vmImage: 'ubuntu-latest'
 | 
					          vmImage: 'ubuntu-latest'
 | 
				
			||||||
@ -92,3 +92,53 @@ stages:
 | 
				
			|||||||
          - task: CmdLine@2
 | 
					          - task: CmdLine@2
 | 
				
			||||||
            inputs:
 | 
					            inputs:
 | 
				
			||||||
              script: pipenv run pyright
 | 
					              script: pipenv run pyright
 | 
				
			||||||
 | 
					  - stage: Test
 | 
				
			||||||
 | 
					    jobs:
 | 
				
			||||||
 | 
					      - job: migrations
 | 
				
			||||||
 | 
					        pool:
 | 
				
			||||||
 | 
					          vmImage: 'ubuntu-latest'
 | 
				
			||||||
 | 
					        steps:
 | 
				
			||||||
 | 
					          - task: UsePythonVersion@0
 | 
				
			||||||
 | 
					            inputs:
 | 
				
			||||||
 | 
					              versionSpec: '3.8'
 | 
				
			||||||
 | 
					          - task: DockerCompose@0
 | 
				
			||||||
 | 
					            displayName: Run services
 | 
				
			||||||
 | 
					            inputs:
 | 
				
			||||||
 | 
					              dockerComposeFile: 'scripts/docker-compose.yml'
 | 
				
			||||||
 | 
					              action: 'Run services'
 | 
				
			||||||
 | 
					              buildImages: false
 | 
				
			||||||
 | 
					          - task: CmdLine@2
 | 
				
			||||||
 | 
					            inputs:
 | 
				
			||||||
 | 
					              script: |
 | 
				
			||||||
 | 
					                sudo pip install -U wheel pipenv
 | 
				
			||||||
 | 
					                pipenv install --dev
 | 
				
			||||||
 | 
					          - task: CmdLine@2
 | 
				
			||||||
 | 
					            inputs:
 | 
				
			||||||
 | 
					              script: pipenv run ./manage.py migrate
 | 
				
			||||||
 | 
					      - job: coverage
 | 
				
			||||||
 | 
					        pool:
 | 
				
			||||||
 | 
					          vmImage: 'ubuntu-latest'
 | 
				
			||||||
 | 
					        steps:
 | 
				
			||||||
 | 
					          - task: UsePythonVersion@0
 | 
				
			||||||
 | 
					            inputs:
 | 
				
			||||||
 | 
					              versionSpec: '3.8'
 | 
				
			||||||
 | 
					          - task: DockerCompose@0
 | 
				
			||||||
 | 
					            displayName: Run services
 | 
				
			||||||
 | 
					            inputs:
 | 
				
			||||||
 | 
					              dockerComposeFile: 'scripts/docker-compose.yml'
 | 
				
			||||||
 | 
					              action: 'Run services'
 | 
				
			||||||
 | 
					              buildImages: false
 | 
				
			||||||
 | 
					          - task: CmdLine@2
 | 
				
			||||||
 | 
					            inputs:
 | 
				
			||||||
 | 
					              script: |
 | 
				
			||||||
 | 
					                sudo pip install -U wheel pipenv
 | 
				
			||||||
 | 
					                pipenv install --dev
 | 
				
			||||||
 | 
					          - task: CmdLine@2
 | 
				
			||||||
 | 
					            inputs:
 | 
				
			||||||
 | 
					              script: pipenv run ./scripts/coverage.sh
 | 
				
			||||||
 | 
					          - task: CmdLine@2
 | 
				
			||||||
 | 
					            inputs:
 | 
				
			||||||
 | 
					              script: pipenv run coverage xml
 | 
				
			||||||
 | 
					          - task: CmdLine@2
 | 
				
			||||||
 | 
					            inputs:
 | 
				
			||||||
 | 
					              script: bash <(curl -s https://codecov.io/bash)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										25
									
								
								scripts/docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								scripts/docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					version: '3.7'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					services:
 | 
				
			||||||
 | 
					  postgresql:
 | 
				
			||||||
 | 
					    container_name: postgres
 | 
				
			||||||
 | 
					    image: postgres:11
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					    - db-data:/var/lib/postgresql/data
 | 
				
			||||||
 | 
					    environment:
 | 
				
			||||||
 | 
					      POSTGRES_DB: passbook
 | 
				
			||||||
 | 
					      POSTGRES_USER: passbook
 | 
				
			||||||
 | 
					      POSTGRES_PASSWORD: "EK-5jnKfjrGRm<77"
 | 
				
			||||||
 | 
					    ports:
 | 
				
			||||||
 | 
					    - 5432:5432
 | 
				
			||||||
 | 
					    restart: always
 | 
				
			||||||
 | 
					  redis:
 | 
				
			||||||
 | 
					    container_name: redis
 | 
				
			||||||
 | 
					    image: redis
 | 
				
			||||||
 | 
					    ports:
 | 
				
			||||||
 | 
					    - 6379:6379
 | 
				
			||||||
 | 
					    restart: always
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					volumes:
 | 
				
			||||||
 | 
					  db-data:
 | 
				
			||||||
 | 
					    driver: local
 | 
				
			||||||
		Reference in New Issue
	
	Block a user