Skip to content

Commit 40170e3

Browse files
authored
Merge pull request #306 from ajinabraham/test_fix
Use postgres instead of sqlite for tests
2 parents 75a60c2 + 5d12157 commit 40170e3

File tree

6 files changed

+35
-68
lines changed

6 files changed

+35
-68
lines changed

.github/workflows/docker-latest.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ jobs:
1111
steps:
1212
-
1313
name: Checkout
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
1515
-
1616
name: Set up QEMU
17-
uses: docker/setup-qemu-action@v1
17+
uses: docker/setup-qemu-action@v2
1818
-
1919
name: Set up Docker Buildx
20-
uses: docker/setup-buildx-action@v1
20+
uses: docker/setup-buildx-action@v2
2121
-
2222
name: Login to DockerHub
23-
uses: docker/login-action@v1
23+
uses: docker/login-action@v2
2424
with:
2525
username: ${{ secrets.DOCKER_USERNAME }}
2626
password: ${{ secrets.DOCKER_TOKEN }}
2727
-
2828
name: Build and push
2929
id: docker_build
30-
uses: docker/build-push-action@v2
30+
uses: docker/build-push-action@v4
3131
with:
3232
push: true
3333
context: .

.github/workflows/docker-release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ jobs:
1010
steps:
1111
-
1212
name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414
-
1515
name: Set up QEMU
16-
uses: docker/setup-qemu-action@v1
16+
uses: docker/setup-qemu-action@v2
1717
-
1818
name: Set up Docker Buildx
19-
uses: docker/setup-buildx-action@v1
19+
uses: docker/setup-buildx-action@v2
2020
-
2121
name: Login to DockerHub
22-
uses: docker/login-action@v1
22+
uses: docker/login-action@v2
2323
with:
2424
username: ${{ secrets.DOCKER_USERNAME }}
2525
password: ${{ secrets.DOCKER_TOKEN }}
@@ -36,7 +36,7 @@ jobs:
3636
-
3737
name: Build and push release
3838
id: docker_build
39-
uses: docker/build-push-action@v2
39+
uses: docker/build-push-action@v4
4040
with:
4141
push: true
4242
context: .

.github/workflows/lint.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Unit Tests
1+
name: Tests
22

33
on:
44
push:
@@ -7,14 +7,18 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
container-job:
10+
build:
1111
runs-on: ubuntu-latest
12-
12+
strategy:
13+
matrix:
14+
os: ['ubuntu-latest', 'mac-latest']
15+
python-version: ['3.10', '3.11']
1316
services:
1417
postgres:
15-
image: postgres
18+
image: postgres:12
1619
env:
1720
POSTGRES_PASSWORD: postgres
21+
POSTGRES_DB: nodejsscan
1822
options: >-
1923
--health-cmd pg_isready
2024
--health-interval 10s
@@ -25,24 +29,27 @@ jobs:
2529

2630
steps:
2731
- uses: actions/checkout@v3
28-
- name: Set up Python3
32+
- name: Set up Python ${{ matrix.python-version }}
2933
uses: actions/setup-python@v3
30-
34+
with:
35+
python-version: ${{ matrix.python-version }}
3136
- name: Install dependencies
3237
run: |
33-
python -m pip install --upgrade pip tox
38+
python -m pip install --upgrade pip tox pytest
3439
pip install -r requirements.txt
3540
36-
- name: Run tests
41+
- name: Lint
42+
run: |
43+
tox -e lint
44+
45+
- name: Bandit
46+
run: |
47+
tox -e bandit
48+
49+
- name: Tests
3750
run: |
3851
tox -e py
39-
env:
40-
POSTGRES_HOST: postgres
41-
POSTGRES_PASSWORD: postgres
42-
POSTGRES_PORT: 5432
43-
POSTGRES_DB: nodejsscan
44-
SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@localhost/nodejsscan
4552
4653
- name: Clean Up
4754
run: |
48-
tox -e clean
55+
tox -e clean

tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def setUp(self):
2929
"""Executed prior to each test."""
3030
app.config['TESTING'] = True
3131
app.config['DEBUG'] = True
32-
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///tmp/test.db'
3332
app.app_context().push()
3433
db.create_all()
3534
self.app = app.test_client()

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ envlist = py37, py38
33
skipsdist = True
44

55
[testenv]
6+
# Needs postgres, works only in Github actions
67
deps =
78
-rrequirements.txt
89
pytest
10+
setenv =
11+
SQLALCHEMY_DATABASE_URI = postgresql://postgres:postgres@localhost:5432/nodejsscan
912
commands =
1013
py.test -vv --cache-clear tests.py
1114

0 commit comments

Comments
 (0)