This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
forked from diffplug/selfie
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'python/main' into main-python
- Loading branch information
Showing
13 changed files
with
271 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
paths: | ||
- 'python/**' | ||
defaults: | ||
run: | ||
working-directory: python/selfie-lib | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- run: pipx install poetry | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: 'python/selfie-lib/pyproject.toml' | ||
cache: 'poetry' | ||
- run: poetry install | ||
- run: poetry run pytest -vv | ||
- run: poetry run pyright | ||
- run: poetry run ruff check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
.gradle/ | ||
build/ | ||
bin/ | ||
.DS_Store | ||
.DS_Store | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"python.testing.pytestArgs": [ | ||
"selfie-lib", | ||
"-vv" | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
The python implementation is under construction. It makes use of PEP 695, so you must use Python 3.12 or later. | ||
|
||
Dependencies are managed using poetry, which you can install here. | ||
- https://python-poetry.org/docs/#installing-with-the-official-installer | ||
- then cd into `selfie-lib` and run `poetry install` | ||
|
||
Our CI server runs three checks in the `selfie-lib` directory. | ||
|
||
- `poetry run pytest -vv` this runs the tests (`-vv` makes nice output) | ||
- `poetry run pyright` this does type checking | ||
- `poetry run ruff check` this checks formatting | ||
|
||
For the IDE we use VSCode. Make sure to open the `python` directory, not the parent `selfie`. Receommended VSCode plugins: | ||
|
||
- https://marketplace.visualstudio.com/items?itemName=ms-python.python | ||
- https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[tool.poetry] | ||
name = "selfie-lib" | ||
version = "0.1.0" | ||
description = "Infrastructure for creating selfie-compatible test runner plugins." | ||
authors = ["Ned Twigg <[email protected]>"] | ||
license = "Apache-2.0" | ||
readme = "../README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.12" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
ruff = "^0.2.1" | ||
pyright = "^1.1.350" | ||
pytest = "^8.0.0" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .ned import fizzbuzz as fizzbuzz | ||
from .harvir import silly_addition as silly_addition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def silly_addition(a, b): | ||
# Adds two numbers and then adds 42 to the result. | ||
return a + b + 42 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def fizzbuzz(n): | ||
fizzbuzz_results = [] | ||
for i in range(1, n + 1): | ||
if i % 3 == 0 and i % 5 == 0: | ||
fizzbuzz_results.append("FizzBuzz") | ||
elif i % 3 == 0: | ||
fizzbuzz_results.append("Fizz") | ||
elif i % 5 == 0: | ||
fizzbuzz_results.append("Buzz") | ||
else: | ||
fizzbuzz_results.append(f"{i}") | ||
return fizzbuzz_results |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from selfie_lib import silly_addition | ||
|
||
def test_silly_addition(): | ||
assert silly_addition(1, 2) == 45, "Should be 45" | ||
assert silly_addition(-42, 0) == 0, "Should be 0" | ||
assert silly_addition(10, 5) == 57, "Should be 57" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from selfie_lib import fizzbuzz | ||
|
||
|
||
def test_fizzbuzz(): | ||
assert fizzbuzz(15) == [ | ||
"1", | ||
"2", | ||
"Fizz", | ||
"4", | ||
"Buzz", | ||
"Fizz", | ||
"7", | ||
"8", | ||
"Fizz", | ||
"Buzz", | ||
"11", | ||
"Fizz", | ||
"13", | ||
"14", | ||
"FizzBuzz", | ||
] |