Skip to content

Commit

Permalink
Refactor into Poetry project, update dependencies (#161)
Browse files Browse the repository at this point in the history
* Initialise Poetry project

* Add format.yml workflow

* Format Python code with Ruff

* Delete requirements.txt

* Fix relative imports

* Add test.yml workflow

* Remove old main.yml workflow

* Update usage instructions to work with Poetry

* Update CI badge to tests workflow

* Change 'tests' -> 'test'

---------

Co-authored-by: IsaacCheng9 <IsaacCheng9@users.noreply.github.com>
  • Loading branch information
IsaacCheng9 and IsaacCheng9 committed Jun 25, 2024
1 parent bc06f04 commit d190947
Show file tree
Hide file tree
Showing 23 changed files with 1,199 additions and 105 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Format

on: [push]

jobs:
format:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12.x]

steps:
- uses: actions/checkout@v3

- name: Run Python code formatting with Ruff
uses: chartboost/ruff-action@main
with:
args: "format --exclude src/trading_portfolio_tracker/ui"

- name: Commit changes made by Ruff
uses: stefanzweifel/git-auto-commit-action@master
with:
commit_message: Format Python code with Ruff

- name: Switch to current branch
run: git checkout ${{ env.BRANCH }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@main
with:
python-version: ${{ matrix.python-version }}
35 changes: 14 additions & 21 deletions .github/workflows/main.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Test

# Controls when the action will run.
on:
Expand All @@ -8,45 +8,38 @@ on:
workflow_dispatch:

jobs:
build:
test:
# The type of runner that the job will run on.
runs-on: ubuntu-latest
runs-on: macos-latest
# Configures the build to use the latest version of Python 3.
strategy:
matrix:
python-version: [3.x]
python-version: [3.12.x]

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can
# access it.
- uses: actions/checkout@v2

- name: Run Python code formatting with Black
uses: lgeiger/black-action@v1.0.1
with:
args: "."

- name: Commit changes made with code formatters
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Format Python code with Black
- uses: actions/checkout@main

- name: Switch to current branch
run: git checkout ${{ env.BRANCH }}

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

- name: Install dependencies
- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
pip install poetry
- name: Install Python dependencies with Poetry
run: |
poetry install
- name: Run unit tests with Pytest
run: coverage run --source=src -m pytest -v
run: poetry run coverage run --source=src/travel_buddy -m pytest -v

- name: Get code coverage report
run: coverage report -m
run: poetry run coverage report -m
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Travel Buddy

[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
![CI](https://github.com/IsaacCheng9/travel-buddy/actions/workflows/main.yml/badge.svg)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![Test](https://github.com/IsaacCheng9/travel-buddy/actions/workflows/test.yml/badge.svg)

**UPDATE (25th June 2024):** The application is no longer fully functional due
to outdated code for scraping data from websites.

**UPDATE (30th August 2022):** The route analysis and related features such as
location autocomplete are currently unavailable as our key for the Google Maps
Expand All @@ -19,34 +22,31 @@ planet by providing route analysis and a carpool marketplace.
<img width="2056" alt="image" src="https://user-images.githubusercontent.com/47993930/160259727-5bda8093-7a97-498a-b338-8806284647eb.png">
<img width="2056" alt="image" src="https://user-images.githubusercontent.com/47993930/160259626-7fe98e35-d7b0-4a2e-abf8-a2faa9b0e492.png">

## Installation
## Usage

### Installing Dependencies

Run the following command from the [project root](./) directory:

### Python Version
```bash
poetry install
```

The application has been developed and tested to work on _Python 3.8_ and
onwards.
### Running the Application

### Running the Application Locally
Run the following command from the [project root](./) directory:

To run the application, you should follow the following steps:
```bash
poetry run app
```

1. Clone this GitHub repository.
2. Ensure that you're in the root directory: `travel-buddy`
3. Install the required Python libraries: `pip install -r requirements.txt`
4. Install the code as a package on your local machine with the command:
`pip install -e .`
5. Run the application with the command: `python -m travel_buddy.app`
6. Navigate to <http://127.0.0.1:5000/> in your web browser.
### Running Tests

### Running Tests Locally
Run the following command from the [project root](./) directory:

1. Clone this GitHub repository.
2. Ensure that you're in the root directory: `travel-buddy`
3. Install the required Python libraries: `pip install -r requirements.txt`
4. Install the code as a package on your local machine with the command:
`pip install -e .`
5. Run all tests with the command `python -m pytest`
6. View test results in the terminal.
```bash
poetry run pytest
```

## Demo Instructions

Expand Down
Loading

0 comments on commit d190947

Please sign in to comment.