Skip to content

Commit

Permalink
Merge pull request #20 from csautter/dev_2
Browse files Browse the repository at this point in the history
ci: run pytest in github actions
  • Loading branch information
philsv authored Oct 14, 2024
2 parents c86f7e4 + 17387c0 commit e31ab0f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Run Pytest

on: [push, pull_request]

jobs:
test:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macOS-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
env:
EIA_TOKEN: ${{ secrets.EIA_TOKEN }}
run: |
pytest tests/test_api.py
28 changes: 28 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Contributing to myeia
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features

## Report bugs using Github's [issues](https://github.com/philsv/myeia/issues/)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/philsv/myeia/issues/new); it's that easy!

Write bug reports with detail, background, and sample code if possible. **Great Bug Reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can.
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

## Github Actions
We use Github Actions to automate the testing and deployment of the package. The workflow is defined in the `.github/workflows` directory.
To get your code merged into the main branch, you need to pass the tests. Feel free to extend the tests to cover your code.
For a successful test run it's necessary to [set the EIA_TOKEN as secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) in your Fork.

## License
By contributing, you agree that your contributions will be licensed under its [MIT License](LICENSE).
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,8 @@ Date
2021-01-25 2.602
... ...
```

## Contributing
We love your input! We want to make contributing to this project as easy and transparent as possible.
Read our [CONTRIBUTING.md](CONTRIBUTING.md) to get started.

11 changes: 8 additions & 3 deletions myeia/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
level=logging.INFO, format="%(asctime)s - %(message)s", datefmt="%d-%b-%y %H:%M:%S"
)

load_dotenv()

load_dotenv(verbose=True)

class API:
"""
Expand All @@ -30,7 +29,13 @@ def __init__(
self,
token: Optional[str] = None,
):
self.token = token if token else os.getenv("EIA_TOKEN")
if token:
self.token = token
elif os.getenv("EIA_TOKEN"):
self.token = os.getenv("EIA_TOKEN")
else:
raise ValueError('EIA_TOKEN is not set. Please set it in your .env file or environment variables.')

self.base_url = "https://api.eia.gov/v2/"
self.header = {"Accept": "*/*"}

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ pandas>=1.5.3
pytest>=7.2.1
python-dateutil>=2.9.0
python-dotenv>=0.19.0
requests>=2.32.0
requests>=2.32.0
numpy>=1.21.4

0 comments on commit e31ab0f

Please sign in to comment.