Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit 93f956f

Browse files
authored
Stubs for starting our python project (especially CI) (#1)
2 parents 09b3efa + 7f70541 commit 93f956f

File tree

11 files changed

+260
-1
lines changed

11 files changed

+260
-1
lines changed

.github/workflows/python-ci.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
push:
3+
branches: [main]
4+
pull_request:
5+
paths:
6+
- 'python/**'
7+
defaults:
8+
run:
9+
working-directory: python/selfie-lib
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
jobs:
14+
build:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, windows-latest]
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
- run: pipx install poetry
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version-file: 'python/selfie-lib/pyproject.toml'
28+
cache: 'poetry'
29+
- run: poetry install
30+
- run: poetry run pytest -vv
31+
- run: poetry run pyright
32+
- run: poetry run ruff check

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.gradle/
33
build/
44
bin/
5-
.DS_Store
5+
.DS_Store
6+
__pycache__/

python/.python-version

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

python/.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"python.testing.pytestArgs": [
3+
"selfie-lib",
4+
"-vv"
5+
],
6+
"python.testing.unittestEnabled": false,
7+
"python.testing.pytestEnabled": true
8+
}

python/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
The python implementation is under construction. It makes use of PEP 695, so you must use Python 3.12 or later.
2+
3+
Dependencies are managed using poetry, which you can install here.
4+
- https://python-poetry.org/docs/#installing-with-the-official-installer
5+
- then cd into `selfie-lib` and run `poetry install`
6+
7+
Our CI server runs three checks in the `selfie-lib` directory.
8+
9+
- `poetry run pytest -vv` this runs the tests (`-vv` makes nice output)
10+
- `poetry run pyright` this does type checking
11+
- `poetry run ruff check` this checks formatting
12+
13+
For the IDE we use VSCode. Make sure to open the `python` directory, not the parent `selfie`. Receommended VSCode plugins:
14+
15+
- https://marketplace.visualstudio.com/items?itemName=ms-python.python
16+
- https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff

python/selfie-lib/poetry.lock

+148
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/selfie-lib/pyproject.toml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[tool.poetry]
2+
name = "selfie-lib"
3+
version = "0.1.0"
4+
description = "Infrastructure for creating selfie-compatible test runner plugins."
5+
authors = ["Ned Twigg <[email protected]>"]
6+
license = "Apache-2.0"
7+
readme = "../README.md"
8+
9+
[tool.poetry.dependencies]
10+
python = "^3.12"
11+
12+
[tool.poetry.group.dev.dependencies]
13+
ruff = "^0.2.1"
14+
pyright = "^1.1.350"
15+
pytest = "^8.0.0"
16+
17+
[build-system]
18+
requires = ["poetry-core"]
19+
build-backend = "poetry.core.masonry.api"
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .ned import fizzbuzz as fizzbuzz

python/selfie-lib/selfie_lib/ned.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def fizzbuzz(n):
2+
fizzbuzz_results = []
3+
for i in range(1, n + 1):
4+
if i % 3 == 0 and i % 5 == 0:
5+
fizzbuzz_results.append("FizzBuzz")
6+
elif i % 3 == 0:
7+
fizzbuzz_results.append("Fizz")
8+
elif i % 5 == 0:
9+
fizzbuzz_results.append("Buzz")
10+
else:
11+
fizzbuzz_results.append(f"{i}")
12+
return fizzbuzz_results

python/selfie-lib/tests/__init__.py

Whitespace-only changes.

python/selfie-lib/tests/ned_test.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from selfie_lib import fizzbuzz
2+
3+
4+
def test_fizzbuzz():
5+
assert fizzbuzz(15) == [
6+
"1",
7+
"2",
8+
"Fizz",
9+
"4",
10+
"Buzz",
11+
"Fizz",
12+
"7",
13+
"8",
14+
"Fizz",
15+
"Buzz",
16+
"11",
17+
"Fizz",
18+
"13",
19+
"14",
20+
"FizzBuzz",
21+
]

0 commit comments

Comments
 (0)