Skip to content

Commit 9c2bfe7

Browse files
chore: CI
1 parent 8196011 commit 9c2bfe7

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313
strategy:
14-
max-parallel: 4
14+
fail-fast: false
15+
max-parallel: 3
1516
matrix:
1617
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1718
steps:
@@ -23,16 +24,15 @@ jobs:
2324

2425
- name: Install Dependencies
2526
run: |
26-
python -m pip install --upgrade pip
27-
pip install -r requirements-dev.txt
27+
make init
2828
2929
- name: Lint
3030
run: |
3131
make lint
3232
3333
- name: Tests
3434
run: |
35-
python -m pytest tests
35+
make pytest
3636
3737
deploy:
3838
needs: build

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.PHONY: docs
22
init:
3+
python -m pip install --upgrade pip
34
python -m pip install -r requirements-dev.txt
45

56
test:
@@ -14,6 +15,9 @@ lint:
1415
python -m isort tls_requests
1516
python -m flake8 tls_requests
1617

18+
pytest:
19+
python -m pytest tests
20+
1721
coverage:
1822
python -m pytest --cov-config .coveragerc --verbose --cov-report term --cov-report xml --cov=tls_requests tests
1923

@@ -25,11 +29,11 @@ publish-test-pypi:
2529
python -m pip install 'twine>=6.0.1'
2630
python setup.py sdist bdist_wheel
2731
twine upload --repository testpypi dist/*
28-
rm -rf build dist .egg *.egg-info
32+
rm -rf build dist .egg wrapper_tls_requests.egg-info
2933

3034
publish-pypi:
3135
python -m pip install -r requirements-dev.txt
3236
python -m pip install 'twine>=6.0.1'
3337
python setup.py sdist bdist_wheel
3438
twine upload dist/*
35-
rm -rf build dist .egg *.egg-info
39+
rm -rf build dist .egg wrapper_tls_requests.egg-info

tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
import tls_requests
2+
13
pytest_plugins = ['pytest_httpserver', 'pytest_asyncio']
4+
5+
6+
def pytest_configure(config):
7+
tls_requests.TLSLibrary.load()

tls_requests/models/libraries.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515

1616
BIN_DIR = os.path.join(Path(__file__).resolve(strict=True).parent.parent / "bin")
1717
GITHUB_API_URL = "https://api.github.com/repos/bogdanfinn/tls-client/releases"
18+
OS_PLATFORM = platform
19+
OS_MACHINE = machine()
1820
PATTERN_RE = re.compile(
19-
r"xgo[a-zA-Z0-9.-]+%s-%s\.(so|dll|dylib)" % (platform, machine()), re.I
21+
r"[a-zA-Z0-9.-]+%s-%s\.(so|dll|dylib)" % (OS_PLATFORM, OS_MACHINE), re.I
2022
)
2123

2224

@@ -58,6 +60,7 @@ def from_kwargs(cls, **kwargs):
5860
class TLSLibrary:
5961
@classmethod
6062
def fetch_api(cls, version: str = None, retries: int = 3):
63+
6164
for _ in range(retries):
6265
try:
6366
response = requests.get(GITHUB_API_URL)
@@ -70,14 +73,16 @@ def fetch_api(cls, version: str = None, retries: int = 3):
7073
asset
7174
for release in releases
7275
for asset in release.assets
73-
if "xgo" in str(asset.browser_download_url)
76+
if PATTERN_RE.search(asset.browser_download_url)
7477
]
7578
if version is not None:
7679
for asset in assets:
7780
if str(version) == asset.name:
78-
return [asset.browser_download_url]
81+
yield asset.browser_download_url
82+
83+
for asset in assets:
84+
yield asset.browser_download_url
7985

80-
return [asset.browser_download_url for asset in assets]
8186
except Exception as e:
8287
print("Unable to fetch GitHub API: %s" % e)
8388

@@ -96,11 +101,12 @@ def find_all(cls) -> list[str]:
96101
@classmethod
97102
def download(cls, version: str = None) -> str:
98103
try:
104+
print("System Info - Platform: %s, Machine: %s." % (OS_PLATFORM, OS_MACHINE))
99105
download_url = None
100106
for download_url in cls.fetch_api(version):
101-
if PATTERN_RE.search(download_url):
102-
break
107+
break
103108

109+
print("Download URL: %s" % download_url)
104110
if download_url:
105111
destination = os.path.join(BIN_DIR, download_url.split("/")[-1])
106112
with requests.get(download_url, stream=True) as response:

0 commit comments

Comments
 (0)