Moving tests from travis to github actions.

This commit is contained in:
Dan 2022-06-20 13:20:55 -04:00
parent a202148880
commit 952b5b48fc
3 changed files with 52 additions and 40 deletions

View File

@ -2,14 +2,64 @@ name: Create and publish a Docker image
on:
push:
branches: ['master']
branches: ['main', 'chore/*', 'feature/*', 'bug/*']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
sonarcloud:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
with:
args: >
-Dsonar.organization=sartography
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run_tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
- uses: actions/setup-python@v3
with:
python-version: '3.9'
architecture: 'x64'
- run: psql -h localhost -c 'create database pb_test;' -U postgres
- run: pip install pipenv
- run: pipenv install --dev
- run: pipenv run coverage run -m pytest
- run: pipenv run coverage xml -i
build-and-push-image:
needs:
- run_tests
- sonarcloud
runs-on: ubuntu-latest
permissions:
contents: read

View File

@ -1,38 +0,0 @@
language: python
python:
- "3.8"
services:
- postgresql
- docker
addons:
chrome: stable
sonarcloud:
organization: "sartography"
before_install:
- psql -c 'create database pb_test;' -U postgres
install:
- pipenv install --dev
env:
global:
- TESTING=true
- SQLALCHEMY_DATABASE_URI="postgresql://postgres:@localhost:5432/pb_test"
script:
- pipenv run coverage run -m pytest
- pipenv run coverage xml -i
after_success:
- sonar-scanner
notifications:
email:
on_success: change
on_failure: always
recipients:
- dan@sartography.com

View File

@ -17,7 +17,7 @@ APPLICATION_ROOT = re.sub(r'//', '/', '/%s/' % environ.get('APPLICATION_ROOT', d
DB_HOST = environ.get('DB_HOST', default="localhost")
DB_PORT = environ.get('DB_PORT', default="5432")
DB_NAME = environ.get('DB_NAME', default="pb")
DB_NAME = environ.get('DB_NAME', default="pb2")
DB_USER = environ.get('DB_USER', default="crc_user")
DB_PASSWORD = environ.get('DB_PASSWORD', default="crc_pass")
SQLALCHEMY_DATABASE_URI = environ.get(