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

mots: create initial prototype (bug 1733956) #1

Merged
merged 27 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b7d1a7f
mots: create initial prototype (bug 1733956)
zzzeid Oct 4, 2021
eeb823c
Additional improvements (to be squashed with previous commit)
zzzeid Oct 18, 2021
3ebc629
circleci: add circleci configuration (bug-1740083)
zzzeid Nov 8, 2021
645fb9a
Additional improvements
zzzeid Nov 29, 2021
26bd5b3
ci: add circleci integration (bug 1740083)
zzzeid Nov 30, 2021
8e0165d
Additional improvements
zzzeid Nov 30, 2021
16ed62e
Additional improvements:
zzzeid Nov 30, 2021
e5c31c6
Additional improvements:
zzzeid Dec 3, 2021
9dfac7e
Additional improvements:
zzzeid Dec 8, 2021
15373df
Additional improvements:
zzzeid Jan 7, 2022
ec11d39
Small fixes:
zzzeid Jan 11, 2022
2c7b567
Small fixes:
zzzeid Jan 28, 2022
fa5d48f
Code review feedback
zzzeid Jan 28, 2022
c08f758
Additional improvements:
zzzeid Feb 2, 2022
efcb8f5
Code review feedback + bug fixes
zzzeid Feb 2, 2022
b8fa8b5
update .gitignore
zzzeid Feb 2, 2022
857f82b
Bug fixes + dog fooding
zzzeid Feb 2, 2022
9c72723
Minor change
zzzeid Feb 2, 2022
97cee66
code review feedback + other fixes
zzzeid Feb 4, 2022
a918a37
pretty print + remove accidentally added file
zzzeid Feb 4, 2022
38e3490
Minor changes
zzzeid Feb 4, 2022
fa9258f
add more circleci environments; code review feedback
zzzeid Feb 4, 2022
271dbbe
Additional improvements:
zzzeid Feb 7, 2022
898fa78
code review feedback + small refactoring
zzzeid Feb 7, 2022
5ef6ce2
remove extra line in Makefile
zzzeid Feb 8, 2022
56d380f
update copyright
zzzeid Feb 8, 2022
fb36034
develop -> latest in README docs reference
zzzeid Feb 8, 2022
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
36 changes: 36 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: 2.1

workflows:
version: 2
test:
jobs:
- test_3_9
zzzeid marked this conversation as resolved.
Show resolved Hide resolved

jobs:
test_3_9:
docker:
- image: circleci/python:3.9
steps:
- checkout
- run:
name: setup
command: |
set -e
sudo apt-get install python3-venv
mkdir -p /tmp/test-reports
make dev-env PY=python3.9
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
make dev-env PY=python3.9
make dev-env

source .mots-env/bin/activate
make dev
- run:
name: run tests
command: |
set -e
source .mots-env/bin/activate
ulimit -c unlimited
for F in tests/test_*.py; do
pytest --junitxml=/tmp/test-reports/junit-$( basename $F .py ).xml -vv $F
done
- store_test_results:
path: /tmp/test-reports
- store_artifacts:
path: /tmo/test-reports
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
source = src/mots
14 changes: 14 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[flake8]
# Matching black's default
max-line-length = 88

extend-ignore =
D107, # Missing docstring in __init__

per-file-ignores =
# D100 Missing docstring in public module
# D101 Missing docstring in public class
# D102 Missing docstring in public method
# D103 Missing docstring in public function
# D104 Missing docstring in public package
tests/*: D100,D101,D102,D103,D104
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ documentation/_build
htmlcov/
mots.log
notes
# should be removed later
dump
parse_wiki.py
wiki
wiki.yaml
src/mots/parking_lot.py
13 changes: 13 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

build:
os: ubuntu-20.04
tools:
python: "3.9"

sphinx:
configuration: documentation/conf.py

python:
install:
- requirements: requirements.txt
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Zeid Zabaneh <zeid@mozilla.com>
103 changes: 103 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

SHELL := /bin/bash
PYTHON := $(shell which python)


.PHONY: help
help:
@echo "using python at $(PYTHON)."
@$(PYTHON) --version
@echo "usage: make <target>"
@echo
@echo "target is one of:"
@echo " help show this message and exit"
@echo " build build the python package and wheels"
@echo " clean remove temporary files"
@echo " cov run coverage check"
@echo " cov-html generate html coverage report"
@echo " dev setup local dev environment by installing required packages, etc."
@echo " dev-env create a python virtual environment in ./mots-env"
@echo " docs generate documentation"
@echo " requirements regenerate requirements.txt"
@echo " serve-cov simple http server for coverage report"
@echo " serve-docs simple http server for docs"
@echo " test run the test suite"

.PHONY: test
test:
$(PYTHON) -m pytest -vvv

.PHONY: build
build:
$(PYTHON) -m build

.PHONY: docs
docs:
make -C documentation html

.PHONY: cov
cov:
-@rm -R .coverage 2>/dev/null ||:
$(PYTHON) -m pytest --cov-fail-under=50 --cov=src/mots tests

.PHONY: cov-html
cov-html:
-@rm -R .coverage 2>/dev/null ||:
-@rm -R .htmlcov 2>/dev/null ||:
$(PYTHON) -m pytest --cov=src/mots tests --cov-report html

.PHONY: serve-cov
serve-cov:
$(PYTHON) -m http.server -d htmlcov 8080

.PHONY: format
format:
$(PYTHON) -m black src/mots
$(PYTHON) -m black tests
zzzeid marked this conversation as resolved.
Show resolved Hide resolved
$(PYTHON) -m black documentation

.PHONY: requirements
requirements:
$ rm requirements.txt
$(PYTHON) -m piptools compile --generate-hashes

.ONESHELL:
.PHONY: dev-env
dev-env:
ifdef PY
@echo "Creating virtual env in .mots-env using provided Python ($(PY))..."
-@(/usr/bin/$(PY) -m venv .mots-env && ([ $$? -eq 0 ] && echo "$(PY) found.")) 2>/dev/null||
-@(/usr/local/bin/$(PY) -m venv .mots-env && ([ $$? -eq 0 ] && echo "$(PY) found.")) 2>/dev/null
else
@echo "PY variable not defined, using python3 if available..."
@echo "Creating virtual env in .mots-env using python3..."
-@(python3 -m venv .mots-env && ([ $$? -eq 0 ] && echo "Found $(shell python3 --version)")) 2>/dev/null
endif

.PHONY: dev
dev:
# TODO: only run this if we can detect .mots-env virtual environment.
$(PYTHON) -m pip install --upgrade pip
$(PYTHON) -m pip install pip-tools
$(PYTHON) -m pip install -r requirements.txt
$(PYTHON) -m pip install -e .

.PHONY: serve-docs
serve-docs:
$(PYTHON) -m http.server -d documentation/_build/html 8080

.PHONY: clean
clean:
-@rm -R htmlcov 2>/dev/null ||:
-@rm -R documentation/_build 2>/dev/null ||:
-@rm -R dist 2>/dev/null ||:
-@rm -R src/*.egg-info 2>/dev/null ||:
-@rm -R src/mots/__pycache__ 2>/dev/null ||:
-@rm -R tests/__pycache__ 2>/dev/null ||:
-@rm -R .coverage 2>/dev/null ||:
-@rm -R .pytest_cache 2>/dev/null ||:
-@rm -R .mots-env 2>/dev/null ||:
-@rm -R .pytest_cache-env 2>/dev/null ||:
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
For full documentation, see https://mots.readthedocs.io/en/develop/.
zzzeid marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 20 additions & 0 deletions documentation/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
58 changes: 58 additions & 0 deletions documentation/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

"""Configuration file for the Sphinx documentation builder."""

# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

sys.path.insert(0, os.path.abspath("../src"))


# -- Project information -----------------------------------------------------

project = "mots"
copyright = "2021 Mozilla Inc."
author = "Zeid Zabaneh <zeid@mozilla.com>"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
Loading