Commit Graph

246 Commits

Author SHA1 Message Date
Dandelion Mané 6ecf282956
Setup travis CI testing (#58)
Observe that it passed on this commit, but failed builds [#2: Break Tests][2], [#3: Break Flow][3], and [#4: Break Prettier][4]. 

Close #23 

[2]: https://travis-ci.org/sourcecred/sourcecred/builds/348453195
[3]: https://travis-ci.org/sourcecred/sourcecred/builds/348454983
[4]: https://travis-ci.org/sourcecred/sourcecred/builds/348455387
2018-03-02 14:39:54 -08:00
William Chargin 58410c62fa
Replace lingering `mealGraph`s in test case (#57)
Summary:
In merging #54, there was a semantic merge conflict that was not also a
textual merge conflict; this created a failure that only appeared once
that commit was merged.

We propose that to fix this in the future, we only merge commits that
are directly ahead of master.

Test Plan:
This fixes `yarn flow` and `yarn test`.

wchargin-branch: fix-merge-conflict
2018-03-02 14:16:51 -08:00
William Chargin 97446138ab
Make `Address`, `Node`, `Edge` read-only and exact (#56)
Summary:
Again: we assume these invariants, so we may as well encode them.
We should just keep in mind that non-Flow users may wantonly violate
these, so we should still code defensively.

wchargin-branch: readonly-exact
2018-03-02 13:49:34 -08:00
William Chargin f305a48391
Check for `null`/`undefined` in graph functions (#55)
Summary:
These will make nicer error functions in cases where static analysis
doesn’t detect the pollution: e.g., a user isn’t using Flow, or an
expression like `arr[0]` introduces an `undefined`.

Paired with @dandelionmane.

Test Plan:
New unit tests added. Run `yarn test`.

wchargin-branch: null-undefined-check
2018-03-02 13:47:13 -08:00
Dandelion Mané ca3502009b
Create an 'advancedMealGraph' test case (#54)
Create an 'advancedMealGraph' test case

The advancedMealGraph will be a grab-all that holds all advanced and
edge behaviors, e.g. the crab-self-referential loop, and the case
where there are multiple directed edges between the same two nodes.

Aggregating them into one test case will make it easier to test more
complex behaviors, like graph merging and serialization, on the
edge case graphs. However, it's still nice to have the simple graph
so that we can test simple things too. The specific tests for edge
case behavior are left mostly unchanged, in that they start from the
simple graph and add just the advanced feature that they want to test.
2018-03-02 13:45:52 -08:00
William Chargin cae3a92dc9
Add `getAllNodes` and `getAllEdges` functions (#53)
Summary:
Without these functions, it is not possible to meaningfully operate on
an arbitrary graph.

Paired with @dandelionmane.

Test Plan:
New unit tests included. Run `yarn flow && yarn test`.

wchargin-branch: get-all
2018-03-02 11:33:45 -08:00
William Chargin 01510ca63f
Make node and edge types exact (#51)
Summary:
We’ve realized that `u: Edge<T>` implies `u: Node<T>`. That certainly
wasn’t what we were expecting! We might want something like that
eventually, to capture the fact that valuations are themselves valuable,
but for now the type system should encode the assumptions that we’re
actually making. See also #50.

Paired with @dandelionmane.

wchargin-branch: exact-types
2018-03-02 11:31:38 -08:00
Dandelion Mané d26b264e8d
Add "license" field to package.json (#52) 2018-03-02 11:31:12 -08:00
William Chargin 09156bf3f4
Promote `Graph` to a class with useful methods (#49)
Summary:
We had planned to expose our core types as simple Plain Old JavaScript
Objects, with accompanying standalone functions to act directly on these
data structures. We chose this instead of creating `class`es for the
types because it simplifies serialization interop: it obviates the need
for serialization and deserialization functions, because the code is
separated from the data entirely. Reconsidering, we now think that the
convenience benefits of using classes probably outweigh these
serialization cons. Furthermore, this design enables us to separate
ancillary data structures and caches from the raw data, presenting a
cleaner API for consumers of the data.

This commit introduces a `Graph` class and some related logic. With lots
of tests! And 100% code coverage! :-)

Paired with @dandelionmane.

Test Plan:
Run `yarn flow && yarn test` to see the new tests.

wchargin-branch: graph-class
2018-03-01 01:04:11 -08:00
William Chargin f5d486087d
Pull in-edges and out-edges up to top-level graph (#48)
Summary:
The main problem with having these fields on the node is that this
presents the illusion that the API surface area is larger than it
actually is. Clients with reference to a node object could
somewhat-reasonably expect that mutating these fields would be
sufficient to update the structure of the graph, but this isn’t the case
(as the edge objects would need to be updated, too). It’s a nice
semantic bonus, too, as edges aren’t conceptually “part of” nodes.

wchargin-branch: top-level-edges
2018-03-01 00:48:23 -08:00
William Chargin 66243a16c1
Remove weights from the weighted graph (#47)
Summary:
This is an experiment. There are a couple diffferent meanings of
“weight” in play: most prominently, weights assigned by plugins versus
those suitable for comparison among other arbitrary weights. We’re not
sure what the right thing is to put in the actual graph object, so we’re
going to think about this a bit more before adding the field back in.

wchargin-branch: remove-weights
2018-03-01 00:45:52 -08:00
William Chargin 43450f18b1
Rename `sourceId`/`destId` to `src`/`dst` (#46)
Summary:
The “ID” parts were left-over from the Great Address Migration, and we
think that abbreviations are fine here, anyway.

Test Plan:
`yarn flow && yarn test`

wchargin-branch: src-dst-rename
2018-03-01 00:32:30 -08:00
Dandelion Mané cde98cd67b
Remove outdated design documents (#45)
design.md and overview.md both describe a vision of sourcecred
in which it is a measure of credit, and an explicit cryptographic
token. right now, SourceCred is more focused on just measuring credit,
with the expectation that cryptoincentives can be added on later.

Removing these outdated documents will reduce confusion; they may
be re-written and re-added later.
2018-02-28 20:41:04 -08:00
William Chargin 01df727c39
Add tiny-example-repository example data (#44)
Summary:
The sourcecred/tiny-example-repository repository stores some example
data that we can use to generate test cases. As of now, the repository
has been archived so that its state is stable. This commit checks in the
result of our scraper on the repository.

wchargin-branch: example-data
2018-02-28 20:36:18 -08:00
Dandelion Mané 9dc9d5e4f3 Change order of repositoryName and pluginName 2018-02-28 17:47:15 -08:00
Dandelion Mané 58ad1eb635 Add inEdges and outEdges for Nodes. 2018-02-28 17:47:15 -08:00
Dandelion Mané 2992a31157 Graph concept renames
- ID -> Address
- ID.name -> Address.id
- GraphEdge -> Edge
- GraphNode -> Node
2018-02-28 17:47:15 -08:00
William Chargin 791cad9059
Add conversion functions for id (#38)
Test Plan:
Run `yarn test` and note that tests pass.

wchargin-branch: id-conversion
2018-02-26 22:57:00 -08:00
Dandelion Mané bc2377448f
Move package json to root (#37)
Reorganize the code so that we have a single package.json file, which is at the root.
All source code now lives under `src`, separated into `src/backend` and `src/explorer`.

Test plan:

- run `yarn start` - it works
- run `yarn test` - it finds the tests (all in src/explorer) and they pass
- run `yarn flow` - it works. (tested with an error, that works too)
- run `yarn prettify` - it finds all the js files and writes to them
2018-02-26 22:32:23 -08:00
William Chargin c5be6eceda
Create script to scrape data from GitHub repos (#36)
Summary:
This tool grabs all the information that we think will be relevant for a
first-pass implementation of the SourceCred project graph. It includes a
tool to save the results to disk so that we avoid needlessly hitting the
GitHub API over and over.

Paired with @dandelionmane.

Test Plan:
The API doesn’t have tests, because we didn’t think that they would
provide much marginal value. But here’s how you invoke it:

    node bin/fetchAndPrintGitHubRepo.js sourcecred sourcecred "${TOKEN}" >/tmp/out

to crawl the repository `sourcecred/sourcecred` with the given API
token.

wchargin-branch: grab-github-data
2018-02-26 17:11:57 -08:00
Dandelion Mané d41872b7b7
Update README.md (#31)
This reflects our current vision that SourceCred is aimed at valuing open-source contributions via a credit graph, not on directly creating cryptotokens
2018-02-26 17:06:06 -08:00
Dandelion Mané 9878313ef3
Add types for GitHub plugin. (#35) 2018-02-26 17:05:50 -08:00
Dandelion Mané 2c083425fb
Add initial graph data types (#34) 2018-02-26 16:52:24 -08:00
William Chargin d48e8e7f26
Add prettier to backend (#33)
Summary:
Follows the lead of #18.

Test Plan:
Verify that non-pretty files abort the commit:
```shell
$ echo 'const x = 1  +  1;' >foo.js
$ git add foo.js
$ git commit -m yikes
husky > npm run -s precommit (node v8.9.4)

 ❯ Running tasks for **/*.js
   ✖ prettier --list-different
     → foo.js
✖ prettier --list-different found some errors. Please fix them and try committing again.
foo.js

husky > pre-commit hook failed (add --no-verify to bypass)
```

wchargin-branch: backend-prettier
2018-02-26 16:42:53 -08:00
Dandelion Mané 5f55804677
Setup flow for backend. (#32) 2018-02-26 16:40:13 -08:00
Dandelion Mané 4dbb5cd21a
Initial commit of the backend project. (#30)
Sets up package.json, .gitignore, and adds octokit/rest.js as a dependency.
2018-02-26 11:24:00 -08:00
William Chargin 32220148c0 Upgrade: babel-plugin-flow-react-proptypes@^18.0.0 (#27)
Summary:
Generated: `yarn add --dev babel-plugin-flow-react-proptypes@^18.0.0`.

This pulls in brigand/babel-plugin-flow-react-proptypes#182 and
brigand/babel-plugin-flow-react-proptypes#184, both of which affect this
project.

wchargin-branch: upgrade-flow-proptypes-18.0.0
2018-02-18 14:13:42 -08:00
Dandelion Mané b367da8568 Run `yarn prettify` for the first time. (#22) 2018-02-18 08:13:29 -08:00
Dandelion Mané de359dbaa4
Frontend visual cleanup (#21)
* Use font roboto

* Change title.

* Add grid gap

* Restyle app; blue header, and css->inline.

* Further visual cleanup.

- Apply consistent formatting to the two plugin panes.
- Add scroll to the User Explorer.
- Both have white backgrounds with centered titles.
2018-02-18 02:00:11 -08:00
Dandelion Mané 167289a75a
Set up prettier as an autoformatter (#18)
Setup prettier precommit, with yarn prettify to reformat.

- Prettier runs as a precommit hook and fails if code is improperly formatted.
- Run `yarn prettify` to reformat the project.
2018-02-18 01:59:28 -08:00
William Chargin 5744d3c860
Autogenerate PropTypes from Flow types (#20)
Summary:
Closes #17; see discussion there.

This commit uses the `babel-plugin-flow-react-proptypes` package to
automatically create PropType definitions from components that are typed
with Flow. It simultaneously updates all of our existing components to
be typed with Flow. As a result, we have both static and dynamic type
checking.

Test Plan:
Note that `yarn test` and `yarn flow` report no errors, and that there
are no prop validation errors at runtime with `yarn start`.

Then, apply the following patch:
```diff
diff --git a/explorer/src/UserExplorer.js b/explorer/src/UserExplorer.js
index bb574cd..636a10d 100644
--- a/explorer/src/UserExplorer.js
+++ b/explorer/src/UserExplorer.js
@@ -18,7 +18,7 @@ export class UserExplorer extends Component<{
         .sort((a,b) => b[1] - a[1]);
     const entries = sortedUserWeightTuples.map(authorWeight => {
       const [author, weight] = authorWeight;
-      return <UserEntry userId={author} weight={weight} key={author}/>
+      return <UserEntry userId={55} weight={weight} key={author}/>
     });
     return <div className="user-explorer">
       <h3> User Explorer </h3>
```
Note that `yarn test` fails (the `App.test.js` E2E rendering test),
`yarn flow` fails, and there is a runtime prop validation error.

wchargin-branch: autogenerate-proptypes
2018-02-17 13:30:16 -08:00
William Chargin ee59eb9b30
Eject from create-react-app (#19)
Summary:
This commit was created by performing the following steps:
  - `rm -r node_modules`
  - `yarn install`
  - `yarn eject`
  - `rm -r node_modules`
  - `yarn install`
on an environment wit Node v6.11.1.

The final `rm -r node_modules && yarn install` ensures that the
`yarn.lock` file is updated accordingly.

Test Plan:
`yarn test`, `yarn flow`, and `yarn start` all still do the right thing.

wchargin-branch: eject
2018-02-17 13:28:47 -08:00
William Chargin c1b37fa729 Add an end-to-end component test for App
Summary:
This should ensure that there aren’t any runtime PropTypes errors.

The change to reimplement `Object.entries` is due to the fact that my
local Node environment (v6.11.1) does not yet support that ESnext
function.

Test Plan:
Apply the following diff (`git apply`):
```diff
diff --git a/explorer/src/UserExplorer.js b/explorer/src/UserExplorer.js
index 8da252d..cdc1370 100644
--- a/explorer/src/UserExplorer.js
+++ b/explorer/src/UserExplorer.js
@@ -10,7 +10,7 @@ export class UserExplorer extends Component {
   static propTypes = {
     selectedPath: PropTypes.string.isRequired,
     selectedUser: PropTypes.string,
-    onSelectUser: PropTypes.func.isRequired,
+    onSelectUser: PropTypes.number.isRequired,
     data: commitUtilsPropTypes.commitData.isRequired,
   }
```
Then, `yarn test` should fail. Revert the diff, and `yarn test` should
pass.

wchargin-branch: react-proptypes-test
2018-02-16 16:32:30 -08:00
William Chargin 1d0368411c Add PropTypes to existing React components
Test Plan:
Run `yarn start` and note that the app runs without any console
warnings, but that changing some of the PropTypes to introduce an error
actually does cause a warning. Upcoming: an automatic test for this.

wchargin-branch: add-proptypes
2018-02-16 16:32:30 -08:00
William Chargin 011e9a755b Remove console.log that alerts us of hacks (#15)
Summary:
It produces a lot of noise, and we know about it.

wchargin-branch: remove-spurious-log
2018-02-16 16:28:17 -08:00
Dandelion Mané 22ddd15d78
Initial prototype of the cred explorer (#14)
Sets up an initial cred explorer that looks at Git commit data

- uses git commit data as generated by `experiments/01_commit_graph_dump.ipynb`
- displays a file explorer, which lets you navigate the file tree by expanding/collapsing dirs, and select a path via double clicking (changes background color)
- displays a user explorer, which shows a sorted list of authors and cred amounts for the selected file path

The commit-wrangling logic is in commitUtils.js and has typechecking (via flow) and some basic testing.
The frontend is built with react; setup was bootstrapped via create-react-app.

Test plan:

```
cd explorer;
yarn install; # get dependencies
yarn flow; # check that types check out
yarn test; # check that tests pass, then `q`
yarn start; # go to localhost:3000 and click around
```

expected behavior: there's a file explorer that shows TensorBoard file structure on the left. you can click the buttons to explore directory, and you can click files to select that path. on the right, it shows you the users that contributed to that directory and their cred for those commits.

note: the ui is very crude.
2018-02-16 15:35:22 -08:00
Dandelion Mané 91bdce2e5e
Frontend setup (#13)
* Initial infrastructure for sourcecred-explorer.

Setup npm, yarn, flow, jest using scaffolding from
create-react-app.

- used create-react-app to get the basic pieces
- added support for flow via instructions in the
create-react-app user guide
- added flow-typed so that flow+jest will work well

* Add some additional resources

* Add index.css

* Remove .DS_STORE per @wchargin's suggestion
2018-02-16 14:32:24 -08:00
Dandelion Mané 5b3b345630
Tweak commit_graph_dump & store sample data. (#12)
commit_graph_dump is modified to use camelCase variables
in the output data.json. Saved the data for TensorBoard
in explorer/src/data.json, where it's useful for debugging
/ iterating on the frontend.
2018-02-15 22:16:37 -08:00
William Chargin 03198b0c86 Check in experimental commit graph traversal (#8)
Summary:
This is a minimal script that will crawl the file-reachable commits in a
repository and dump statistics to a JSON file that can be further
analyzed interactively on a frontend.

Requires PyPI `gitpython` (and `matplotlib`, but this can be excised).
Requires `jupyter` to run.

(Mostly paired with @dandelionmane on 2018-02-08.)

wchargin-branch: experiment-commit-traversal
2018-02-15 16:11:38 -08:00
Dandelion Mané 84ad9d57bf
Split out useful & ethical. (#7) 2018-02-07 15:04:23 -08:00
William Chargin 65d711022e Make design goals grammatically consistent
Summary:
This changes the titles of two design goals so that they are all
adjectival: “SourceCred will be…” and not “SourceCred will have…”.

wchargin-branch: design-goals-grammar-list-consistent
2018-02-07 14:56:53 -08:00
Dandelion Mané 6bcc275c2d
Add overview.md (#6) 2018-02-05 00:14:15 -08:00
Dandelion Mané c9b2fcd21a
Simplify README, link to new docs 2018-02-05 00:09:14 -08:00
Dandelion Mané 0874d89b31
Enumerate design goals for SourceCred (#5)
* Add design goals

* Fix formatting on design.md

* It's also a protocol

* Fix formatting
2018-02-05 00:03:18 -08:00
Dandelion Mané 7dd9155833
Initial draft of the README (#1)
* Initial commit of README

* Fix some typos, etc

* More tweaks.

* More iterations on markdown, etc

* Take Jay's suggestion
2018-02-04 12:04:40 -08:00
Dandelion Mané 9cba0e9e21 Add LICENSE 2018-02-03 17:58:49 -08:00