Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💚 ci: add github actions #1

Merged
merged 8 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: ⬆️ dep-bump
include: "scope"
111 changes: 111 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Python package

on:
push:
branches:
- "**"

jobs:
python-lint:
strategy:
matrix:
python-version: ["3.10"]
platform: [ubuntu-latest]
fail-fast: false
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root
- name: Install pdm
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
python -m pip install pdm>=2.11.1
- name: Install Dependencies
run: python -m pdm install -G lint -G dev
- name: Lint
run: python -m pdm run lint

python-test:
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
platform: [ubuntu-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root
- name: Install pdm
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
python -m pip install pdm>=2.11.1
- name: Install Dependencies
run: python -m pdm install -dG test
- name: Test
run: python -m pdm run test
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: coverage-${{ matrix.package }}-${{ matrix.python-version }}
path: reports/.coverage

upload-coverage:
runs-on: ubuntu-latest
needs: [python-test]
steps:
- uses: actions/checkout@v4
- name: Install tools
run: python -m pip install coverage requests tomli
- name: Download coverage reports
uses: actions/download-artifact@v3
- name: Combine reports
run: |
coverage combine $(ls ./**/.coverage)
coverage report
coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
files: reports/coverage.xml

bump-version:
runs-on: ubuntu-latest
needs: [python-lint, python-test]
if: |
github.event_name == 'push' &&
github.ref_name == 'main' &&
github.ref_type == 'branch' &&
!startsWith(github.event.head_commit.message, '🔖 bump(release):') &&
!startsWith(github.event.head_commit.message, 'bump(release):') &&
!startsWith(github.event.head_commit.message, '🔖 bump:') &&
!startsWith(github.event.head_commit.message, 'bump:')
name: "Bump version and create changelog with commitizen"
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 0
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
extra_requirements: "cz-conventional-gitmoji"
26 changes: 26 additions & 0 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upload Python Package

on:
push:
tags:
- "v*"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry>=1.2.0
poetry install
- name: Publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }}
run: |
./scripts/publish.sh
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ command_line = "--module pytest"
data_file = "reports/.coverage"
source = ["src"]

[tool.coverage.paths]
source = ["src/", "/home/runner/**/src", "D:\\**\\src"]

[tool.coverage.report]
fail_under = 50
precision = 1
Expand Down Expand Up @@ -170,7 +173,6 @@ convention = "google"
ban-relative-imports = "all"

[tool.ruff.lint.pep8-naming]
# Allow Pydantic's `@validator` decorator to trigger class method treatment.
classmethod-decorators = ["classmethod"]

[tool.pytest.ini_options]
Expand Down Expand Up @@ -207,7 +209,7 @@ dev = [

[tool.pdm.scripts]
lint = "pre-commit run --all-files --color always"
test = "coverage run -m pytest"
test = "coverage run -m pytest -m 'not network'"
test-network = "coverage run -m pytest -m network"
# this will run after the `test` command
post_test = { composite = ["coverage report", "coverage xml"] }

2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _session_start() -> None:
def api_key() -> str:
"""Load the API key from the environment."""
load_dotenv()
return os.environ["COINAPI_KEY"]
return os.environ.get("COINAPI_KEY", "testing")


@pytest.fixture()
Expand Down
Loading