Merge pull request #21 from EdinsonRequena/dependabot/pip/sqlparse-0.5.0 #40
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: Django CI | |
on: | |
push: | |
branches: [ develop ] | |
pull_request: | |
branches: [ develop ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:12 | |
env: | |
POSTGRES_DB: test_db_name | |
POSTGRES_USER: test_db_user | |
POSTGRES_PASSWORD: test_db_password | |
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }} | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Install dependencies | |
run: | | |
pip install pipenv | |
pipenv install --dev | |
- name: Run migrations | |
run: | | |
pipenv run python manage.py migrate | |
env: | |
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }} | |
DATABASE_NAME: ${{ secrets.TEST_DATABASE_NAME }} | |
DATABASE_USER: ${{ secrets.TEST_DATABASE_USER }} | |
DATABASE_PASSWORD: ${{ secrets.TEST_DATABASE_PASSWORD }} | |
DATABASE_HOST: ${{ secrets.TEST_DATABASE_HOST }} | |
DATABASE_PORT: ${{ secrets.TEST_DATABASE_PORT }} | |
- name: Run tests | |
run: | | |
pipenv run python manage.py test | |
env: | |
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }} | |
DATABASE_NAME: ${{ secrets.TEST_DATABASE_NAME }} | |
DATABASE_USER: ${{ secrets.TEST_DATABASE_USER }} | |
DATABASE_PASSWORD: ${{ secrets.TEST_DATABASE_PASSWORD }} | |
DATABASE_HOST: ${{ secrets.TEST_DATABASE_HOST }} | |
DATABASE_PORT: ${{ secrets.TEST_DATABASE_PORT }} | |
- name: Install PostgreSQL client | |
run: | | |
sudo apt-get install postgresql-client | |
- name: Check PostgreSQL service | |
run: | | |
pg_isready -h localhost -p 5432 -U test_db_user | |
- name: Run tests with coverage | |
run: | | |
pipenv run coverage run --source='.' manage.py test | |
pipenv run coverage xml -o coverage.xml | |
env: | |
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }} | |
DATABASE_NAME: ${{ secrets.TEST_DATABASE_NAME }} | |
DATABASE_USER: ${{ secrets.TEST_DATABASE_USER }} | |
DATABASE_PASSWORD: ${{ secrets.TEST_DATABASE_PASSWORD }} | |
DATABASE_HOST: ${{ secrets.TEST_DATABASE_HOST }} | |
DATABASE_PORT: ${{ secrets.TEST_DATABASE_PORT }} | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
with: | |
projectBaseDir: . | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }} |