additional messages #176
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- "**" | |
# ignore the event if the only changed file is found in documentation path | |
paths-ignore: | |
- "documentation/**" | |
jobs: | |
build: | |
if: github.ref != 'refs/heads/main' | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_USER: postgres | |
POSTGRES_DB: test_db | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Run backend lint | |
working-directory: ./backend | |
run: npm install && npm run lint | |
- name: Run frontend lint | |
working-directory: ./frontend | |
run: npm install && npm run lint | |
- name: Run backend tests | |
working-directory: ./backend | |
# install dependencies and create the necessary databases before running tests | |
run: npm install && createdb -h localhost -p 5432 -U postgres dev_db && createdb -h localhost -p 5432 -U postgres prod_db && npm test | |
env: | |
DB_HOST: localhost | |
DB_PASS: postgres | |
DB_USER: postgres | |
SECRET_FOR_TOKEN: ${{secrets.SECRET_FOR_TOKEN}} | |
# createdb requires a password that has to be supplied as environment variable | |
PGPASSWORD: postgres | |
NODE_ENV: test | |
HUBSPOT_API_KEY: ${{secrets.HUBSPOT_API_KEY}} | |
- name: Run frontend tests | |
working-directory: ./frontend | |
run: npm install && npm test | |
end-to-end-tests: | |
if: github.ref != 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Build the application stack | |
working-directory: ./end-to-end-tests | |
run: docker-compose up -d | |
- name: Wait for 10 seconds so that server is running and db initialized | |
uses: jakejarvis/wait-action@master | |
with: | |
time: '10s' | |
- name: Install python dependencies | |
working-directory: ./end-to-end-tests | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Check running containers | |
run: docker ps -a | |
- name: Run robot tests | |
working-directory: ./end-to-end-tests | |
run: robot --variable DB_CONFIG_FILE:resources/compose.cfg --variable BROWSER:headlessfirefox --include local tests | |
deploy_to_staging: | |
if: github.ref == 'refs/heads/staging' | |
runs-on: ubuntu-latest | |
needs: [build, end-to-end-tests] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: akhileshns/[email protected] | |
with: | |
heroku_api_key: ${{secrets.HEROKU_API_KEY}} | |
heroku_app_name: ${{secrets.STAGING_HEROKU_APP_NAME}} | |
heroku_email: ${{secrets.PROJECT_EMAIL}} | |
usedocker: true | |
docker_build_args: | | |
API_URL | |
env: | |
API_URL: ${{secrets.STAGING_API_URL}} | |
lighthouse: | |
if: github.ref == 'refs/heads/staging' | |
runs-on: ubuntu-latest | |
needs: deploy_to_staging | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Audit URLs using Lighthouse | |
uses: treosh/lighthouse-ci-action@v8 | |
with: | |
urls: | | |
https://${{secrets.STAGING_URL}} | |
https://${{secrets.STAGING_URL}}/survey/questions/?id=1/ | |
https://${{secrets.STAGING_URL}}/survey/questions/summary/ | |
end-to-end-staging-tests: | |
if: github.ref == 'refs/heads/staging' | |
runs-on: ubuntu-latest | |
needs: deploy_to_staging | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Install python dependencies | |
working-directory: ./end-to-end-tests | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Check running containers | |
run: docker ps -a | |
- name: Run robot tests | |
working-directory: ./end-to-end-tests | |
run: robot --variable SERVER:${{secrets.STAGING_URL}} --variable BROWSER:headlessfirefox --include staging tests | |
# accessibility test | |
deploy_to_production: | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: akhileshns/[email protected] | |
with: | |
heroku_api_key: ${{secrets.HEROKU_API_KEY}} | |
heroku_app_name: ${{secrets.PRODUCTION_HEROKU_APP_NAME}} | |
heroku_email: ${{secrets.PROJECT_EMAIL}} | |
usedocker: true | |
env: | |
SECRET_FOR_TOKEN: ${{secrets.SECRET_FOR_TOKEN}} | |
HUBSPOT_API_KEY: ${{secrets.HUBSPOT_API_KEY}} | |