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

Upgrade python CI actions #58

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 0 additions & 3 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
make venv > /dev/null
source venv/bin/activate

dotenv_if_exists .env
26 changes: 18 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,40 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Black
uses: microsoft/[email protected].0
uses: microsoft/[email protected].2
with:
workdir: .
black: true
python_version: "3.12"
- name: Flake8
uses: microsoft/[email protected].0
uses: microsoft/[email protected].2
with:
workdir: .
flake8: true
python_version: "3.12"

pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v3
- name: Pytest
uses: microsoft/[email protected]
- uses: actions/setup-python@v5
with:
workdir: .
testing: true
python_version: ${{ matrix.python-version }}
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
**/requirements.txt
**/requirements-dev.txt
- name: Install deps
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Pytest
run: |
python -m pytest
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VENV_BIN ?= python3.11 -m venv
VENV_BIN ?= python3 -m venv
VENV_DIR ?= venv
PIP_CMD ?= pip3

Expand All @@ -21,15 +21,15 @@ $(VENV_ACTIVATE): setup.py setup.cfg
venv: $(VENV_ACTIVATE) ## Create a new (empty) virtual environment

freeze: ## Run pip freeze -l in the virtual environment
@$(VENV_RUN); pip freeze -l
@$(VENV_RUN); $(PIP_CMD) freeze -l

pre-commit: ## Install pre-commit hooks
@pre-commit install > /dev/null
@$(VENV_RUN); pre-commit install > /dev/null

install: ## Install full dependencies into venv
make install-lib
make install-dev
@make pre-commit
make pre-commit

install-dev: venv ## Install requirements for development into venv
@$(VENV_RUN); $(PIP_CMD) install -r requirements-dev.txt
Expand All @@ -39,19 +39,19 @@ install-lib: venv ## Install requirements for godaddypy into venv

dist: ## Build distributions
@$(VENV_RUN); pip install --upgrade twine build;
python -m build
@$(VENV_RUN); python -m build

publish: clean-dist dist ## Publish the library to the central PyPi repository
$(VENV_RUN); twine upload dist/*

test: ## Run tests via PyTest
@$(VENV_RUN); pytest
@$(VENV_RUN); python -m pytest

lint: ## Run linter
@$(VENV_RUN); python -m pflake8 --show-source

format:
@$(VENV_RUN); python -m black examples godaddypy tests
format: ## Run formatting
@$(VENV_RUN); python -m black .

clean: ## Clean up everything
rm -f .coverage
Expand Down
7 changes: 4 additions & 3 deletions godaddypy/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from os import environ, path, makedirs
from pathlib import Path
from sys import stdout
from typing import Union

import yaml
from configloader import ConfigLoader
Expand Down Expand Up @@ -100,7 +101,7 @@ def __init__(self, api_key=None, api_secret=None, delegate=None, log_level=None)
self.__api_secret = self.__api_secret or (config.secret if config else api_secret)
self._config = config

def __parse_configuration(self) -> Configuration | None:
def __parse_configuration(self) -> Union[Configuration, None]:
# Get config from environment
env_config = self.__parse_env()

Expand All @@ -111,7 +112,7 @@ def __parse_configuration(self) -> Configuration | None:
# See: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
return self.__parse_file()

def __parse_file(self) -> Configuration | None:
def __parse_file(self) -> Union[Configuration, None]:
if not self or not path.exists(self._config_path):
return None

Expand All @@ -131,7 +132,7 @@ def __parse_file(self) -> Configuration | None:

return Configuration(key=key, secret=secret)

def __parse_env(self) -> Configuration | None:
def __parse_env(self) -> Union[Configuration, None]:
config = ConfigLoader()
config.update_from_env_namespace("GODADDY_API")

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.black]
line-length = 120
target-version = ['py38']
target-version = ['py39']

[tool.flake8]
max-line-length = 120
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))


def get_reqs(*fns):
lst = []
for fn in fns:
Expand All @@ -17,6 +18,7 @@ def get_reqs(*fns):
lst.append(package.strip())
return lst


with open("godaddypy/__init__.py", "r") as f:
version_match = re.search(r"^__version__\s*=\s*[\'\"]([^\'\"]*)[\'\"]", f.read(), re.MULTILINE)

Expand All @@ -37,8 +39,8 @@ def get_reqs(*fns):
author_email="[email protected]",
url="https://github.com/eXamadeus/godaddypy",
packages=["godaddypy"],
install_requires=get_reqs('requirements.txt'),
tests_require=get_reqs('requirements-dev.txt'),
install_requires=get_reqs("requirements.txt"),
tests_require=get_reqs("requirements-dev.txt"),
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
Expand Down
Loading