aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar scragly <[email protected]>2019-09-21 15:34:00 +1000
committerGravatar GitHub <[email protected]>2019-09-21 15:34:00 +1000
commit8de91c4fff4a0e84bea9b6543a78231cd5afe85f (patch)
treec3a80f71c6ebac2f153cce4853b6c56c3e113a86
parentRevert uwsgi back to pip install. (#254) (diff)
parentChange CI DB setup to use docker. (diff)
CI Job Merge (#255)
CI Job Merge Co-authored-by: null <[email protected]>
-rw-r--r--.coveragerc1
-rw-r--r--Pipfile5
-rw-r--r--azure-pipelines.yml167
-rw-r--r--docker-compose.yml4
4 files changed, 83 insertions, 94 deletions
diff --git a/.coveragerc b/.coveragerc
index 68f8305a..a49af74e 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -8,6 +8,7 @@ source =
pydis_site/apps/staff
pydis_site/apps/wiki
omit =
+ */migrations/*
*/admin.py
*/apps.py
*/urls.py
diff --git a/Pipfile b/Pipfile
index 897d1b08..6da62a2b 100644
--- a/Pipfile
+++ b/Pipfile
@@ -40,6 +40,7 @@ python_version = "3.7"
[scripts]
makemigrations = "python manage.py makemigrations"
django_shell = "python manage.py shell"
-test = "python manage.py test"
-lint = "flake8 pydis_site"
+test = "coverage run manage.py test"
+report = "coverage report -m"
+lint = "flake8"
precommit = "pre-commit install"
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 450e005b..b3d4e6da 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -1,93 +1,80 @@
# https://aka.ms/yaml
jobs:
-- job: python_lint
- displayName: 'Lint Job'
- pool:
- vmImage: ubuntu-16.04
-
- variables:
- PIP_CACHE_DIR: .cache/pip
-
- steps:
- - task: UsePythonVersion@0
- displayName: 'Set Python Version'
- inputs:
- versionSpec: '3.7.x'
- addToPath: true
-
- - script: python3 -m pip install pipenv && pipenv install --dev --system && python3 -m pip install flake8-formatter-junit-xml
- displayName: 'Install Project Environment'
-
- - script: python3 -m flake8 --format junit-xml --output-file test-lint.xml
- displayName: 'Run Linter'
-
- - task: PublishTestResults@2
- condition: succeededOrFailed()
- inputs:
- testResultsFiles: '**/test-*.xml'
- testRunTitle: 'Site-Django Lint Results'
-
-- job: coverage_test
- displayName: 'Test Job'
- dependsOn: python_lint
- pool:
- vmImage: ubuntu-16.04
-
- steps:
- - task: UsePythonVersion@0
- inputs:
- versionSpec: '3.7.x'
- architecture: x64
-
- - script: |
- curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
- sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
- sudo apt-get update -y
- sudo apt-get install -y postgresql-11
- displayName: 'Install PostgreSQL'
-
- - script: |
- echo "$USER_CREATE_COMMAND;" > pgscript.sql
- echo "CREATE DATABASE pysite OWNER pysite;" >> pgscript.sql
- sudo su postgres -c "psql < pgscript.sql"
- env:
- USER_CREATE_COMMAND: CREATE USER pysite WITH PASSWORD 'pysite' CREATEDB
- displayName: 'Setup Database'
-
- - script: python3 -m pip install pipenv && pipenv install --dev --system
- displayName: 'Install Project Environment'
-
- - script: |
- python manage.py makemigrations --check
- python manage.py migrate
- coverage run --branch manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input
- env:
- CI: azure
- DATABASE_URL: postgres://pysite:pysite@localhost/pysite
- displayName: 'Run Test'
-
- - script: coverage report
- displayName: 'Show Coverage Results'
-
- - task: PublishTestResults@2
- inputs:
- testResultsFiles: "**/TEST-*.xml"
- testRunTitle: 'Site-Django Test Results'
-
-- job: build
- displayName: 'Build & Push Container'
- dependsOn: coverage_test
- condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
-
- steps:
- - task: Docker@2
- displayName: 'Build & Push Container'
-
- inputs:
- containerRegistry: 'DockerHubV2'
- repository: 'pythondiscord/site'
- command: 'buildAndPush'
- Dockerfile: 'docker/app/Dockerfile'
- buildContext: '.'
- tags: 'latest'
+ - job: test
+ displayName: 'Test & Lint'
+ pool:
+ vmImage: ubuntu-16.04
+
+ variables:
+ PIP_CACHE_DIR: .cache/pip
+
+ steps:
+ - task: UsePythonVersion@0
+ displayName: 'Set Python Version'
+ inputs:
+ versionSpec: '3.7.x'
+ addToPath: true
+
+ - task: DockerCompose@0
+ displayName: 'Setup Database'
+ inputs:
+ action: Run a specific service
+ dockerComposeFile: docker-compose.yml
+ projectName: pydis_web
+ serviceName: postgres
+ ports: '7777:5432'
+
+ - script: |
+ pip install pipenv
+ pipenv install --dev --system
+ pip install flake8-formatter-junit-xml
+ displayName: 'Install Project Environment'
+
+ - script: flake8 --format junit-xml --output-file TEST-lint.xml
+ displayName: 'Run Linter'
+
+ - script: |
+ python3 manage.py makemigrations --check
+ python3 manage.py migrate
+ coverage run \
+ manage.py test \
+ --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner \
+ --no-input
+ env:
+ CI: azure
+ DATABASE_URL: postgres://pysite:pysite@localhost:7777/pysite
+ displayName: 'Run Tests'
+
+ - script: coverage report -m && coverage xml
+ displayName: 'Generate Coverage Reports'
+
+ - task: PublishTestResults@2
+ condition: succeededOrFailed()
+ displayName: 'Publish Test & Linting Results'
+ inputs:
+ testResultsFiles: '**/TEST-*.xml'
+ testRunTitle: 'Site Test Results'
+
+ - task: PublishCodeCoverageResults@1
+ displayName: 'Publish Coverage Results'
+ condition: succeededOrFailed()
+ inputs:
+ codeCoverageTool: Cobertura
+ summaryFileLocation: '**/coverage.xml'
+
+ - job: build
+ displayName: 'Build & Push Container'
+ dependsOn: test
+ condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
+
+ steps:
+ - task: Docker@2
+ displayName: 'Build & Push Container'
+ inputs:
+ containerRegistry: 'DockerHub'
+ repository: 'pythondiscord/site'
+ command: 'buildAndPush'
+ Dockerfile: 'docker/app/Dockerfile'
+ buildContext: '.'
+ tags: 'latest'
diff --git a/docker-compose.yml b/docker-compose.yml
index 0a8e6bcd..4ea110c4 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -16,7 +16,7 @@ services:
- "127.0.0.1:7777:5432"
environment:
POSTGRES_DB: pysite
- POSTGRES_PASSWORD: supersecretpassword
+ POSTGRES_PASSWORD: pysite
POSTGRES_USER: pysite
web:
@@ -32,7 +32,7 @@ services:
- .:/app:ro
- staticfiles:/var/www/static
environment:
- DATABASE_URL: postgres://pysite:supersecretpassword@postgres:5432/pysite
+ DATABASE_URL: postgres://pysite:pysite@postgres:5432/pysite
DEBUG: "true"
SECRET_KEY: suitable-for-development-only
STATIC_ROOT: /var/www/static