Skip to content

Commit

Permalink
Fixed gh workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
tcorzo committed Jun 24, 2024
1 parent 901d250 commit a392cf9
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 72 deletions.
12 changes: 12 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
max-line-length = 120
exclude =
.git,
__pycache__,
.venv,
venv,
.eggs,
*.egg,
build,
dist
ignore = E501
39 changes: 0 additions & 39 deletions .github/workflows/python-app.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Python CI

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

jobs:
build:
name: "OS: ${{ matrix.os }} | Python ${{ matrix.python-version }}"
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10", "3.11"]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install project
run: poetry install --no-interaction

- name: Run flake8
run: poetry run flake8 .

- name: Run pytest
run: poetry run pytest tests/
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ First, `cd` into the directory where you want your courses and activities stored
To fetch activities for a specific course:

```bash
poetry run myrpl fetch <course_id> [--token YOUR_BEARER_TOKEN]
myrpl fetch <course_id>
```

This will create a file structure in the current working directory like follows:
Expand Down Expand Up @@ -107,13 +107,13 @@ This will create a file structure in the current working directory like follows:
For general help:

```bash
poetry run myrpl --help
myrpl --help
```

For help with the a specific command:

```bash
poetry run myrpl {command} --help
myrpl {command} --help
```

## Project Structure 🏗️
Expand All @@ -134,7 +134,7 @@ myrpl-cli/

To set up the development environment:

1. Install dependencies including development dependencies:
1. Install all dependencies

```bash
poetry install
Expand All @@ -148,6 +148,16 @@ poetry shell

3. Off you go! 🚀

### Tests 🧪

Use `pytest` to run the project tests

Use [act](https://github.com/nektos/act) for running the github workflow locally

### Linting 📝✅

I chose [flake8](https://pypi.org/project/flake8/) for linting

## Contributing 🤝

Contributions are welcome! Please feel free to submit a Pull Request.
Expand Down
1 change: 1 addition & 0 deletions myrpl_cli/credential_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

SERVICE_NAME = 'myrpl_cli'


class CredentialManager:

def __init__(self):
Expand Down
81 changes: 54 additions & 27 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["tcorzo"]
myrpl = "myrpl_cli.main:main"

[tool.poetry.dependencies]
python = "^3.8"
python = ">=3.10,<4.0"
requests = "^2.25.1"
python-dotenv = "^1.0.1"
pytest = "^8.2.2"
Expand All @@ -22,6 +22,9 @@ pydantic = "^2.7.4"
# myrpl test dependencies:
timeout-decorator = "^0.5.0"

[tool.poetry.group.dev.dependencies]
flake8 = "^7.1.0"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
2 changes: 1 addition & 1 deletion tests/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def test_auth_api_call_with_token_renewal(api):

with patch.object(api, 'make_request') as mock_request, \
patch.object(api, 'renew_token') as mock_renew_token, \
patch.object(api.credential_manager, 'get_stored_token') as mock_get_stored_token:
patch.object(api.credential_manager, 'get_stored_token') as mock_get_stored_token:
# The first call to make_request raises an HTTPError for 401
# The second call to make_request succeeds
mock_request.side_effect = [
Expand Down

0 comments on commit a392cf9

Please sign in to comment.