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

Use postgres instead of sqlite for tests #306

Merged
merged 11 commits into from
Sep 2, 2023
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/docker-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
push: true
context: .
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
Expand All @@ -36,7 +36,7 @@ jobs:
-
name: Build and push release
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
push: true
context: .
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/lint.yml

This file was deleted.

37 changes: 22 additions & 15 deletions .github/workflows/unit_tests.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unit Tests
name: Tests

on:
push:
Expand All @@ -7,14 +7,18 @@ on:
branches: [ master ]

jobs:
container-job:
build:
runs-on: ubuntu-latest

strategy:
matrix:
os: ['ubuntu-latest', 'mac-latest']
python-version: ['3.10', '3.11']
services:
postgres:
image: postgres
image: postgres:12
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: nodejsscan
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand All @@ -25,24 +29,27 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3

with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox
python -m pip install --upgrade pip tox pytest
pip install -r requirements.txt

- name: Run tests
- name: Lint
run: |
tox -e lint

- name: Bandit
run: |
tox -e bandit

- name: Tests
run: |
tox -e py
env:
POSTGRES_HOST: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
POSTGRES_DB: nodejsscan
SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@localhost/nodejsscan

- name: Clean Up
run: |
tox -e clean
tox -e clean
1 change: 0 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def setUp(self):
"""Executed prior to each test."""
app.config['TESTING'] = True
app.config['DEBUG'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///tmp/test.db'
app.app_context().push()
db.create_all()
self.app = app.test_client()
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ envlist = py37, py38
skipsdist = True

[testenv]
# Needs postgres, works only in Github actions
deps =
-rrequirements.txt
pytest
setenv =
SQLALCHEMY_DATABASE_URI = postgresql://postgres:postgres@localhost:5432/nodejsscan
commands =
py.test -vv --cache-clear tests.py

Expand Down