Skip to content

Commit

Permalink
Merge pull request #36 from madeddie/31-refactor-code-to-have-session…
Browse files Browse the repository at this point in the history
…-client-and-ui-components

Switch to rye and ruff
  • Loading branch information
madeddie authored May 21, 2024
2 parents 67f9a42 + eed7552 commit 4325af4
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 64 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

permissions:
pull-requests: write

steps:
- uses: actions/checkout@v4
- uses: eifinger/setup-rye@v3
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: run ruff
uses: chartboost/ruff-action@v1
- name: run tests
run: |
echo '```' > pytest.log
rye test | tee -a pytest.log
echo '```' >> pytest.log
- name: PR comment pytest output
uses: thollander/actions-comment-pull-request@v2
with:
filePath: pytest.log
if: github.event_name == 'pull_request'
49 changes: 0 additions & 49 deletions .github/workflows/test.yml

This file was deleted.

16 changes: 10 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# python dev objects
# python generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info

# venv
.venv
__pycache__

# local testing objects
*.json
cookies.txt
# testing files
.coverage
.envrc
11 changes: 8 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ repos:
- id: check-merge-conflict
- id: check-json
- id: no-commit-to-branch
- repo: https://github.com/psf/black
rev: 22.10.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.4
hooks:
- id: black
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.3
39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[project]
name = "tyora"
version = "0.1.0"
description = "CLI to interact with the mooc.fi instance of CSES"
license = "MIT"
authors = [
{ name = "Edwin Hermans", email = "[email protected]" }
]
dependencies = [
"html2text>=2024.2.26",
"htmlement>=2.0.0",
"requests>=2.32.1",
]
readme = "README.md"
requires-python = ">= 3.12"

[project.scripts]
"tyora" = "tyora:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = [
"pytest>=8.2.1",
"requests-mock>=1.12.1",
"pytest-cov>=5.0.0",
]

[tool.hatch.metadata]
allow-direct-references = true

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

[tool.pytest.ini_options]
addopts = "--cov"
38 changes: 38 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false
# generate-hashes: false

-e file:.
certifi==2024.2.2
# via requests
charset-normalizer==3.3.2
# via requests
coverage==7.5.1
# via pytest-cov
html2text==2024.2.26
# via tyora
htmlement==2.0.0
# via tyora
idna==3.7
# via requests
iniconfig==2.0.0
# via pytest
packaging==24.0
# via pytest
pluggy==1.5.0
# via pytest
pytest==8.2.1
# via pytest-cov
pytest-cov==5.0.0
requests==2.32.1
# via requests-mock
# via tyora
requests-mock==1.12.1
urllib3==2.2.1
# via requests
25 changes: 25 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false
# generate-hashes: false

-e file:.
certifi==2024.2.2
# via requests
charset-normalizer==3.3.2
# via requests
html2text==2024.2.26
# via tyora
htmlement==2.0.0
# via tyora
idna==3.7
# via requests
requests==2.32.1
# via tyora
urllib3==2.2.1
# via requests
6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

File renamed without changes.

0 comments on commit 4325af4

Please sign in to comment.