• Stars
    star
    112
  • Rank 301,133 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 4 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The bot which handles auto-merging your PRs

This is the bot which controls the workflow of Definitely Typed PRs.

Meta

TODO: Update these links for dtmergebot2

It is both a series of command line scripts which you can use to test different states, and an Azure Function App which handles incoming webhooks from the DefinitelyTyped repo.

This repo is deployed to Azure on every push to master. To ensure we can handle timeouts on older PRs, there is a GitHub Action which runs the bot every 6 hours against all open PRs, and has a bunch of useful flags for running manually too.

Setup

# Clone it
git clone https://github.com/DefinitelyTyped/dt-mergebot.git
cd dt-mergebot

# Deps
npm install

# Validate it works
npm test

How the app works

There are three main stages once the app has a PR number:

How the bot works

There is an Azure function in PR-Trigger which receives webhooks; this function's job is to find the PR number then it runs the above steps.

Running Locally

You probably don't need to do this. Use test to validate any change inside the src dir against integration tests.

However, you need to have a GitHub API access key in either: DT_BOT_AUTH_TOKEN, BOT_AUTH_TOKEN or AUTH_TOKEN. Ask Ryan for the bot's auth token (TypeScript team members: Look in the team OneNote). Don't run the bot under your own auth token as this will generate a bunch of spam from duplicate comments.

# Windows
set BOT_AUTH_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxx

# *nix
export BOT_AUTH_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Then to run locally you'll need to install the Azure Functions cli.

Development

# Build
npm run build

# Run the CLI to see what would happen to an existing PR
npm run single-info -- [PR_NUM]
# or
npm run single-info-debug -- [PR_NUM]

If you update any queries

Run this to update the generate types:

# Code-gen the schema
npm run graphql-schema

If you change project columns or labels

Run this to update the cached values:

# Regenerate src/_tests/cachedQueries.json
npm run update-test-data

Tests

# Run tests, TypeScript is transpiled at runtime
npm test

Most of the tests run against a fixtured PR, these are high level integration tests which store the PR info and then re-run the latter two phases of the app.

To create fixtures of a current PR:

# To create a fixture for PR 43161
npm run create-fixture -- 43161

Then you can work against these fixtures offline with:

# Watch mode for all tests
npm test -- --watch
# Just run fixtures for one PR
npm test -- --testNamePattern 44299

Run a test with the debugger:

node --inspect --inspect-brk ./node_modules/.bin/jest -i --runInBand --testNamePattern 44299

Then use "Attach to Process ID" to connect to that test runner

If your changes require re-creating all fixtures:

npm run update-all-fixtures

Be careful with this, because PRs may now be in a different state e.g. it's now merged and it used to be a specific weird state.

Running with real webhooks

You need a tool like ngrok to expose a URL from the webhooks section on DT.

Start two terminal sessions with:

  • yarn watch (for TypeScript changes)
  • yarn start (for the app)

Then start a third with your localhost router like ngrok:

  • ngrok http 7071

More Repositories

1

DefinitelyTyped

The repository for high quality TypeScript type definitions.
TypeScript
47,136
star
2

tsd

[DEPRECATED] TypeScript Definition manager for DefinitelyTyped
TypeScript
1,118
star
3

definitelytyped.github.io

Website content for definitelytyped.org
JavaScript
241
star
4

typescript-directory

A directory of TypeScript tools and learning resources
55
star
5

dts-critic

Checks a new dts against the JavaScript sources and tells you what problems it has
TypeScript
44
star
6

NugetAutomation

Automatically generate nuget packages for the DefinetlyTyped TypeScript definitions.
PowerShell
24
star
7

grunt-tsd

Grunt plugin to automate TSD and TypeScript definition related tasks
JavaScript
15
star
8

docs

DefinitelyTyped documentation-generator source + gh-pages
JavaScript
12
star
9

focus-dt

A simple command-line tool for running down PRs on DefinitelyTyped
TypeScript
12
star
10

dt-review-bot

TypeScript
11
star
11

demo-typescript-node-minimal

Minimal demo showing how to use TypeScript with node.js/npm modules
TypeScript
9
star
12

tsd-site

Source of the TSD website
CSS
8
star
13

types-publisher-watchdog

Report how long DefinitelyTyped's types-publisher takes to publish packages to npm
JavaScript
6
star
14

generator-deftyped

Yeoman generator for DefinitelyTyped typings - lets you quickly set up a typing directory with a minimal template.
TypeScript
5
star
15

definition-tester

DefinitelyTyped repository testing infrastructure
TypeScript
5
star
16

definition-header

DefinitelyTyped definition header utils
TypeScript
4
star
17

dt-review-tool

TypeScript
3
star
18

badges

Content for the DefinitelyTyped badges
3
star
19

typescript-bot-watchdog

Watch typescript-bot for recent activity on DefinitelyTyped
JavaScript
2
star
20

dt-retag

This repo has moved:
JavaScript
1
star