Skip to content

Commit fc07122

Browse files
authored
Add test framework and test in CI (#34)
1 parent cbeee33 commit fc07122

File tree

14 files changed

+173
-8
lines changed

14 files changed

+173
-8
lines changed

.github/workflows/ci.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
strategy:
6+
matrix:
7+
include:
8+
- name: Tests
9+
command: bin/tests
10+
- name: Lint
11+
command: bin/lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@v3
16+
- uses: actions/setup-python@v4
17+
with:
18+
python-version-file: '.python-version'
19+
cache: 'pip'
20+
cache-dependency-path: |
21+
requirements.txt
22+
requirements/*.txt
23+
- name: Install Python dependencies
24+
run: |
25+
pip install -U pip setuptools wheel
26+
pip install -r requirements.txt --no-deps
27+
pip install -r requirements/dev.txt
28+
- name: Run ${{ matrix.name }}
29+
run: ${{ matrix.command }}

.github/workflows/deploy.yml

-7
This file was deleted.

.python-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10.4

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ FROM python:3.10-slim
55
# Allow statements and log messages to immediately appear in the logs
66
ENV PYTHONUNBUFFERED True
77

8+
# Put our application on the PYTHONPATH
9+
ENV PYTHONPATH /app
10+
811
# Define whether we're building a production or a development image. This will
912
# generally be used to control whether or not we install our development and
1013
# test dependencies.

Makefile

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,12 @@ reformat:
2525
docker-compose run --rm web isort -rc inspector #migrations
2626
docker-compose run --rm web black inspector #migrations
2727

28+
tests: .state/docker-build
29+
docker-compose run --rm web bin/tests $(T) $(TESTARGS)
2830

29-
.PHONY: default serve #initdb
31+
32+
lint: .state/docker-build
33+
docker-compose run --rm web bin/lint $(T) $(TESTARGS)
34+
35+
36+
.PHONY: default serve tests lint #initdb

bin/lint

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Print all the following commands
5+
set -x
6+
7+
# Actually run our tests.
8+
python -m flake8 .
9+
python -m black --check *.py inspector/ tests/
10+
python -m isort --check *.py inspector/ tests/
11+
python -m doc8 --allow-long-titles README.rst CONTRIBUTING.rst docs/ --ignore-path docs/_build/
12+
python -m curlylint ./inspector/templates
13+
python -m mypy -p inspector

bin/tests

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
COMMAND_ARGS="$@"
5+
6+
# Print all the following commands
7+
set -x
8+
9+
# Actually run our tests.
10+
python -m pytest $COMMAND_ARGS

inspector/__init__.py

Whitespace-only changes.

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# This is just for Dependabot
22
-r requirements/main.txt
33
-r requirements/deploy.txt
4+
-r requirements/lint.txt
5+
-r requirements/tests.txt

requirements/dev.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
black
22
isort
3+
pretend
4+
pytest

requirements/lint.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env -S pip-compile --allow-unsafe --generate-hashes --output-file=requirements/lint.txt
2+
3+
black
4+
isort

requirements/lint.txt

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# This file is autogenerated by pip-compile with python 3.10
3+
# To update, run:
4+
#
5+
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements/lint.txt ./requirements/lint.in
6+
#
7+
black==22.6.0 \
8+
--hash=sha256:074458dc2f6e0d3dab7928d4417bb6957bb834434516f21514138437accdbe90 \
9+
--hash=sha256:187d96c5e713f441a5829e77120c269b6514418f4513a390b0499b0987f2ff1c \
10+
--hash=sha256:2ea29072e954a4d55a2ff58971b83365eba5d3d357352a07a7a4df0d95f51c78 \
11+
--hash=sha256:4af5bc0e1f96be5ae9bd7aaec219c901a94d6caa2484c21983d043371c733fc4 \
12+
--hash=sha256:560558527e52ce8afba936fcce93a7411ab40c7d5fe8c2463e279e843c0328ee \
13+
--hash=sha256:568ac3c465b1c8b34b61cd7a4e349e93f91abf0f9371eda1cf87194663ab684e \
14+
--hash=sha256:6797f58943fceb1c461fb572edbe828d811e719c24e03375fd25170ada53825e \
15+
--hash=sha256:6c1734ab264b8f7929cef8ae5f900b85d579e6cbfde09d7387da8f04771b51c6 \
16+
--hash=sha256:6c6d39e28aed379aec40da1c65434c77d75e65bb59a1e1c283de545fb4e7c6c9 \
17+
--hash=sha256:7ba9be198ecca5031cd78745780d65a3f75a34b2ff9be5837045dce55db83d1c \
18+
--hash=sha256:94783f636bca89f11eb5d50437e8e17fbc6a929a628d82304c80fa9cd945f256 \
19+
--hash=sha256:a218d7e5856f91d20f04e931b6f16d15356db1c846ee55f01bac297a705ca24f \
20+
--hash=sha256:a3db5b6409b96d9bd543323b23ef32a1a2b06416d525d27e0f67e74f1446c8f2 \
21+
--hash=sha256:ac609cf8ef5e7115ddd07d85d988d074ed00e10fbc3445aee393e70164a2219c \
22+
--hash=sha256:b154e6bbde1e79ea3260c4b40c0b7b3109ffcdf7bc4ebf8859169a6af72cd70b \
23+
--hash=sha256:b270a168d69edb8b7ed32c193ef10fd27844e5c60852039599f9184460ce0807 \
24+
--hash=sha256:b9fd45787ba8aa3f5e0a0a98920c1012c884622c6c920dbe98dbd05bc7c70fbf \
25+
--hash=sha256:c85928b9d5f83b23cee7d0efcb310172412fbf7cb9d9ce963bd67fd141781def \
26+
--hash=sha256:c9a3ac16efe9ec7d7381ddebcc022119794872abce99475345c5a61aa18c45ad \
27+
--hash=sha256:cfaf3895a9634e882bf9d2363fed5af8888802d670f58b279b0bece00e9a872d \
28+
--hash=sha256:e439798f819d49ba1c0bd9664427a05aab79bfba777a6db94fd4e56fae0cb849 \
29+
--hash=sha256:f586c26118bc6e714ec58c09df0157fe2d9ee195c764f630eb0d8e7ccce72e69 \
30+
--hash=sha256:f6fe02afde060bbeef044af7996f335fbe90b039ccf3f5eb8f16df8b20f77666
31+
# via -r ./requirements/lint.in
32+
click==8.1.3 \
33+
--hash=sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e \
34+
--hash=sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48
35+
# via black
36+
isort==5.10.1 \
37+
--hash=sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7 \
38+
--hash=sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951
39+
# via -r ./requirements/lint.in
40+
mypy-extensions==0.4.3 \
41+
--hash=sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d \
42+
--hash=sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8
43+
# via black
44+
pathspec==0.9.0 \
45+
--hash=sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a \
46+
--hash=sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1
47+
# via black
48+
platformdirs==2.5.2 \
49+
--hash=sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788 \
50+
--hash=sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19
51+
# via black
52+
tomli==2.0.1 \
53+
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
54+
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
55+
# via black

requirements/tests.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env -S pip-compile --allow-unsafe --generate-hashes --output-file=requirements/tests.txt
2+
3+
pretend
4+
pytest

requirements/tests.txt

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# This file is autogenerated by pip-compile with python 3.10
3+
# To update, run:
4+
#
5+
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements/tests.txt ./requirements/tests.in
6+
#
7+
attrs==21.4.0 \
8+
--hash=sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4 \
9+
--hash=sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd
10+
# via pytest
11+
iniconfig==1.1.1 \
12+
--hash=sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3 \
13+
--hash=sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32
14+
# via pytest
15+
packaging==21.3 \
16+
--hash=sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb \
17+
--hash=sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522
18+
# via pytest
19+
pluggy==1.0.0 \
20+
--hash=sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159 \
21+
--hash=sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3
22+
# via pytest
23+
pretend==1.0.9 \
24+
--hash=sha256:c90eb810cde8ebb06dafcb8796f9a95228ce796531bc806e794c2f4649aa1b10 \
25+
--hash=sha256:e389b12b7073604be67845dbe32bf8297360ad9a609b24846fe15d86e0b7dc01
26+
# via -r ./requirements/tests.in
27+
py==1.11.0 \
28+
--hash=sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719 \
29+
--hash=sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378
30+
# via pytest
31+
pyparsing==3.0.9 \
32+
--hash=sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb \
33+
--hash=sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc
34+
# via packaging
35+
pytest==7.1.2 \
36+
--hash=sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c \
37+
--hash=sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45
38+
# via -r ./requirements/tests.in
39+
tomli==2.0.1 \
40+
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
41+
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
42+
# via pytest

0 commit comments

Comments
 (0)