Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for docker #1746

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: run tests

name: CI Pipeline
on: [push, pull_request]

env:
Expand All @@ -8,6 +7,7 @@ env:
DB_PASSWORD: vulnerablecode

jobs:
# Original test job
build:
runs-on: ubuntu-20.04

Expand Down Expand Up @@ -56,3 +56,38 @@ jobs:
VULNERABLECODE_DB_NAME: ${{ env.DB_NAME }}
VULNERABLECODE_DB_USER: ${{ env.DB_USER }}
VULNERABLECODE_DB_PASSWORD: ${{ env.DB_PASSWORD }}



# New job for Docker-based tests
docker-tests:
runs-on: ubuntu-20.04

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Build Docker Image
run: docker compose build --no-cache

- name: Run Tests in Docker Container
run: |
docker compose up -d
docker compose exec vulnerablecode sh -c "
python3 -m venv venv &&
chmod +x venv &&
. venv/bin/activate &&
pip install -r requirements.txt &&
make test "
env:
GH_TOKEN: 1
POSTGRES_HOST: vulnerablecode-db
POSTGRES_PORT: 5432
VULNERABLECODE_DB_NAME: ${{ env.DB_NAME }}
VULNERABLECODE_DB_USER: ${{ env.DB_USER }}
VULNERABLECODE_DB_PASSWORD: ${{ env.DB_PASSWORD }}

- name: Tear Down Docker Environment
if: always()
run: docker compose down --remove-orphans

3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ coreapi==2.3.3
coreschema==0.0.4
cryptography==43.0.1
crispy-bootstrap4==2024.1
cvss
cwe2==3.0.0
dateparser==1.1.1
decorator==5.1.1
Expand All @@ -30,6 +31,7 @@ distro==1.7.0
Django==4.2.17
django-crispy-forms==2.3
django-environ==0.11.2
django-extensions==3.2.3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this ?

django-filter==24.3
django-widget-tweaks==1.5.0
djangorestframework==3.15.2
Expand All @@ -45,6 +47,7 @@ frozenlist==1.3.0
gitdb==4.0.9
GitPython==3.1.41
gunicorn==23.0.0
htmllistparse
idna==3.3
imagesize==1.3.0
importlib-metadata==4.11.3
Expand Down