Skip to content

Commit

Permalink
Better Tox Integration
Browse files Browse the repository at this point in the history
  • Loading branch information
markovejnovic committed Dec 4, 2023
1 parent bbe6526 commit aa208a3
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/res/badges/code-style.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .github/res/badges/python-version.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 21 additions & 13 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: lint-and-test
run-name: Lint and Test
name: ci-regressions
run-name: Run CI Regressions
on:
pull_request:
branches:
Expand All @@ -9,28 +9,36 @@ on:
- main

jobs:
lint:
name: Build Lint and Test Code
regressions:
name: CI Regression Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'pip'

- name: Setup Poetry
uses: abatilo/actions-poetry@v2
- name: Grab Tox and Poetry
run: pip install tox poetry

- name: Install Dependencies
run: |
poetry install
- name: Lint and Test
run: tox
env:
MARKETSTACK_TOKEN_TEST: "${{ secrets.MARKETSTACK_TOKEN_TEST }}"

- name: Build Lint and Test
- name: Run a Build
run: poetry build

- name: Create a build-artifacts tarball
run: |
make ci-build-lint-test
env:
MARKETSTACK_TOKEN_TEST: "${{ secrets.MarketstackFreeTestToken }}"
tar -czf \
build-artifacts.tar.gz \
test-artifacts-* \
dist
- name: Upload Artifacts
uses: actions/upload-artifact@v3
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,5 @@ cython_debug/
#.idea/

# Build Artifact ignores
build-artifacts
build-artifacts*/
build-artifacts.tar.gz
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ build:
rm -rf build-artifacts/dist
mv dist build-artifacts/dist

ci-build-lint-test: build lint test
tar -czf build-artifacts.tar.gz build-artifacts
build-lint-test: build lint test
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# aiomarketstack

![Python 3.6-3.11](.github/res/badges/python-version.svg)
![Code Style](.github/res/badges/code-style.svg)

`aiomarketstack` is a thin-and-light, Python-only `asyncio`-based
[marketsack](https://marketstack.com/) client.

Expand All @@ -11,7 +14,26 @@ To get started, grab yourself a copy of `aiomarketstack`:
pip install aiomarketstack
```

## Development

To manually build `aiomarketstack` for development, we use `poetry`. Get
started with:

```bash
git clone https://github.com/markovejnovic/aiomarketstack.git
cd aiomarketstack
poetry install && poetry build
```

### Unit Tests

You can test your code against test suite via `tox`.

```bash
MARKETSTACK_TOKEN_TEST=<Your-Marketstack-Free-Token> tox
```

> [!CAUTION]
> This will consume about 30 API requests.
## Dependencies
The code is tested against `py38-311`.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ readme = "README.md"
packages = [{ include = "aiomarketstack" }]

[tool.poetry.dependencies]
python = "^3.8"
aiohttp = {version = "^3.9.1", python = "^3.8"}
python = "^3.8"
structlog = {version = "^23.2.0", python = "^3.8"}
typing-extensions = {version = "^4.8.0", python = "^3.8"}

[tool.poetry.group.test.dependencies]
mypy = {version = "^1.7.1", python = "^3.8"}
numpy = {version = "^1.24", python = "^3.8"}
pytest = {version = "^7.4.3", python = "^3.8"}
pytest-asyncio = {version = "^0.23.1", python = "^3.8"}
pytest-cov = {version = "^4.1.0", python = "^3.8"}
ruff = {version = "^0.1.6", python = "^3.8"}
numpy = {version = "^1.24", python = "^3.8"}

[build-system]
requires = ["poetry-core"]
Expand Down
21 changes: 21 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tox]
isolated_build = True
envlist = py38,py39,py310,py311

[testenv]
deps =
mypy
numpy
pytest
pytest-asyncio
pytest-cov
ruff
commands =
pytest \
--cov=aiomarketstack \
--cov-report=html:test-artifacts-{envname} \
--cov-report=term tests/
mypy aiomarketstack tests
ruff check .
passenv =
MARKETSTACK_TOKEN_TEST

0 comments on commit aa208a3

Please sign in to comment.