Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #129 from mozillach/bouncyball
Browse files Browse the repository at this point in the history
Bouncyball
  • Loading branch information
MichaelKohler committed Mar 31, 2019
2 parents bdf1d55 + 26beff0 commit 75df6ff
Show file tree
Hide file tree
Showing 89 changed files with 11,243 additions and 9,787 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ test
out
LICENSE
README.md
CODEOWNERS
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# EditorConfig is awesome: http://EditorConfig.org

root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 4

# C-style doc comments for eclint
block_comment_start = /*
block_comment = *
block_comment_end = */

[{package.json,.travis.yml,package-lock.json}]
indent_style = space
indent_size = 2
104 changes: 52 additions & 52 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
{
"env": {
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 8
},
"plugins": [
"node"
],
"rules": {
"valid-jsdoc": 1,
"indent": ["error", 4],
"prefer-const": 1,
"strict": 2,
"no-loop-func": 1,
"no-tabs": 2,
"no-eval": 1,
"prefer-arrow-callback": 2,
"no-use-before-define": 2,
"block-scoped-var": 2,
"no-extra-label": 2,
"no-implied-eval": 2,
"no-invalid-this": 2,
"yoda": 1,
"eol-last": 2,
"no-trailing-spaces": 2,
"one-var-declaration-per-line": 2,
"no-console": 0,
"node/no-unsupported-features": [
"error",
{
"ignores": [
"asyncAwait"
]
}
"env": {
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 8
},
"plugins": [
"node"
],
"semi": 2
},
"settings": {
"jsdoc": {
"additionalTagNames": {
"customTags": [
"async"
]
}
}
},
"extends": [
"eslint:recommended",
"plugin:node/recommended",
"plugin:array-func/recommended"
]
"rules": {
"valid-jsdoc": 1,
"indent": ["error", 4],
"prefer-const": 1,
"strict": 2,
"no-loop-func": 1,
"no-tabs": 2,
"no-eval": 1,
"prefer-arrow-callback": 2,
"no-use-before-define": 2,
"block-scoped-var": 2,
"no-extra-label": 2,
"no-implied-eval": 2,
"no-invalid-this": 2,
"yoda": 1,
"eol-last": 2,
"no-trailing-spaces": 2,
"one-var-declaration-per-line": 2,
"no-console": 0,
"node/no-unsupported-features": [
"error",
{
"ignores": [
"asyncAwait"
]
}
],
"semi": 2
},
"settings": {
"jsdoc": {
"additionalTagNames": {
"customTags": [
"async"
]
}
}
},
"extends": [
"eslint:recommended",
"plugin:node/recommended",
"plugin:array-func/recommended"
]
}
23 changes: 18 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
sudo: false
language: node_js
node_js: stable
before_install: npm install -g greenkeeper-lockfile
install: case $TRAVIS_BRANCH in greenkeeper*) npm i;; *) npm ci;; esac;
before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload
after_success: npm run coverage
cache:
directories:
- $HOME/.npm
stages:
- lint
- test
jobs:
include:
- stage: lint
script: npm run lint:js
name: "Lint JS"
- script: npm run lint:docker
name: "Lint Dockerfile"
- script: npm run lint:ec
name: "Lint for editorconfig"
- stage: test
script: npm run test:js
after_success: npm run coverage
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @freaktechnik
10 changes: 5 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------

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 http://mozilla.org/MPL/2.0/.
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 http://mozilla.org/MPL/2.0/.

If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
Expand All @@ -369,5 +369,5 @@ You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------

This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
154 changes: 35 additions & 119 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,147 +3,63 @@
[![Greenkeeper badge](https://badges.greenkeeper.io/mozillach/gh-projects-content-queue.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/mozillach/gh-projects-content-queue.svg?branch=master)](https://travis-ci.org/mozillach/gh-projects-content-queue) [![codecov](https://codecov.io/gh/mozillach/gh-projects-content-queue/branch/master/graph/badge.svg)](https://codecov.io/gh/mozillach/gh-projects-content-queue) [![docker hub](https://img.shields.io/docker/build/mozillach/content-queue.svg)](https://hub.docker.com/r/mozillach/content-queue/builds)

A Twitter content curation queue based on GitHub projects. Crowd sources tweet
A content curation queue based on GitHub projects. Originally built for tweeting. Crowd sources content
creation, improves collaboration and gives better control over content quality.

## Features

- Represent tweets as GitHub issues
- Supports replying and retweets
- Auto add issues to a column in a dedicated project board
- Auto tweet issues from a column in the dedicated board
- Validate issue content to be valid for tweeting
- Scheduling of tweets to an exact time
- Reaction squad system to ping people to react to a mention
- Auto tweeting tweets from a column in certain spacing (à la buffer)
- Reminder system for tweets that are due but not ready
- Auto create tweets for events on Mozilla Reps for a given query
- Auto create tweets for new discourse threads
- Represent tweets as GitHub issues
- Supports replying and retweets
- Auto add unhandled mentions as new issues
- Auto add issues to a column in a dedicated project board
- Auto post issues from a column in the dedicated board
- Validate issue content to be valid for posting
- Scheduling of posts to an exact time
- Reaction squad system to ping people to react to a mention
- Auto posting from a column in certain spacing (à la buffer)
- Reminder system for posts that are due but not ready
- Auto create posts for events from an ical feed
- Auto create posts for new discourse threads
- Auto create posts for posts in an Atom or RSS feed
- Mastodon support
- Supports replying, reposts and spoilers

### Planned
- Tweet pinning management
- See all the issues with the enhancement tag...

- Tweet pinning management (will probably happen for Mastodon first, since there's actually an API for that there)
- See all the issues with the enhancement tag...

## Set up a repo for use with this tool

### Requirements
- GitHub user auth token (will use that to create issues and comment on them etc.)

- GitHub user auth token (will use that to create issues and comment on them etc.)
- Log in with your GitHub user
- Go to your settings
- Go to "Personal access token" and go click on the "Generate new token" button
- Select the "public_repo" scope and if you are using it with an organization "read:org" and click save
- Add the resulting token to the `config.json` file (`githubToken` property)
- Twitter API credentials incl. OAuth tokens and secret (will tweet to this account)
- Create a new App through [apps.twitter.com](https://apps.twitter.com/)
- Add the resulting token to the `config.json` file (`accounts.github.token` property)
- Twitter API credentials incl. OAuth tokens and secret (will tweet to this account)
- Create a new App through [developer.twitter.com/apps](https://developer.twitter.com/apps)
- Apply for a developer account if you don't have one yet
- There is no need to define a redirect URL, just leave the field blank
- Copy the consumer key and secret to the fields in the `config.json` file
- Click on "Create access token"
- Copy the access token key and secret to the fields in the `config.json` file
- Node >= 7.7.1
- Mastodon OAuth access token (will toot to this account)
- In the following, replace `https://mastodoninstance.example.com` with the URL of your instance
- Create a new application at `https://mastodoninstance.example.com/settings/applications/new`
- Grant all read and write scopes. In theory the `read:accounts`, `read:statuses` and `write:statuses` should be enough at the moment, but this is untested
- Go to the application and copy the access token under "Your access token"
- The instance URL is probably `https://mastodoninstance.example.com/api/v1`
- Add both the access token and the instance URL to the fields in the `config.json` file
- Node >= 8.0.0

### Issue template
An issue template is generated in the repository if none is found. See the documentation for GitHub issue templates.
Issue templates are generated in the repository. See the documentation for GitHub issue templates.

### Configuration
#### By file
The configuration is defined with JSON in the file `config.json` in the root directory of the project. This file does not exist by default. It is validated against the [config schema](templates/config.schema.json). The default config can be found in [`config.default.json`](config.default.json). Note that this is not a working config, as invalid values are provided for the authentication credentials for Twitter and GitHub. You can copy the [`config.default.json`](config.default.json) to `config.json` and edit it.

You could also provide the configuartion via the environment, but if a config.json is present it will be preferred.

#### By environment variables
The `CQ_CONFIG` environment vairable should be set to a stringified version of the JSON configuration.

#### Basic anatomy
The configuration consists of an array of repositories to run the tool on. Each repository has its entirely separate configuration.

#### Required properties
##### githubToken
Token to the GitHub account the service should run as.

##### repo
Repository the tool should run on. Should be of the form of "username/repository".

##### twitter
Object with four properties:
- `consumer_key`: Twitter API consumer key as string
- `consumer_secret`: Twitter API consumer secret as string
- `access_token_key`: Twitter API access token (you may have to generate this)
- `access_token_secret`: Twitter API access token secret (you may have to generate this)

##### projectName
Name of the GitHub project board to run the tool in.

#### Additional properties

##### sources
Sources to run on the board. You need to declare these, else none are loaded. The sources are in an array of objects, where each object defines the source and its parameters. This means you can have multiple instances of one sources, though the same source should never run multiple times on the same column. The tool currently doesn't check that.

There are currently seven stable sources:
- **issues**: Adds open issues to an ideas column.
- **mentions**: Opens issues for new mentions on Twitter.
- **tweeting**: Tweets valid issues from the To tweet column and moves them to tweeted and closes them.
- **squad**: Assigns users from a list to new issues in a column.
- **events**: Opens new issues for new events on reps.mozilla.org with a specific query.
- **reminder**: Reminds assignees and people following an issue when it's due but not ready.
- **discourse**: Opens an issue for each new discourse thread in a given discourse category.

###### type
A string describing the type of the source. Should be one of the available source names.

###### columns
Specifies the column names of columns the source should use. Is a key-value map with the key being a column identifier from the source and the value the name of the column.

###### squad
List for users that should handle new mentions for the **squad** source. The array should hold usernames of all users to cycle through. Is preferred over the `squadTeam` config.

###### squadTeam
Name of an organization team that should be the source to the reaction squad for the **squad** source. Should be the name of the team.

###### schedule
A schedule of slots for the **tweeting** source. Per slot one tweet is sent out, including scheduled tweets. Takes an array of strings, containing the desired time in the format of `hh:mm`. The field is fully optional. If not provided tweets are instantly sent out unless scheduled. This does not use the timezone of the `schedulingTime` and is in UTC+0.

###### discourse properties
The **discourse** source requires four configuration keys:
- `forum`: Slug of the category to watch threads of.
- `apiUrl`: URL of the API of the discourse instance.
- `apiKey`: API Key for the discourse instance.
- `username`: Username for the discourse instance.

###### query
The search query for the **events** source.

##### labels
Adjust the names of the labels the tool uses. Built in label identifiers:
- `retweet`
- `ready`
- `invalid`

##### schedulingTime
Define the local time zone and the date format for scheduling Tweets. An object with two properties.

###### format
Date format for scheduling tweets.

**Placeholders**:
- `YYYY`: Four digit representation of the year
- `MM`: Two digit representation of the month
- `DD`: Two digit representation of the day of the month
- `HH`: Two digit 24 hours representation of the hour
- `mm`: Two digit representation of the minute in the hour

**Dividers**:
- `.`
- `:`
- ` `
- `T`
- `Z`
- `-`

###### timezone
Integer offset from UTC the tool should treat dates in issues as.

#### Example
See [config.default.json](./config.default.json)
[configuration.md](docs/configuration.md)

### Run
#### The tool
Expand Down
Loading

0 comments on commit 75df6ff

Please sign in to comment.