Skip to content

Commit

Permalink
Add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanramoscfa committed Jan 9, 2024
1 parent d250c4f commit bf4b115
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 20 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: sphinx

on:
push:
branches: [ main, dev ]
paths:
- 'docs/**'
- 'pycgapi/**'
pull_request:
branches: [ main, dev ]
paths:
- 'docs/**'
- 'pycgapi/**'

jobs:
build-docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build Sphinx Documentation
run: |
cd docs
make html
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
build-and-upload:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Extract version from tag
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

- name: Update version number
run: |
echo "__version__ = '${{ env.VERSION }}'" > pycgapi/__version__.py
- name: Install dependencies
run: pip install -r requirements.txt

- name: Build package
run: python setup.py sdist bdist_wheel

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
10 changes: 3 additions & 7 deletions .github/workflows/main.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: pytest

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

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -25,14 +25,10 @@ jobs:
pip install -r requirements.txt
- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --max-line-length=120
- name: Run tests with coverage
run: |
export PYTHONPATH=$PYTHONPATH:./
pytest --cov=./pycgapi --cov-report=xml
env:
pythonLocation: /opt/hostedtoolcache/Python/3.11.7/x64
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ All notable changes to `pycgapi` will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Added
## [Unreleased]
- Asynchronous functionality for enhanced performance (planned).

## [0.1.1] - 2024-01-09

### Added
- Automated GitHub workflow for Pypi package release.
- Separation of different GitHub workflows into their individual `.yml` files.
- Creation of `__version__.py` to maintain a single source of truth for the project's version number.
- Updates to README.md and index.rst for correcting hyperlinks to `examples`.
- Inclusion of `sphinx` in `requirements.txt` for documentation support.

## [0.1.0] - 2024-01-08

### Added
Expand All @@ -28,6 +37,3 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

### Fixed
- Comprehensive testing for all functionalities ensuring robust performance.

## [Unreleased]
- No pending changes.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[![pytest](https://github.com/nathanramoscfa/pycgapi/actions/workflows/main.yml/badge.svg)](https://github.com/nathanramoscfa/pycgapi/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/nathanramoscfa/pycgapi/graph/badge.svg?token=I1CRHDN73S)](https://codecov.io/gh/nathanramoscfa/pycgapi)
[![Documentation Status](https://readthedocs.org/projects/coingeckoapi/badge/?version=latest)](https://coingeckoapi.readthedocs.io/en/latest/?badge=latest)
![PyPI](https://img.shields.io/pypi/v/pycgapi)
![Python Version](https://img.shields.io/pypi/pyversions/pycgapi)

## Table of Contents
1. [Overview](#overview)
Expand Down Expand Up @@ -90,7 +92,7 @@ python setup.py install
## API Key
You do not need an API key to use the Public API. You will need an API key to use the Pro API. To obtain an API key,
please visit the [CoinGecko API](https://www.coingecko.com/api) page and follow the instructions. This package comes
bundled with `keyring` ([Homepage](https://github.com/jaraco/keyring)) to save and retrieve your API key securely
bundled with [keyring](https://github.com/jaraco/keyring) to save and retrieve your API key securely
without having to hardcode it. To save your API key, simply run the following code in a Python console or Jupyter
Notebook:

Expand Down Expand Up @@ -132,7 +134,7 @@ api = CoinGeckoAPI() # no API key required for public API
```python
import keyring
from pycgapi import CoinGeckoAPI
api_key = keyring.get_password('coingecko', 'api_key') # gets your API key from keyring
api_key = keyring.get_password('coingecko', 'api_key') # gets your API key
api = CoinGeckoAPI(api_key, pro_api=True) # must provide api_key and set pro_api=True
```
**Ping the CoinGecko API server:**
Expand All @@ -150,7 +152,7 @@ The output above confirms a successful connection to the CoinGecko API server.

## Usage Examples
For detailed examples of all endpoints, see the
[examples directory](https://github.com/nathanramoscfa/pycgapi/examples). Here are a few examples of `pycgapi`:
[examples directory](https://github.com/nathanramoscfa/pycgapi/tree/main/examples). Here are a few examples of `pycgapi`:

**Get a list of all supported coins:**

Expand Down
1 change: 1 addition & 0 deletions __version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.2.0'
5 changes: 3 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import os
import sys
from pycgapi.__version__ import __version__
sys.path.insert(0, os.path.abspath('../..'))


Expand All @@ -22,8 +23,8 @@
author = 'Nathan Ramos, CFA'

# The full version, including alpha/beta/rc tags
version = '0.1.0'
release = '0.1.0'
version = __version__
release = __version__


# -- General configuration ---------------------------------------------------
Expand Down
12 changes: 9 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
:target: https://coingeckoapi.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://img.shields.io/pypi/v/pycgapi
:target: https://pypi.org/project/pycgapi/

.. image:: https://img.shields.io/pypi/pyversions/pycgapi
:target: https://pypi.org/project/pycgapi/


Table of Contents
=================
Expand Down Expand Up @@ -149,7 +155,7 @@ To initialize the ``pycgapi`` client, simply run the following code based on you
import keyring
from pycgapi import CoinGeckoAPI
# gets your API key from keyring
# gets your API key
api_key = keyring.get_password(
'coingecko',
'api_key'
Expand All @@ -175,7 +181,7 @@ The output above confirms a successful connection to the CoinGecko API server.
Usage Examples
==============

See the `examples <https://github.com/nathanramoscfa/pycgapi/examples>`_ directory for detailed examples of all
See the `examples <https://github.com/nathanramoscfa/pycgapi/tree/main/examples>`_ directory for detailed examples of all
endpoints. Here are a few examples of ``pycgapi``:

**Get a list of all supported coins:**
Expand Down Expand Up @@ -340,7 +346,7 @@ License
=======

``pycgapi`` is released under the MIT License. See
`LICENSE <https://github.com/nathanramoscfa/pycgapi/LICENSE>`_ file for more details.
`LICENSE <https://github.com/nathanramoscfa/pycgapi/blob/main/LICENSE>`_ file for more details.

Contact
=======
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pandas~=2.1.3
pytest-cov~=4.1.0
pytz~=2023.3
requests~=2.31.0
sphinx~=5.0.2
sphinx-rtd-theme~=2.0.0
tqdm~=4.66.1
urllib3~=2.1.0
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from setuptools import setup, find_packages
from pycgapi.__version__ import __version__

# Read the contents of your requirements file
with open('requirements.txt', encoding='utf-8') as f:
Expand All @@ -10,7 +11,7 @@

setup(
name='pycgapi',
version='0.1.0',
version=__version__,
author='Nathan Ramos, CFA',
author_email='nathan.ramos.github@gmail.com',
description='A Python wrapper for the CoinGecko API',
Expand Down

0 comments on commit bf4b115

Please sign in to comment.