Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Add basic test data generator and document dev flow
Browse files Browse the repository at this point in the history
  • Loading branch information
spladug committed Jan 24, 2020
1 parent 999e820 commit fb6fdc2
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 14 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@ Harold and Harold's Code Salon are tools for coordinating software development,
code review, and deployment. They were made for reddit.com's dev team to use
and have grown over the years.

## Installation
# Development

Harold's `setup.py` will install a base system. Configuration of the salon web
interface is not yet documented.
For reddit employees, you can use the OneVM to develop harold. Enable it with

## Configuration
vagrant enable-repo harold

See [example.ini](example.ini) for a sample configuration with annotations.
and then provision with

## API
vagrant provision

If the HTTP plugin is enabled, harold will present an HTTP API which allows
various actions to be commanded remotely. A simple python command API wrapper
can be found in https://github.com/spladug/wessex.
To test slack communciation, you'll need to generate a Slack API token by going
to

## License
https://<myslackdomain>.slack.com/apps/manage/custom-integrations

The Harold code itself is released under the BSD 3-clause license. Various 3rd
party components have different licenses and all of this can be found in
[LICENSE](LICENSE).
and setting up a "bot" integration. Put the resulting value into the
appropriate field in the `example.ini`.

# Testing

To simulate webhooks firing, use the `tests/fire-webhook` script with payloads
in `tests/webhookpayloads`.

tests/fire-webhook tests/webhookpayloads/push-multiple-nonsender.request
4 changes: 3 additions & 1 deletion salon/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
# register views
import salon.views

# register cli command for email sending
# register cli commands
import salon.email
import salon.metrics
import salon.test_data
61 changes: 61 additions & 0 deletions salon/test_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import datetime

from salon.app import app
from salon.models import db
from salon.models import Event
from salon.models import PullRequest
from salon.models import ReviewState


@app.cli.command()
def make_test_data():
now = datetime.datetime.utcnow()
reviewers = {"foo": "fish", "bar": "nail_care", "baz": "unreviewed"}

if not PullRequest.query.get(("example/test", 1)):
pr_time = now - datetime.timedelta(hours=3)
db.session.add(PullRequest(
repository="example/test",
id=1,
created=pr_time,
author="example",
state="open",
title="This is an example pull request",
url="https://github.com/example/test/pull/1",
))
db.session.add(Event(
actor="example",
event="opened",
timestamp=pr_time,
repository="example/test",
pull_request_id=1,
info={},
))
db.session.add(Event(
actor="example",
event="review_requested",
timestamp=pr_time,
repository="example/test",
pull_request_id=1,
info={"targets": list(reviewers)},
))
db.session.commit()

for name, state in reviewers.iteritems():
if not ReviewState.query.get(("example/test", 1, name)):
db.session.add(ReviewState(
repository="example/test",
pull_request_id=1,
user=name,
timestamp=now,
state=state,
))
db.session.add(Event(
actor=name,
event="review",
timestamp=now,
repository="example/test",
pull_request_id=1,
info={"state": state},
))
db.session.commit()

0 comments on commit fb6fdc2

Please sign in to comment.