Skip to content

Merge branch 'main' of https://github.com/pocolifo/noter-backend #24

Merge branch 'main' of https://github.com/pocolifo/noter-backend

Merge branch 'main' of https://github.com/pocolifo/noter-backend #24

Workflow file for this run

name: Test
on:
push:
paths-ignore: '**.md'
pull_request:
paths-ignore: '**.md'
env:
SQLALCHEMY_URL: postgresql://postgres:postgres@localhost:5432/postgres
jobs:
test:
runs-on: ubuntu-latest
name: Run unit tests
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- 5432:5432
# Wait for Postgres to start
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: '3.10'
- name: Set up project
run: make init
- name: Test
run: make test
sast:
runs-on: ubuntu-latest
name: SAST with Bandit
needs: test
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.10'
- name: Install Bandit
run: pip install bandit
- name: Run Bandit
run: bandit -li -r backend meta admin
dast:
env:
META_SERVER_PORT: 9000
BACKEND_SERVER_PORT: 8000
SQLALCHEMY_URL: postgresql://postgres:postgres@localhost:5432/postgres
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- 5432:5432
# Wait for Postgres to start
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
permissions:
security-events: write
statuses: write
actions: write
checks: read
contents: read
deployments: read
needs: test
runs-on: ubuntu-latest
name: DAST with ZAP API scan
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.10'
- name: Set up project
run: make init
- uses: JarvusInnovations/background-action@v1
name: Run backend in background
with:
run: |
uvicorn backend:app --host 0.0.0.0 --port ${{ env.BACKEND_SERVER_PORT }} --env-file .env --log-config .github/workflows/backend-logger.ini &
uvicorn meta:app --host 0.0.0.0 --port ${{ env.META_SERVER_PORT }} --env-file .env &
wait-on: |
http-get://127.0.0.1:${{ env.BACKEND_SERVER_PORT }}/
http-get://127.0.0.1:${{ env.META_SERVER_PORT }}/access-flags
tail: true # monitor the progress live
wait-for: 1m # timeout 1 minute
log-output: true
log-output-if: true
- name: Run ZAP API DAST Scan
uses: zaproxy/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
docker_name: 'ghcr.io/zaproxy/zaproxy:stable'
format: openapi
target: 'http://127.0.0.1:${{ env.BACKEND_SERVER_PORT }}/openapi.json'
allow_issue_writing: false
- uses: actions/upload-artifact@v3
with:
name: backend-log
path: backend.log