Skip to content

chore: Deploy to k8s #174

chore: Deploy to k8s

chore: Deploy to k8s #174

name: Backend - Pull Request checks
on:
pull_request:
types: [ opened, synchronize, reopened ]
branches:
- main
paths:
- backend/**
push:
branches:
- main
paths:
- backend/**
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-test.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-test.txt
- name: Run tests
env:
DJANGO_SETTINGS_MODULE: app.settings.test
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
run: |
coverage run ./manage.py test
coverage xml
- name: Save coverage report
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: backend/coverage.xml
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-test.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-test.txt
- name: Run linter
run: |
echo "Running flake8"
# black --check .
# flake8
sonarcloud:
runs-on: ubuntu-latest
needs: [ test, lint ]
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- uses: actions/download-artifact@v2
name: Download coverage report
with:
name: coverage-report
path: backend/
- name: Fix coverage
run: |
sed -i -e 's/app</backend\/app</g' coverage.xml
- uses: sonarsource/sonarcloud-github-action@master
name: SonarCloud Scan
with:
projectBaseDir: backend
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }}