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: Improve and modernize software tests configuration and dependency package definition #31

Merged
merged 5 commits into from
May 18, 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
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
91 changes: 58 additions & 33 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,63 @@
name: Tests

on:
pull_request:
branches:
- main
pull_request: ~
push:
branches: [ main ]

# Allow job to be triggered manually.
workflow_dispatch:

# Run job each night after CrateDB nightly has been published.
schedule:
- cron: '0 3 * * *'

# Cancel in-progress jobs when pushing to the same branch.
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Run linter
run: make lint
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Run software tests
run: make test
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Measure code coverage
run: make coverage

tests:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.8", "3.11"]

env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}

steps:

- name: Acquire sources
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'pip'
cache-dependency-path: 'pyproject.toml'

- name: Run linters
run: make lint

- name: Run software tests
run: make test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Configuration
# =============

$(eval venv := .venv311)
$(eval venv := .venv)
$(eval pip := $(venv)/bin/pip)
$(eval python := $(venv)/bin/python)
$(eval pytest := $(venv)/bin/pytest)
Expand All @@ -19,7 +19,7 @@ $(eval tsperf := $(venv)/bin/tsperf)

# Setup Python virtualenv
setup-virtualenv:
@test -e $(python) || python3.11 -m venv $(venv)
@test -e $(python) || python3 -m venv $(venv)

# Install requirements for development.
virtualenv-dev: setup-virtualenv
Expand All @@ -38,7 +38,4 @@ format: virtualenv-dev
$(isort) tsperf tests

test: virtualenv-dev
$(pytest) -vvv tests

coverage: virtualenv-dev
$(pytest) --cov=tsperf --cov-fail-under=80 --cov-branch --cov-report=term tests
$(pytest) tests
33 changes: 16 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,36 @@
long_description = fh.read()

requires = [
"blessed==1.18.0",
"boto3==1.17.84",
"botocore~=1.20.84",
"blessed<1.21",
"boto3<1.35",
"crate==0.26.0",
"prometheus_client==0.10.1",
"urllib3==1.26.5",
"datetime_truncate==1.1.1",
"prometheus-client<0.11",
"urllib3<2",
"datetime-truncate<2",
"psycopg2-binary<2.10",
"influxdb_client==1.17.0",
"pymongo==3.11.4",
"dnspython==2.1.0",
"influxdb-client<2",
"pymongo<4",
"dnspython<3",
"numpy<1.27",
"pgcopy==1.5.0",
"pgcopy<1.7",
#"pyodbc<5",
"tqdm==4.61.0",
"cloup==0.8.2",
"tqdm<5",
"cloup<1",
]

test_requires = [
"pytest==6.2.4",
"pytest-cov==2.12.0",
"dotmap==1.3.23",
"pytest<7",
"pytest-cov<6",
"dotmap<1.4",
"flakehell==0.9.0",
"flake8==3.8.4",
# FIXME: Does not work per 2024-05-18
# "flake8-bandit==2.1.2",
"flake8-black==0.2.1",
"flake8-black<0.4",
"flake8-bugbear<22",
"flake8-isort<5",
"black==21.5b1",
"isort==5.8.0",
"isort<5.9",
]

setuptools.setup(
Expand Down