From 1ed7e900f270f243d851eb07765ad1f5ef2b5479 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 28 May 2020 19:29:28 +0200 Subject: [PATCH] ci: migrate unittests and coverage --- README.md | 26 +------------------ azure-pipelines.yml | 52 +++++++++++++++++++++++++++++++++++++- scripts/docker-compose.yml | 25 ++++++++++++++++++ 3 files changed, 77 insertions(+), 26 deletions(-) create mode 100644 scripts/docker-compose.yml diff --git a/README.md b/README.md index 731732beb..a77266825 100644 --- a/README.md +++ b/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. -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: - -```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 -``` +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`. To tell passbook about these databases, create a file in the project root called `local.env.yml` with the following contents: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dc01bfb97..0c5a9a8c4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -57,7 +57,7 @@ stages: pipenv install --dev prospector --skip-lock - task: CmdLine@2 inputs: - script: pipenv run prospector --check passbook + script: pipenv run prospector passbook - job: bandit pool: vmImage: 'ubuntu-latest' @@ -92,3 +92,53 @@ stages: - task: CmdLine@2 inputs: 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) diff --git a/scripts/docker-compose.yml b/scripts/docker-compose.yml new file mode 100644 index 000000000..ed841bce5 --- /dev/null +++ b/scripts/docker-compose.yml @@ -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