mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 23:26:40 -08:00
Python: Add Continuous Integration for Python
There are a lot of exceptions, but it's a start. This will ensure that no more issues get added / that issues get fixed before the code is added
This commit is contained in:
35
.github/workflows/check-python.yml
vendored
Normal file
35
.github/workflows/check-python.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Check Python code
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r 00_Utilities/python/ci-requirements.txt
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
pytest 01_Acey_Ducey/python 02_Amazing/python
|
||||
- name: Test with mypy
|
||||
run: |
|
||||
mypy . --exclude 79_Slalom --exclude 27_Civil_War --exclude 38_Fur_Trader --exclude 81_Splat --exclude 09_Battle --exclude 40_Gomoko --exclude 36_Flip_Flop --exclude 43_Hammurabi --exclude 04_Awari --exclude 78_Sine_Wave --exclude 77_Salvo --exclude 34_Digits --exclude 17_Bullfight --exclude 16_Bug
|
||||
- name: Test with flake8
|
||||
run: |
|
||||
flake8 . --ignore E501,W504,W503,E741,F541,E203,W291,E722,E711,E712,F821,F401,E402,F841,E302,E731,E266
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -28,6 +28,7 @@ out/
|
||||
*.py[co]
|
||||
.python-version
|
||||
Pipfile
|
||||
venv/
|
||||
|
||||
.DS_Store
|
||||
.vs/
|
||||
|
||||
3
00_Utilities/python/ci-requirements.in
Normal file
3
00_Utilities/python/ci-requirements.in
Normal file
@@ -0,0 +1,3 @@
|
||||
pytest
|
||||
flake8
|
||||
mypy
|
||||
38
00_Utilities/python/ci-requirements.txt
Normal file
38
00_Utilities/python/ci-requirements.txt
Normal file
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# This file is autogenerated by pip-compile with python 3.10
|
||||
# To update, run:
|
||||
#
|
||||
# pip-compile ci-requirements.in
|
||||
#
|
||||
attrs==21.4.0
|
||||
# via pytest
|
||||
flake8==4.0.1
|
||||
# via -r ci-requirements.in
|
||||
iniconfig==1.1.1
|
||||
# via pytest
|
||||
mccabe==0.6.1
|
||||
# via flake8
|
||||
mypy==0.931
|
||||
# via -r ci-requirements.in
|
||||
mypy-extensions==0.4.3
|
||||
# via mypy
|
||||
packaging==21.3
|
||||
# via pytest
|
||||
pluggy==1.0.0
|
||||
# via pytest
|
||||
py==1.11.0
|
||||
# via pytest
|
||||
pycodestyle==2.8.0
|
||||
# via flake8
|
||||
pyflakes==2.4.0
|
||||
# via flake8
|
||||
pyparsing==3.0.7
|
||||
# via packaging
|
||||
pytest==7.0.1
|
||||
# via -r ci-requirements.in
|
||||
tomli==2.0.1
|
||||
# via
|
||||
# mypy
|
||||
# pytest
|
||||
typing-extensions==4.1.1
|
||||
# via mypy
|
||||
@@ -40,6 +40,7 @@ def build_maze(width: int, length: int) -> Maze:
|
||||
# Set to 1 if there is an exit down
|
||||
# Set to 2 if there is an exit right
|
||||
# Set to 3 if there are exits down and right
|
||||
assert width >= 2 and length >= 2
|
||||
|
||||
used = []
|
||||
walls = []
|
||||
|
||||
27
02_Amazing/python/test_amazing.py
Normal file
27
02_Amazing/python/test_amazing.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import pytest
|
||||
from amazing import build_maze, welcome_header
|
||||
|
||||
|
||||
def test_welcome_header(capsys):
|
||||
assert welcome_header() == None
|
||||
out, err = capsys.readouterr()
|
||||
assert out == (
|
||||
" AMAZING PROGRAM\n"
|
||||
" CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n\n\n\n"
|
||||
)
|
||||
assert err == ""
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("width", "length"),
|
||||
[
|
||||
(1, 1),
|
||||
(1, 0),
|
||||
(1, -1),
|
||||
(1, 2),
|
||||
(2, 1),
|
||||
],
|
||||
)
|
||||
def test_build_maze(width, length):
|
||||
with pytest.raises(AssertionError):
|
||||
build_maze(width, length)
|
||||
Reference in New Issue
Block a user