Skip to content

Commit 1b53678

Browse files
authored
Merge pull request #3 from dhruvan2006/github-actions
Add release and tests action
2 parents 0bbc4d8 + 6611de6 commit 1b53678

File tree

5 files changed

+84
-6
lines changed

5 files changed

+84
-6
lines changed

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.x"
19+
20+
- name: Install pypa/build
21+
run: python3 -m pip install build --user
22+
23+
- name: Build a binary wheel and a source tarball
24+
run: python3 -m build
25+
26+
- name: Store the distribution packages
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: python-package-distributions
30+
path: dist/
31+
32+
publish-to-pypi:
33+
name: >-
34+
Publish Python distribution to PyPI
35+
needs:
36+
- build
37+
runs-on: ubuntu-latest
38+
environment:
39+
name: pypi
40+
url: https://pypi.org/p/ocfinance
41+
permissions:
42+
id-token: write # IMPORTANT: mandatory for trusted publishing
43+
44+
steps:
45+
- name: Download all the dists
46+
uses: actions/download-artifact@v4
47+
with:
48+
name: python-package-distributions
49+
path: dist/
50+
- name: Publish distribution to PyPI
51+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.x"
19+
- name: Install dependencies
20+
run: |
21+
pip install --upgrade pip
22+
pip install -r requirements.txt
23+
pip install pytest
24+
- name: Run tests
25+
run: pytest

ocfinance/scraper/cryptoquant.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
CRYPTOQUANT_URL = "https://cryptoquant.com/"
88

99
def _download(url, **kwargs):
10+
email = kwargs.get('email')
11+
password = kwargs.get('password')
12+
if not email or not password:
13+
raise TypeError("Email and/or password hasn't been passed")
14+
1015
splits = urlparse(url).path.split('/')
1116
id = splits[-1]
1217

@@ -17,10 +22,6 @@ def _download(url, **kwargs):
1722
proxy = kwargs.get('proxy', None)
1823
driver = _get_driver(proxy=proxy)
1924

20-
email = kwargs.get('email')
21-
password = kwargs.get('password')
22-
if not email or not password:
23-
raise TypeError("Email and/or password hasn't been passed")
2425
data = _get_json(driver, id, email, password)
2526

2627
columns = data['data']['result']['columns']

tests/test_bitbo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ def test_download_data(monkeypatch):
6060
result_df = _download('test_url')
6161

6262
pd.testing.assert_frame_equal(result_df, expected_df)
63-
6463

64+
65+
@pytest.mark.skipif(not sbr_webdriver, reason="Skipping Bitbo integration tests: SBR_WEBDRIVER not provided.")
6566
@pytest.mark.parametrize("url, expected_columns", [
6667
(
6768
"https://charts.bitbo.io/cycle-repeat/",

tests/test_download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_download_valid_urls(url, expected_data, provider):
3131

3232
def test_download_invalid_url():
3333
invalid_url = "https://unknownsource.com/some_data"
34-
with pytest.raises(ValueError, match="URL does not match any known source"):
34+
with pytest.raises(ValueError, match="Unsupported source"):
3535
download(invalid_url)
3636

3737

0 commit comments

Comments
 (0)