Skip to content

Commit 6234af1

Browse files
committed
Initial commit
0 parents  commit 6234af1

25 files changed

+832
-0
lines changed

Diff for: .github/ISSUE_TEMPLATE.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Feel free to raise an issue for any of the following:
2+
3+
* Support request
4+
* Feature request
5+
* Argument
6+
* Bug
7+

Diff for: .github/PULL_REQUEST_TEMPLATE.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Qualities of an ideal pull request:
2+
3+
Code changes come with a new story or an amendment to an existing story
4+
in order to exercise the code.
5+
6+
Commit messages that adhere to the following pattern:
7+
8+
TYPEOFCOMMIT : Quick explanation of what changed and why.
9+
10+
Where TYPEOFCOMMIT is one of the following:
11+
12+
* FEATURE - for new features and accompanying stories.
13+
* BUG - for bugfixes and accompanying stories (or amendments to an existing story).
14+
* DOCS - for changes to README, etc. and non-functional changes to stories.
15+
* MISC - Anything else.
16+
17+
Ideal code qualities:
18+
19+
* Loosely coupled
20+
* DRY
21+
* Clear and straightforward is preferable to clever
22+
* Docstrings that explain why rather than what
23+
* Clearly disambiguated Variable/method/class names
24+
* Passes flake8 linting with < 100 character lines

Diff for: .github/workflows/regression.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Regression
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
10+
jobs:
11+
regression:
12+
timeout-minutes: 30
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: checkout repo
16+
uses: actions/checkout@v2
17+
18+
- name: build
19+
run: |
20+
mkdir -p ~/.ssh/
21+
touch ~/.ssh/id_rsa
22+
touch ~/.ssh/id_rsa.pub
23+
echo test | podman secret create pypitoken -
24+
./key.sh make
25+
26+
- name: regression
27+
run: |
28+
./key.sh regression

Diff for: .gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
hitchskeleton.egg-info/
2+
.vscode/
3+
venv/
4+
5+
docs/snippets/
6+
docs/draft/
7+
docs/src/using/
8+
9+
hitchpylibrarytoolkit/
10+
11+
*.pyc

Diff for: CHANGELOG.md

Whitespace-only changes.

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 pixegami
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: MANIFEST.in

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include VERSION
2+
include LICENSE.txt
3+
include README.md
4+
recursive-include hitch *
5+
prune hitch/__pycache__
6+
prune hitch/gen

Diff for: PROJECT_NAME

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hitchskeleton

Diff for: README.md

Whitespace-only changes.

Diff for: VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

Diff for: docs/public/_

Whitespace-only changes.

Diff for: docs/src/index.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{{{{ intro.txt }}}}
2+
3+
HitchSkeleton is a command line bootstrapper for quickly setting up a skeleton
4+
integration testing framework with necessary functionality and sensible defaults
5+
for various different kinds of projects.
6+
7+
* Realistic
8+
* Hermetic
9+
* Economic
10+
* Literate
11+
12+
## Quickstart
13+
14+
{{{{ quickstart.txt }}}}
15+
16+
## Install
17+
18+
HitchSkeleton is best install with pipx:
19+
20+
```bash
21+
pipx install hitchskeleton
22+
```
23+
24+
As a command line app, it is typically best installed via
25+
[pipx](https://pypa.github.io/pipx/).
26+
27+
```bash
28+
pipx install hitchskeleton
29+
```
30+

Diff for: hitch/Dockerfile-hitch

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ubuntu:20.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
ENV LC_ALL=C.UTF-8
5+
ENV LANG=C.UTF-8
6+
7+
RUN apt-get update && apt-get install \
8+
libuv1-dev libncurses5-dev libncursesw5-dev xz-utils \
9+
liblzma-dev tk-dev build-essential \
10+
libreadline-dev libffi-dev libsqlite3-dev \
11+
zlib1g-dev zlib1g libbz2-dev libssl-dev \
12+
curl git make llvm wget \
13+
python3-virtualenv virtualenv python3.8-venv \
14+
python3-dev python-openssl -y \
15+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
16+
17+
RUN mkdir /src
18+
WORKDIR /src

Diff for: hitch/debugrequirements.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
flake8
2+
ipython #==1.2.1
3+
pyzmq
4+
path.py
5+
q
6+
ipykernel
7+
sure
8+
ensure
9+
python-slugify
10+
pytest

Diff for: hitch/engine.py

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
from hitchstory import (
2+
StoryCollection,
3+
BaseEngine,
4+
exceptions,
5+
validate,
6+
no_stacktrace_for,
7+
strings_match,
8+
Failure
9+
)
10+
from hitchstory import GivenDefinition, GivenProperty, InfoDefinition, InfoProperty
11+
from templex import Templex
12+
from strictyaml import Optional, Str, Map, Int, Bool, Enum, load, MapPattern
13+
from path import Path
14+
import hitchpylibrarytoolkit
15+
from hitchrunpy import (
16+
ExamplePythonCode,
17+
HitchRunPyException,
18+
ExpectedExceptionMessageWasDifferent,
19+
)
20+
from shlex import split
21+
from templex import Templex
22+
from commandlib import Command
23+
24+
25+
class Engine(BaseEngine):
26+
"""Python engine for running tests."""
27+
28+
given_definition = GivenDefinition(
29+
files=GivenProperty(
30+
MapPattern(Str(), Str()),
31+
inherit_via=GivenProperty.OVERRIDE,
32+
),
33+
)
34+
35+
info_definition = InfoDefinition(
36+
status=InfoProperty(schema=Enum(["experimental", "stable"])),
37+
docs=InfoProperty(schema=Str()),
38+
)
39+
40+
def __init__(self, keypath, python_path=None, rewrite=False, cprofile=False):
41+
self.path = keypath
42+
self._python_path = python_path
43+
self._rewrite = rewrite
44+
self._cprofile = cprofile
45+
46+
def set_up(self):
47+
"""Set up your applications and the test environment."""
48+
self.path.profile = self.path.gen.joinpath("profile")
49+
self.path.working = self.path.gen.joinpath("working")
50+
51+
if self.path.working.exists():
52+
self.path.working.rmtree()
53+
self.path.working.mkdir()
54+
55+
for filename, contents in self.given["files"].items():
56+
filepath = self.path.working.joinpath(filename)
57+
if not filepath.dirname().exists():
58+
filepath.dirname().mkdir()
59+
self.path.working.joinpath(filename).write_text(contents)
60+
61+
if not self.path.profile.exists():
62+
self.path.profile.mkdir()
63+
64+
self.python = Command(self._python_path)
65+
self.hitchskeleton_bin = Command(self._python_path.parent / "hitchskeleton")\
66+
.with_env(MOCK="yes")
67+
68+
@no_stacktrace_for(AssertionError)
69+
@validate(cmd=Str(), output=Str(), error=Bool())
70+
def hitchskeleton(self, cmd, output, error=False):
71+
command = self.hitchskeleton_bin(*split(cmd)).in_dir(self.path.working)
72+
73+
if error:
74+
command = command.ignore_errors()
75+
76+
actual_output = command.output()
77+
78+
try:
79+
strings_match(output, actual_output)
80+
except Failure:
81+
if self._rewrite:
82+
self.current_step.update(output=actual_output)
83+
else:
84+
raise
85+
86+
def pause(self, message="Pause"):
87+
import IPython
88+
89+
IPython.embed()
90+
91+
def on_success(self):
92+
if self._rewrite:
93+
self.new_story.save()
94+
if self._cprofile:
95+
self.python(
96+
self.path.key.joinpath("printstats.py"),
97+
self.path.profile.joinpath("{0}.dat".format(self.story.slug)),
98+
).run()

Diff for: hitch/hitchreqs.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hitchpylibrarytoolkit==0.6.20

0 commit comments

Comments
 (0)