Skip to content

Commit 67d8552

Browse files
committed
Make upstream tests use makefile
Refactor upstream tests to use makefile and standard installation procedure. Also, it explicitly makes sure python version we test is 3.8.11 Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
1 parent 34c83a7 commit 67d8552

2 files changed

Lines changed: 17 additions & 31 deletions

File tree

.github/workflows/upstream_test.yml

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,26 @@ jobs:
88
unit_tests:
99
runs-on: ubuntu-latest
1010

11-
services:
12-
# Label used to access the service container
13-
postgres:
14-
image: postgres
15-
env:
16-
POSTGRES_PASSWORD: vulnerablecode
17-
POSTGRES_DB: vulnerablecode
18-
# Set health checks to wait until postgres has started
19-
options: >-
20-
--health-cmd pg_isready
21-
--health-interval 10s
22-
--health-timeout 5s
23-
--health-retries 5
24-
ports:
25-
# Maps tcp port 5432 on service container to the host
26-
- 5432:5432
2711
steps:
28-
- name: Check out repository code
12+
- name: Checkout code
2913
uses: actions/checkout@v2
3014

31-
- name: Set up Python 3.8
15+
- name: Set up Python 3.8.11
3216
uses: actions/setup-python@v2
3317
with:
34-
python-version: 3.8
18+
python-version: 3.8.11
3519

3620
- name: Install dependencies
3721
run: |
38-
sudo apt install python3-dev postgresql libpq-dev build-essential libxml2-dev libxslt1-dev
39-
python -m pip install --upgrade pip
40-
pip install -r requirements.txt -r requirements-dev.txt
41-
pip install pytest-xdist
42-
43-
- name: Run tests
22+
sudo apt-get install -y postgresql python3-dev libpq-dev build-essential
23+
make dev envfile
24+
25+
- name: Setup database
4426
run: |
45-
python -m pytest -v vulnerabilities/tests/test_upstream.py -n 2
27+
sudo systemctl start postgresql
28+
make postgres
29+
30+
- name: Run upstream tests
31+
run: make webtest
4632
env:
47-
# The hostname, username used to communicate with the PostgreSQL service container
48-
POSTGRES_HOST: localhost
49-
VC_DB_USER: postgres
50-
POSTGRES_PORT: 5432
5133
GH_TOKEN: 1

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ run:
9999
${ACTIVATE} ./manage.py runserver
100100

101101
test:
102-
@echo "-> Run the test suite"
102+
@echo "-> Run offline tests"
103103
${ACTIVATE} ${PYTHON_EXE} -m pytest -v -m "not webtest"
104104

105+
webtest:
106+
@echo "-> Run web tests"
107+
${ACTIVATE} ${PYTHON_EXE} -m pytest -v -m "webtest"
108+
105109
package: conf
106110
@echo "-> Create a VulnerableCode package for offline installation"
107111
@echo "-> Fetch dependencies in thirdparty/ for offline installation"

0 commit comments

Comments
 (0)