Git and README
The very first thing was to create a git repository, write a README.md
file describing the sport. Much like what I posted within the first article of this sequence.
Create the primary take a look at
Then create a file referred to as assessments/test_game.py
with the next content material:
import mastermind.sport as mm
def test_game():
mm.play()
assert True
It isn’t a lot, however I needed to see that the assessments are going to work.
I additionally put in pytest:
pip set up pytest
Then operating pytest
:
pytest
acquired the next error
ModuleNotFoundError: No module named 'mastermind'
That is after all not stunning as I’ve not created that module.
Creating the skeleton of the module
Subsequent step was to create the file that may maintain the implementation of the sport. I created the file mastermind/sport.py
with the next content material:
def play():
...
Very minimalistic, I do know, however sufficient to fulfill the take a look at:
PYTHONPATH=. pytest
This time it was profitable.
Organising GitHub Actions for Steady Integration (CI)
Having assessments is nice. Having a CI to run them on each push
and each pull-request
is method higher.
So I created the file .github/workflows/ci.yml
with the next content material:
title: CI
on:
push:
pull_request:
workflow_dispatch:
# schedule:
# - cron: '42 5 * * *'
jobs:
take a look at:
technique:
fail-fast: false
matrix:
runner: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11"]
runs-on: ${{matrix.runner}}
title: OS ${{matrix.runner}} Python ${{matrix.python-version}}
steps:
- title: Checkout
makes use of: actions/checkout@v3
- title: Arrange Python ${{ matrix.python-version }}
makes use of: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- title: Set up dependencies
run: |
# pip set up -r necessities.txt
pip set up pytest
- title: Verify Python model
run: python -V
- title: Take a look at with pytest
env:
PYTHONPATH: .
run: pytest -vs
It’s humorous that to date that is essentially the most complicated a part of the challenge, but it surely will not change rather a lot.
The final file I added was the .gitignore
file with the next content material:
__pycache__
*.bak
This may assist me make sure that we do not add generated recordsdata to git by mistake.
Listing format
To make it simpler to grasp the challenge I’m additionally together with the listing format now we have now:
.
├── mastermind
│ └── sport.py
├── README.md
├── .gitignore
└── assessments
└── test_game.py
Conclusion
OK, so once I began to jot down this challenge I believed I am going to have extra free time to make extra progress, however after I printed the introduction one thing got here up and I solely managed to get up to now. However one have to begin someplace and it is not that horrible to make sluggish progress.
I hope tomorrow I am going to have some extra time to work on this.