Skip to content

Commit

Permalink
Add automation infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
ElePT committed Nov 27, 2023
1 parent d023788 commit 037b9f5
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
OS := $(shell uname -s)

ifeq ($(OS), Linux)
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
else ifeq ($(OS), Darwin)
NPROCS := 2
else
NPROCS := 0
endif # $(OS)

ifeq ($(NPROCS), 2)
CONCURRENCY := 2
else ifeq ($(NPROCS), 1)
CONCURRENCY := 1
else ifeq ($(NPROCS), 3)
CONCURRENCY := 3
else ifeq ($(NPROCS), 0)
CONCURRENCY := 0
else
CONCURRENCY := $(shell echo "$(NPROCS) 2" | awk '{printf "%.0f", $$1 / $$2}')
endif

.PHONY: lint black test test_ci coverage clean

all_check: lint

lint:
pylint -rn qopt_best_practices test

black:
python -m black qopt_best_practices test

test:
python -m unittest discover -v test

test_ci:
echo "Detected $(NPROCS) CPUs running with $(CONCURRENCY) workers"
python -m stestr run --concurrency $(CONCURRENCY)

coverage:
python -m coverage3 run --source qopt_best_practices -m unittest discover -s test -q
python -m coverage3 report

coverage_erase:
python -m coverage erase

clean: coverage_erase;
29 changes: 29 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 100
target-version = ['py38', 'py39', 'py310', 'py311']

[tool.pylint.main]
py-version = "3.8" # update it when bumping minimum supported python version

[tool.pylint.basic]
good-names = ["a", "b", "i", "j", "k", "d", "n", "m", "ex", "v", "w", "x", "y", "z", "Run", "_", "logger", "q", "c", "r", "qr", "cr", "qc", "nd", "pi", "op", "b", "ar", "br", "p", "cp", "ax", "dt", "__unittest", "iSwapGate", "mu"]
method-rgx = "(([a-z_][a-z0-9_]{2,49})|(assert[A-Z][a-zA-Z0-9]{2,43})|(test_[_a-zA-Z0-9]{2,}))$"
variable-rgx = "[a-z_][a-z0-9_]{1,30}$"

[tool.pylint.format]
max-line-length = 105 # default 100

[tool.pylint."messages control"]
disable = []

enable = [
"use-symbolic-message-instead"
]

[tool.pylint.spelling]
spelling-private-dict-file = ".pylintdict"
spelling-store-unknown-words = "n"
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
coverage>=4.4.0,<7.0
black[jupyter]~=22.0
pylint>=2.15.0
ddt>=1.2.0,!=1.4.0,!=1.4.3
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
python-sat
networkx
# preventively pinning qiskit in anticipation of
# breaking changes in 1.0
qiskit>=0.44,<1.0
2 changes: 2 additions & 0 deletions stestr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[DEFAULT]
test_path=./test
41 changes: 41 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[tox]
# Sets this min.version because of differences with env_tmp_dir env.
minversion = 4.0.2
envlist = py38, py39, py310, py311, lint
skipsdist = True

[testenv]
usedevelop = True
install_command = pip install -c constraints.txt -U {opts} {packages}
passenv = *
setenv =
VIRTUAL_ENV={envdir}
LANGUAGE=en_US
LC_ALL=en_US.utf-8
ARGS="-V"
deps = git+https://github.com/Qiskit/qiskit.git
-r{toxinidir}/requirements.txt
-r{toxinidir}/requirements-dev.txt
commands =
stestr run {posargs}

[testenv:lint]
envdir = .tox/lint
basepython = python3
commands =
black --check {posargs} qopt_best_practices test
pylint -rn qopt_best_practices test

[testenv:black]
envdir = .tox/lint
commands = black {posargs} qopt_best_practices test

[testenv:coverage]
basepython = python3
setenv =
{[testenv]setenv}
PYTHON=coverage3 run --source qopt_best_practices --parallel-mode
commands =
stestr run {posargs}
coverage3 combine
coverage3 report

0 comments on commit 037b9f5

Please sign in to comment.