Skip to content

Commit 13d083d

Browse files
committed
Add test, lint and format tasks to Makefile.
1 parent 8a73275 commit 13d083d

File tree

10 files changed

+90
-3
lines changed

10 files changed

+90
-3
lines changed

.github/workflows/stage-2-test.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ jobs:
4040
steps:
4141
- name: "Checkout code"
4242
uses: actions/checkout@v4
43+
- name: "Set up Python"
44+
uses: actions/setup-python@v4
45+
with:
46+
python-version: '3.13'
4347
- name: "Run unit test suite"
4448
run: |
4549
make test-unit
@@ -53,6 +57,10 @@ jobs:
5357
steps:
5458
- name: "Checkout code"
5559
uses: actions/checkout@v4
60+
- name: "Set up Python"
61+
uses: actions/setup-python@v4
62+
with:
63+
python-version: '3.13'
5664
- name: "Run linting"
5765
run: |
5866
make test-lint
@@ -67,6 +75,10 @@ jobs:
6775
steps:
6876
- name: "Checkout code"
6977
uses: actions/checkout@v4
78+
- name: "Set up Python"
79+
uses: actions/setup-python@v4
80+
with:
81+
python-version: '3.13'
7082
- name: "Run test coverage check"
7183
run: |
7284
make test-coverage

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
.direnv
1616
node_modules/
17+
openapitools.json
1718
bin/
1819
dist/
1920
build/
@@ -35,5 +36,6 @@ env
3536
poetry.lock
3637
package-lock.json
3738
test-report.xml
39+
.coverage
3840

3941
localstack_data/

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ install: install-node install-python .git/hooks/pre-commit
2222
#Run the npm linting script (specified in package.json). Used to check the syntax and formatting of files.
2323
lint:
2424
npm run lint
25-
find . -name '*.py' -not -path '**/.venv/*' | xargs poetry run flake8
25+
poetry run ruff format . --check
26+
poetry run ruff check .
27+
poetry run pyright
28+
29+
30+
format: ## Format and fix code
31+
poetry run ruff format .
32+
poetry run ruff check . --fix-only
2633

2734
#Creates the fully expanded OAS spec in json
2835
publish: clean
@@ -36,7 +43,8 @@ _dist_include="pytest.ini poetry.lock poetry.toml pyproject.toml Makefile build/
3643
# Example CI/CD targets are: dependencies, build, publish, deploy, clean, etc.
3744

3845
dependencies: # Install dependencies needed to build and test the project @Pipeline
39-
# TODO: Implement installation of your project dependencies
46+
pip install --user pipx
47+
pipx install poetry
4048

4149
build: # Build the project artefact @Pipeline
4250
# TODO: Implement the artefact build step
@@ -51,6 +59,8 @@ config:: # Configure development environment (main) @Configuration
5159
# TODO: Use only 'make' targets that are specific to this project, e.g. you may not need to install Node.js
5260
make _install-dependencies
5361

62+
precommit: lint test ## Pre-commit tasks
63+
5464
# ==============================================================================
5565

5666
${VERBOSE}.SILENT: \

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,20 @@ aiohttp = "^3.7.3"
4040
awscli = "^1.29.29"
4141
awscli-local = "^0.22.0"
4242
pyhamcrest = "^2.1.0"
43+
factory-boy = "^3.3.3"
44+
pyright = "^1.1.394"
45+
46+
[tool.ruff]
47+
line-length = 120
48+
exclude = ["docs/", "scripts/"]
49+
50+
[tool.ruff.lint]
51+
select = ["ALL"]
52+
ignore = ["COM812", "D"]
53+
54+
[tool.ruff.lint.per-file-ignores]
55+
"tests/*" = ["ANN", "INP", "S101"]
56+
57+
[tool.pyright]
58+
include = ["src/"]
59+
pythonVersion = "3.13"

scripts/tests/integration.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
cd "$(git rev-parse --show-toplevel)"
6+
7+
# This file is for you! Edit it to call your integration test suite. Note that the same
8+
# file will be called if you run it locally as if you run it on CI.
9+
10+
# Replace the following line with something like:
11+
#
12+
# rails test:integration
13+
# python manage.py test
14+
# npm run test
15+
#
16+
# or whatever is appropriate to your project. You should *only* run your fast
17+
# tests from here. If you want to run other test suites, see the predefined
18+
# tasks in scripts/test.mk.
19+
20+
make dependencies install-python
21+
poetry run pytest tests/integration/ --durations=10 --cov-report term-missing --cov src

scripts/tests/unit.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ cd "$(git rev-parse --show-toplevel)"
1717
# tests from here. If you want to run other test suites, see the predefined
1818
# tasks in scripts/test.mk.
1919

20-
echo "Unit tests are not yet implemented. See scripts/tests/unit.sh for more."
20+
make dependencies install-python
21+
poetry run pytest tests/unit/ --durations=10 --cov-report term-missing --cov src

tests/.gitkeep renamed to src/eligibility_signposting_api/__init__.py

File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from flask import Flask
2+
3+
app = Flask(__name__)
4+
5+
6+
@app.route("/")
7+
def hello_world() -> str:
8+
return "<p>Hello, World!</p>"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def test_something():
2+
# Given
3+
4+
# When
5+
actual = 1
6+
7+
# Then
8+
assert actual == 1

tests/unit/test_goes_here.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def test_something():
2+
# Given
3+
4+
# When
5+
actual = 1
6+
7+
# Then
8+
assert actual == 1

0 commit comments

Comments
 (0)