Skip to content

Commit

Permalink
Merge with MIRA / add Svelte frontend
Browse files Browse the repository at this point in the history
Major dev release, with breaking changes.
  • Loading branch information
eric-intuitem committed Feb 11, 2024
1 parent 5c40510 commit 5fde75f
Show file tree
Hide file tree
Showing 2,651 changed files with 52,959 additions and 394,256 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/backend-api-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: API Tests

on:
pull_request:
paths:
- "backend/**"
- ".github/workflows/backend-api-tests.yml"
workflow_dispatch:

env:
GITHUB_WORKFLOW: github_actions

jobs:
test:
runs-on: ubuntu-latest
env:
working-directory: ./backend

strategy:
max-parallel: 4
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
working-directory: ${{env.working-directory}}
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Create environment variables file
working-directory: ${{env.working-directory}}
run: |
touch .env
echo DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }} >> .env
echo DJANGO_DEBUG='True' >> .env
echo DB_HOST=localhost >> .env
echo EMAIL_HOST=localhost >> .env
echo EMAIL_PORT=1025 >> .env
echo EMAIL_HOST_USER='' >> .env
echo EMAIL_HOST_PASSWORD='' >> .env
#echo EMAIL_USE_TLS=False >> .env
echo DEFAULT_FROM_EMAIL='[email protected]' >> .env
echo CISO_ASSISTANT_SUPERUSER_EMAIL='' >> .env
echo CISO_ASSISTANT_URL=http://127.0.0.1:5173 >> .env
- name: Run migrations
working-directory: ${{env.working-directory}}
run: |
export $(grep -v '^#' .env | xargs)
python manage.py migrate
- name: Run API tests
working-directory: ${{env.working-directory}}
run: |
export $(grep -v '^#' .env | xargs)
pytest app_tests/api
79 changes: 79 additions & 0 deletions .github/workflows/backend-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Backend code coverage

on:
pull_request:
branches: ["main"]
paths:
- "backend/**"

env:
GITHUB_WORKFLOW: github_actions

jobs:
build:
runs-on: ubuntu-latest
env:
working-directory: ./backend

services:
postgres:
image: postgres:14.1
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: postgres
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

strategy:
max-parallel: 4
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
working-directory: ${{env.working-directory}}
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Create environment variables file
working-directory: ${{env.working-directory}}
run: |
touch .env
echo DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }} >> .env
echo DJANGO_DEBUG='True' >> .env
echo POSTGRES_NAME=postgres >> .env
echo POSTGRES_USER=postgres >> .env
echo POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} >> .env
echo DB_HOST=localhost >> .env
echo EMAIL_HOST=localhost >> .env
echo EMAIL_PORT=1025 >> .env
echo EMAIL_HOST_USER='' >> .env
echo EMAIL_HOST_PASSWORD='' >> .env
#echo EMAIL_USE_TLS=False >> .env
echo DEFAULT_FROM_EMAIL='[email protected]' >> .env
echo CISO_ASSISTANT_SUPERUSER_EMAIL='' >> .env
echo CISO_ASSISTANT_URL=http://127.0.0.1:5173 >> .env
- name: Run migrations
working-directory: ${{env.working-directory}}
run: |
export $(grep -v '^#' .env | xargs)
python manage.py migrate
- name: Run coverage
working-directory: ${{env.working-directory}}
env:
DATABASE_URL: "postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres"
run: |
export $(grep -v '^#' .env | xargs)
find . -path '*/tests/*' -and -name 'test*.py' -and -not -path "./venv/*" | xargs coverage run -m pytest
- name: Display coverage report
working-directory: ${{env.working-directory}}
env:
DATABASE_URL: "postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres"
run: coverage report
35 changes: 35 additions & 0 deletions .github/workflows/backend-linters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Backend Linters

on:
pull_request:
paths:
- "backend/**"

env:
GITHUB_WORKFLOW: github_actions

jobs:
ruff:
runs-on: ubuntu-latest
env:
working-directory: ./backend

strategy:
max-parallel: 4
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install ruff
working-directory: ${{env.working-directory}}
run: |
python -m pip install ruff
- name: ruff
working-directory: ${{env.working-directory}}
run: ruff check .
40 changes: 40 additions & 0 deletions .github/workflows/frontend-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Frontend code coverage

on:
pull_request:
branches: ["main"]
paths:
- "frontend/**"

env:
GITHUB_WORKFLOW: github_actions

jobs:
build:
runs-on: ubuntu-latest
env:
working-directory: ./frontend

strategy:
max-parallel: 4
matrix:
node-version: ["20"]

steps:
- uses: actions/checkout@v3
- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install latest npm
working-directory: ${{env.working-directory}}
run: |
npm install -g npm &&
npm --version &&
npm list -g --depth 0
- name: Install dependencies
working-directory: ${{env.working-directory}}
run: npm ci
- name: Run coverage
working-directory: ${{env.working-directory}}
run: npm run coverage
43 changes: 43 additions & 0 deletions .github/workflows/frontend-linters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Frontend Linters

on:
pull_request:
paths:
- "frontend/**"

env:
GITHUB_WORKFLOW: github_actions

jobs:
build:
runs-on: ubuntu-latest
env:
working-directory: ./frontend
PUBLIC_BACKEND_API_URL: "http://127.0.0.1:8000/api"

strategy:
max-parallel: 4
matrix:
node-version: ["20"]

steps:
- uses: actions/checkout@v3
- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install latest npm
working-directory: ${{env.working-directory}}
run: |
npm install -g npm &&
npm --version &&
npm list -g --depth 0
- name: Install dependencies
working-directory: ${{env.working-directory}}
run: npm ci
- name: Run prettier check & eslint
working-directory: ${{env.working-directory}}
run: npm run lint
- name: Run svelte-check
working-directory: ${{env.working-directory}}
run: npm run check
39 changes: 39 additions & 0 deletions .github/workflows/frontend-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Unit tests on CISO Assistant frontend

on:
push:
paths:
- "frontend/**"

env:
GITHUB_WORKFLOW: github_actions

jobs:
build:
runs-on: ubuntu-latest
env:
working-directory: ./frontend

strategy:
max-parallel: 4
matrix:
node-version: ["20"]

steps:
- uses: actions/checkout@v3
- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install latest npm
working-directory: ${{env.working-directory}}
run: |
npm install -g npm &&
npm --version &&
npm list -g --depth 0
- name: Install dependencies
working-directory: ${{env.working-directory}}
run: npm ci
- name: Run tests
working-directory: ${{env.working-directory}}
run: npm run test:ci
Loading

0 comments on commit 5fde75f

Please sign in to comment.