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

EIP Linting Bot #3351

Merged
merged 52 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
a08ae0b
EIP Linting Bot
alita-moore Mar 9, 2021
3cff846
Delete .DS_Store
alita-moore Mar 9, 2021
c2f04d1
Delete .DS_Store
alita-moore Mar 9, 2021
3f6a720
Delete .DS_Store
alita-moore Mar 9, 2021
4c53f6c
remove build
alita-moore Mar 9, 2021
be99e3d
gitignore dist
alita-moore Mar 9, 2021
3e39b52
add npm install && npm run build
alita-moore Mar 9, 2021
fd8af11
Merge branch 'master' of https://github.com/alita-moore/EIPs
alita-moore Mar 9, 2021
1b167c3
fix script
alita-moore Mar 9, 2021
490a285
prettier run
alita-moore Mar 9, 2021
fde0ad3
Handful of minor cleanups, fixes, and tweaks.
MicahZoltu Mar 9, 2021
e5bbaae
Update .github/bot/action.yml
alita-moore Mar 9, 2021
4a702c8
Update .github/bot/tsconfig.json
alita-moore Mar 9, 2021
054994d
Update .github/bot/package.json
alita-moore Mar 9, 2021
2c6df3e
move to dev and cleanup packages
alita-moore Mar 9, 2021
5d75ceb
update readme
alita-moore Mar 9, 2021
719e4b4
make versions explicit
alita-moore Mar 9, 2021
beb39a1
Revert "Update .github/bot/tsconfig.json"
alita-moore Mar 9, 2021
aeb11ee
Merge pull request #3 from ethereum/micah
alita-moore Mar 9, 2021
e53bbe0
Update .github/bot/tsconfig.json
alita-moore Mar 9, 2021
81a3686
Merge branch 'master' of https://github.com/alita-moore/EIPs
alita-moore Mar 9, 2021
d173ca9
update to node 14
alita-moore Mar 9, 2021
2cbcf8e
target ES2015 because github
alita-moore Mar 9, 2021
7eeaece
remove log
alita-moore Mar 9, 2021
4e80957
compile at action run-time using github composites
alita-moore Mar 9, 2021
6f6e6ca
use GITHUB-TOKEN instead
alita-moore Mar 9, 2021
79e5d32
auto_merge_bot
alita-moore Mar 9, 2021
473a1f5
collapse action into one line
alita-moore Mar 9, 2021
5161e93
update to node 14 bc of composite action
alita-moore Mar 10, 2021
df82087
basic tests setup
alita-moore Mar 11, 2021
f34082d
absolute paths plus fixing jest and ts configs
alita-moore Mar 11, 2021
d6e1b2f
revert absolute build out debug system
alita-moore Mar 11, 2021
100ee55
fixing absolute paths 🙏
alita-moore Mar 11, 2021
6b2cb87
use repo
alita-moore Mar 14, 2021
9aee7e3
edit
alita-moore Mar 14, 2021
5994fe7
edit
alita-moore Mar 14, 2021
ceafd98
remove bot because in it's own repo now
alita-moore Mar 14, 2021
7d9006b
Update eip-1051.md
alita-moore Mar 14, 2021
cfe021e
fix issue with cd'ing into the action
alita-moore Mar 15, 2021
095804d
revert accidental change
alita-moore Mar 15, 2021
27a3e9f
Update .github/workflows/auto-merge-bot.yml
alita-moore Mar 15, 2021
69d9da9
continue on error
alita-moore Mar 15, 2021
260bc2b
Update auto-merge-bot.yml
alita-moore Mar 16, 2021
d8ef8b8
Update auto-merge-bot.yml
alita-moore Mar 16, 2021
e015a85
Update auto-merge-bot.yml
alita-moore Mar 16, 2021
20d973c
Update auto-merge-bot.yml
alita-moore Mar 16, 2021
495e651
Update auto-merge-bot.yml
alita-moore Mar 16, 2021
c667830
Update eip-1015.md
alita-moore Mar 16, 2021
c62ae34
Update eip-1015.md
alita-moore Mar 16, 2021
225e9ba
Update auto-merge-bot.yml
alita-moore Mar 24, 2021
05ee376
Update auto-merge-bot.yml
alita-moore Mar 24, 2021
3ff3e6a
Update .github/workflows/auto-merge-bot.yml
alita-moore Mar 27, 2021
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
88 changes: 88 additions & 0 deletions .github/bot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
6 changes: 6 additions & 0 deletions .github/bot/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "none",
"tabWidth": 2,
"semi": true,
"singleQuote": false
}
3 changes: 3 additions & 0 deletions .github/bot/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
139 changes: 139 additions & 0 deletions .github/bot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# EIP Linting Bot

This Github Actions integrated bot lints EIPs and provides feedback for authors, its goal is to catch simple problems and merge simple changes automatically.
# Usage

```yml
on: [pull_request]

jobs:
hello_world_job:
runs-on: ubuntu-latest
name: EIP Auto-Merge Bot
steps:
- name: auto-merge-bot
uses: ./.github/bot
id: auto-merge-bot
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
```

# Contributing
## Development Enviornment Setup
### Requirements
1) node package manager (npm)
2) Github Token
3) Forked Repo
4) node version manager (nvm)
alita-moore marked this conversation as resolved.
Show resolved Hide resolved

### Quick Start
1) Download your forked `EIPS` repo
2) Create a [Github Token](/creating-a-personal-access-token)
3) Create a PR in your forked repo doing anything, I recommend just editing a couple lines in an already existing EIPs
4) Create a .env variable in the root dir with the following information defined:

```
GITHUB_TOKEN = <YOUR GITHUB TOKEN>
NODE_ENV = development

PULL_NUMBER = <pull_number>
BASE_SHA = <base sha of the PR>
HEAD_SHA = <head sha of the PR>
REPO_OWNER_NAME = <your login>
REPO_NAME = EIPs
GITHUB_REPOSITORY = <your login>/EIPs
```
5) `npm run it`

### npm scripts

This repo uses ncc; ncc compiles the code into a single pure js file, and that makes it easier for github to execute. But you have to build and commit your changes.
alita-moore marked this conversation as resolved.
Show resolved Hide resolved

```
npm run watch // re-builds after each save
npm run build // re-builds
npm run it // runs the action using a basic development
```
### Troubleshooting
- <i>I make changes but nothing changes when I `npm run it`</i>
- This repo requires that the changes be compiled in a pure js distribution `dist/index.js`
- Try running `npm run build` and see if that helps
- If it does, make sure to keep `npm run watch` running in the background while you make changes, it'll re-compile whenever changes are made and make life easier
alita-moore marked this conversation as resolved.
Show resolved Hide resolved
- <i>When I run it, I'm getting unexplainable errors with my github requests.</i>
- Github limits the number requests from a given IP, this may be avoidable if you only use the `octokit` but a VPN also works just fine
## Code Style Guidelines (in no particular order)
This repo is a living repo, and it will grow with the EIP drafting and editing process. It's important to maintain code quality.

1) Define every type (including octokit)
2) Make clean and clear error messages
3) Avoid abstraction
4) Use [enums](https://www.sohamkamani.com/javascript/enums/) as much as possible
## Explanations of Style Guidenlines
A couple things to keep in mind if you end up making changes to this

#### 1. <ins>Define every type</ins>
Define every type, no `any` types. The time it takes to define a type now will save you or someone else later a lot of time. If you make assumptions about types, protect those assumptions (throw exception if they are false).

Sometimes [Octokit types](https://www.npmjs.com/package/@octokit/types) can be difficult to index, but it's important that whenever possible the types are defined and assumptions protected.

#### 2. <ins>Make clean and clear error messages</ins>
This bot has a single goal: catch simple mistakes automatically and save the editors time. Unclear errors means that it is more likely that

#### 3. <ins>Avoid Abstraction</ins>
Only abstract if necessary, keep things in one file where applicable; other examples of okay abstraction are types, regex, and methods used more than 3 times. Otherwise, it's often cleaner to just re-write things.
```javascript
// DON'T DO THIS
** src/lib.ts **
export const baz = () => "baz"

** src/foo.ts **
import { baz } from "./lib"
export const foo = () => baz();

** src/bar.ts **
import { baz } from "./lib"
export const bar = () => baz();

// DO THIS
** src/foo.ts **
const baz = () => "baz"
export const foo = () => baz();

** src/bar.ts **
const baz = () => "baz"
export const bar = () => baz();
```
#### 4. <ins>Always use enum when defining restricted string types</ins>
In short, enums make code easier to read, trace, and maintain.

But here's a brief info if you haven't worked with them before

```typescript
enum EnumFoo {
bar = "BAR",
baz = "BAZ"
}
type Foo = "BAR" | "BAZ"
```
Inline declaraion is maintained
```typescript
const foo: EnumFoo
const bar: Foo
// foo and bar both must be either "BAR" or "BAZ"
```
Use case is slightly different
```typescript
const foo: EnumFoo = EnumFoo.baz // you can't directly assign "BAZ"
const bar: Foo = "BAZ"
```
But comparisons are maintained
```typescript
// taking variables from above
("BAZ" === foo) === ("BAZ" === bar)
&&
("BAZ" === EnumFoo.baz) === ("BAZ" === "BAZ")
```
In addition to the above use case and string eradication it centralizes the strings to be matched so they can be easily changed. So, making life much easier if you wanted to change the names of statuses on an EIP.

# Contributors
- @alita-moore
9 changes: 9 additions & 0 deletions .github/bot/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: "Auto Merge EIP"
description: "A bot that lints EIP edits, finds common errors, and can auto-merge"

runs:
using: "node12"
main: "dist/index.js"
branding:
icon: 'code'
alita-moore marked this conversation as resolved.
Show resolved Hide resolved
color: 'blue'
Loading