Skip to content

Commit

Permalink
add ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmax committed Jul 10, 2024
1 parent e34b485 commit d78f933
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

[{*.yaml, *.yml}]
indent_size = 2

[*.py]
# See Ruff config
max_line_length = 120
74 changes: 74 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI
"on":
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * *"
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- uses: eifinger/setup-rye@v4
id: setup-rye
with:
enable-cache: true
cache-prefix: ${{ matrix.python-version }}
- name: Pin python-version ${{ matrix.python-version }}
if: steps.setup-rye.outputs.cache-hit != 'true'
run: rye pin ${{ matrix.python-version }}
- name: Format check
run: rye fmt --check
- name: Lint check
run: rye lint
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: eifinger/setup-rye@v4
id: setup-rye
with:
enable-cache: true
cache-prefix: ${{ matrix.python-version }}
- name: Pin python-version ${{ matrix.python-version }}
if: steps.setup-rye.outputs.cache-hit != 'true'
run: rye pin ${{ matrix.python-version }}
- name: Install dependencies
if: steps.setup-rye.outputs.cache-hit != 'true'
run: |
rye sync --no-lock
- name: Test
run: rye test -- --cov-report term-missing
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- uses: eifinger/setup-rye@v4
id: setup-rye
with:
enable-cache: true
cache-prefix: ${{ matrix.python-version }}
- name: Pin python-version ${{ matrix.python-version }}
if: steps.setup-rye.outputs.cache-hit != 'true'
run: rye pin ${{ matrix.python-version }}
- name: Build
run: rye build --clean
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ dist/
wheels/
*.egg-info

.coverage*
htmlcov

# venv
.venv

Expand Down
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
repos:
- repo: local
hooks:
- id: rye-lint
name: rye-lint
description: "Lint Python via 'rye lint'"
entry: rye lint --fix
language: system
types_or: [python, pyi]
args: []
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"
- id: rye-format
name: rye-format
description: "Format Python via 'rye fmt'"
entry: rye fmt
language: system
types_or: [python, pyi]
args: []
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"
- id: rye-test
name: rye-test
description: "Test Python via 'rye test'"
entry: rye test
language: system
types_or: [python, pyi]
args: []
pass_filenames: false
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"
16 changes: 15 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ version-file = "src/simpy_playground/_version.py"

[tool.rye]
managed = true
dev-dependencies = []
dev-dependencies = [
"pytest>=8.2.2",
"pytest-cov>=5.0.0",
"pre-commit>=3.7.1",
"pyright>=1.1.371",
]

[tool.hatch.metadata]
allow-direct-references = true
Expand All @@ -56,3 +61,12 @@ include = ["src/simpy_playground"]

[tool.hatch.build.targets.wheel]
packages = ["src/simpy_playground"]

[tool.ruff]
target-version = "py310"
line-length = 120

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q -vvv --cov=simpy_playground"
testpaths = ["tests"]
35 changes: 35 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,40 @@
# universal: false

-e file:.
cfgv==3.4.0
# via pre-commit
coverage==7.5.4
# via pytest-cov
distlib==0.3.8
# via virtualenv
exceptiongroup==1.2.1
# via pytest
filelock==3.15.4
# via virtualenv
identify==2.6.0
# via pre-commit
iniconfig==2.0.0
# via pytest
nodeenv==1.9.1
# via pre-commit
# via pyright
packaging==24.1
# via pytest
platformdirs==4.2.2
# via virtualenv
pluggy==1.5.0
# via pytest
pre-commit==3.7.1
pyright==1.1.371
pytest==8.2.2
# via pytest-cov
pytest-cov==5.0.0
pyyaml==6.0.1
# via pre-commit
simpy==4.1.1
# via simpy-playground
tomli==2.0.1
# via coverage
# via pytest
virtualenv==20.26.3
# via pre-commit
5 changes: 5 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from simpy_playground.__main__ import main


def test_main():
main()

0 comments on commit d78f933

Please sign in to comment.