Skip to content

Commit

Permalink
Merge pull request #528 from rcpch/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
eatyourpeas authored Jul 18, 2023
2 parents c3ade85 + 1193e5d commit d625196
Show file tree
Hide file tree
Showing 273 changed files with 23,512 additions and 4,735 deletions.
50 changes: 42 additions & 8 deletions .github/workflows/autodeploy-to-azure-epilepsy12-development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,70 @@ on:
jobs:
build-and-deploy:
runs-on: ubuntu-latest

# this 'environment' refers to GitHub Environments, not environment variables
environment:
name: 'development'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

# this 'env' refers to environment variables
env:
DJANGO_CSRF_TRUSTED_ORIGINS: https://localhost,https://0.0.0.0
E12_POSTGRES_DB_HOST: 127.0.0.1
E12_POSTGRES_DB_NAME: test_db
E12_POSTGRES_DB_PASSWORD: postgis
E12_POSTGRES_DB_PORT: 5432
E12_POSTGRES_DB_USER: postgis
POSTCODES_IO_API_URL: https://api.postcodes.io
RCPCH_CENSUS_PLATFORM_TOKEN: ${{ secrets.RCPCH_CENSUS_PLATFORM_TOKEN }}
RCPCH_CENSUS_PLATFORM_URL: https://api.rcpch.ac.uk/deprivation/v1
RCPCH_HERMES_SERVER_URL: http://rcpch-hermes.uksouth.azurecontainer.io:8080/v1/snomed

# Sets up a Postgis container for the test db
services:
postgis:
image: postgis/postgis:15-3.3
env:
POSTGRES_USER: postgis
POSTGRES_PASSWORD: postgis
POSTGRES_DB: test_db
ports:
- 5432:5432
# needed because the postgis container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v3

- name: List all files
run: ls -al


- name: Set up Python version
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install PostGIS dependencies
run: sudo apt-get install -y binutils libproj-dev gdal-bin libgdal-dev python3-gdal

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
# python dependencies
- name: Install dependencies
run: pip install -r requirements.txt

run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# run migrations
- name: Run migrations
run: python manage.py migrate

- name: collect static files
run: python manage.py collectstatic --noinput

- name: Pytest Suite
run: pytest -rP

# Deploy to Azure
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
Expand Down
68 changes: 45 additions & 23 deletions .github/workflows/autodeploy-to-azure-epilepsy12-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,77 @@ on:
workflow_dispatch:

jobs:
build:
build-and-deploy:
runs-on: ubuntu-latest

# this 'environment' refers to GitHub Environments, not environment variables
environment:
name: 'staging'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

# this 'env' refers to environment variables
env:
DJANGO_CSRF_TRUSTED_ORIGINS: https://localhost,https://0.0.0.0
E12_POSTGRES_DB_HOST: 127.0.0.1
E12_POSTGRES_DB_NAME: test_db
E12_POSTGRES_DB_PASSWORD: postgis
E12_POSTGRES_DB_PORT: 5432
E12_POSTGRES_DB_USER: postgis
POSTCODES_IO_API_URL: https://api.postcodes.io
RCPCH_CENSUS_PLATFORM_TOKEN: ${{ secrets.RCPCH_CENSUS_PLATFORM_TOKEN }}
RCPCH_CENSUS_PLATFORM_URL: https://api.rcpch.ac.uk/deprivation/v1
RCPCH_HERMES_SERVER_URL: http://rcpch-hermes.uksouth.azurecontainer.io:8080/v1/snomed

# Sets up a Postgis container for the test db
services:
postgis:
image: postgis/postgis:15-3.3
env:
POSTGRES_USER: postgis
POSTGRES_PASSWORD: postgis
POSTGRES_DB: test_db
ports:
- 5432:5432
# needed because the postgis container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v3

- name: Set up Python version
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install PostGIS dependencies
run: sudo apt-get install -y binutils libproj-dev gdal-bin libgdal-dev python3-gdal

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
# python dependencies
- name: Install dependencies
run: pip install -r requirements.txt

run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: collect static files
run: python manage.py collectstatic --noinput

# Optional: Add step to run tests here (PyTest, Django test suites, etc.)


- name: Pytest Suite
run: pytest -rP

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v3
with:
name: python-app
path: |
.
.
!venv/
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'staging'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: python-app
path: .

# Deploy to Azure
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/test-workflow-temp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Temp workflow to test Pytest Suite

on:
push:
branches:
- "add-cicd-auto-pytest"
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest

# this 'env' refers to environment variables
env:
DJANGO_CSRF_TRUSTED_ORIGINS: https://localhost,https://0.0.0.0
E12_POSTGRES_DB_HOST: 127.0.0.1
E12_POSTGRES_DB_NAME: test_db
E12_POSTGRES_DB_PASSWORD: postgis
E12_POSTGRES_DB_PORT: 5432
E12_POSTGRES_DB_USER: postgis
POSTCODES_IO_API_URL: https://api.postcodes.io
RCPCH_CENSUS_PLATFORM_TOKEN: ${{ secrets.RCPCH_CENSUS_PLATFORM_TOKEN }}
RCPCH_CENSUS_PLATFORM_URL: https://api.rcpch.ac.uk/deprivation/v1
RCPCH_HERMES_SERVER_URL: http://rcpch-hermes.uksouth.azurecontainer.io:8080/v1/snomed

# this 'environment' refers to GitHub Environments, not environment variables
environment:
name: "development"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

services:
postgis:
image: postgis/postgis:15-3.3
env:
POSTGRES_USER: postgis
POSTGRES_PASSWORD: postgis
POSTGRES_DB: test_db
ports:
- 5432:5432
# needed because the postgis container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v3

- name: List all files
run: ls -al

- name: Set up Python version
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install PostGIS dependencies
run: sudo apt-get install -y binutils libproj-dev gdal-bin libgdal-dev python3-gdal

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
# python dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# run migrations
- name: Run migrations
run: python manage.py migrate

- name: collect static files
run: python manage.py collectstatic --noinput

# Run Pytest Suite
- name: print settings for debugging purposes
run: python manage.py diffsettings --all

- name: Pytest Suite
run: pytest -rP
6 changes: 3 additions & 3 deletions docker-compose.dev-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
- DEBUG=True
- DJANGO_ALLOWED_HOSTS=0.0.0.0
- DJANGO_CSRF_TRUSTED_ORIGINS=https://localhost,https://0.0.0.0
- POSTCODES_IO_API_URL=https://api.postcodes.io/postcodes
- POSTCODES_IO_API_URL=https://api.postcodes.io
- RCPCH_CENSUS_PLATFORM_URL=https://api.rcpch.ac.uk/deprivation/v1 # live
# - RCPCH_CENSUS_PLATFORM_URL=http://0.0.0.0:8001 # development
- RCPCH_HERMES_SERVER_URL=http://rcpch-hermes.uksouth.azurecontainer.io:8080/v1/snomed
Expand All @@ -43,15 +43,15 @@ services:
command: >
sh -c "python manage.py collectstatic --noinput &&
python manage.py migrate &&
python manage.py seed --mode=seed_dummy_cases &&
python manage.py seed --mode=cases --cases 100 &&
python manage.py seed --mode=seed_registrations &&
python manage.py seed --mode=seed_groups_and_permissions &&
python manage.py createsuperuser --noinput &&
echo 'DEV SETUP SCRIPT: Development superuser email: [email protected]' &&
echo 'DEV SETUP SCRIPT: Development superuser password: pw' &&
python manage.py runserver 0.0.0.0:8000"
# db container - runs postgres
# db container - runs postgis
db:
image: postgis/postgis:15-3.3
volumes:
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ services:
# ensures that docker compose always displays log output
tty: true
stdin_open: true
env_file:
- .env # env file with the token for RCPCH Census Platform, not committed to Git

# db container - runs postgres
db:
Expand Down
Loading

0 comments on commit d625196

Please sign in to comment.