Skip to content

Commit

Permalink
Merge pull request #10 from JoshuaKGoldberg/issue-pr-comments
Browse files Browse the repository at this point in the history
feat: comment on issues and PRs
  • Loading branch information
JoshuaKGoldberg authored May 10, 2023
2 parents a16f3c6 + 7453dae commit 63cb7ba
Show file tree
Hide file tree
Showing 20 changed files with 2,312 additions and 1,334 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ module.exports = {
},
extends: ["plugin:jsonc/recommended-with-json"],
},
{
files: "**/*.test.ts",
rules: {
// These on-by-default rules aren't useful in test files.
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
},
},
{
files: ["**/*.{yml,yaml}"],
parser: "yaml-eslint-parser",
Expand Down Expand Up @@ -77,14 +85,17 @@ module.exports = {
"@typescript-eslint",
"deprecation",
"import",
"no-only-tests",
"regexp",
"simple-import-sort",
"typescript-sort-keys",
"vitest",
],
root: true,
rules: {
// These off-by-default rules work well for this repo and we like them on.
"import/extensions": ["error", "ignorePackages"],
"no-only-tests/no-only-tests": "error",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error",

Expand Down
30 changes: 27 additions & 3 deletions .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Each should be shown in VS Code, and can be run manually on the command-line:

## Testing Locally

You can run this locally by providing `GITHUB_REPOSITORY` and `GITHUB_TOKEN` environment variables.
You can run this locally by running `lib/index.js`.
Be sure to `pnpm build` before running.

In one (background/secondary) terminal:
Expand All @@ -63,8 +63,32 @@ In one (background/secondary) terminal:
pnpm build -w
```

In your primary terminal:
In your primary terminal, run `lib/index.js` with the following environment variables:

- `GITHUB_REPOSITORY`: Locator for the repository to run against, in a format like `Owner/repository`.
- `GITHUB_TOKEN`: Your GitHub auth token, to avoid API throttling
- `LOCAL_TESTING`: Indicates to log comments that _would_ be creating to the console, instead of actually POSTing them to GitHub

For example:

```shell
GITHUB_REPOSITORY=YourUsername/your-repository-name GITHUB_TOKEN=$(gh auth token) LOCAL_TESTING=true node lib/index.js
```

## Unit Tests

[Vitest](https://vitest.dev) is used for some small tests.
You can run it locally on the command-line:

```shell
pnpm run test
```

Add the `--coverage` flag to compute test coverage and place reports in the `coverage/` directory:

```shell
GITHUB_REPOSITORY=JoshuaKGoldberg/template-typescript-node-package GITHUB_TOKEN=$(gh auth token) node lib/index.js
pnpm run test --coverage
```

Note that [console-fail-test](https://github.com/JoshuaKGoldberg/console-fail-test) is enabled for all test runs.
Calls to `console.log`, `console.warn`, and other console methods will cause a test to fail.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare
- run: pnpm build
- run: node ./lib/index.js

name: Build

Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare
- run: pnpm run test --coverage
- name: Codecov
uses: codecov/codecov-action@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

name: Test

on:
pull_request: ~

push:
branches:
- main
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"configurations": [
{
"args": ["run", "${relativeFile}"],
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"name": "Debug Current Test File",
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"request": "launch",
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"smartStep": true,
"type": "node"
}
],
"version": "0.2.0"
}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<!-- prettier-ignore-end -->
</a>
<a href="https://codecov.io/gh/JoshuaKGoldberg/all-contributors-auto-action" target="_blank">
<img alt="Codecov Test Coverage" src="https://codecov.io/gh/JoshuaKGoldberg/all-contributors-auto-action/branch/main/graph/badge.svg?token=eVIFY4MhfQ"/>
</a>
<a href="https://github.com/JoshuaKGoldberg/all-contributors-auto-action/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank">
<img alt="Contributor Covenant" src="https://img.shields.io/badge/code_of_conduct-enforced-21bb42" />
</a>
Expand All @@ -28,13 +31,13 @@
This action will:

1. Ask [`all-contributors-for-repository`](https://github.com/JoshuaKGoldberg/all-contributors-for-repository) to collect the current repository's contributors
2. Run [`all-contributors add`](https://allcontributors.org/docs/en/cli/usage#all-contributors-add) to add them to the current repository
2. Post [`@all-contributors add` bot comments](https://allcontributors.org/docs/en/bot/usage) in the newest issues and PRs for each contributor

> **Warning**
> This tool only sees contributions that can be detected from the last 500 events in GitHub's API.
> Don't forget to manually add in other forms of contributions!
For example, the following job will run on every push to `main`, then check in changes:
For example, the following job will run on every push to `main`:

```yml
# .github/workflows/contributors.yml
Expand All @@ -44,7 +47,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: JoshuaKGoldberg/all-contributors-auto-action@v0.1.0
- uses: stefanzweifel/git-auto-commit-action@v4

name: Contributors

Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
],
"words": [
"allcontributors",
"boop",
"Codecov",
"codespace",
"commitlint",
Expand Down
1 change: 1 addition & 0 deletions knip.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://unpkg.com/knip@next/schema.json",
"entry": "src/index.ts!",
"ignoreBinaries": ["dedupe"],
"project": "src/**/*.ts!"
}
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"lint": "eslint . --max-warnings 0 --report-unused-disable-directives",
"lint:knip": "knip",
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line",
"lint:package": "npmPkgJsonLint .",
"lint:packages": "pnpm-deduplicate --list",
"lint:package": "npmPkgJsonLint ./package.json",
"lint:packages": "pnpm dedupe --check",
"lint:spelling": "cspell \"**\" \".github/**/*\"",
"prepare": "husky install",
"should-semantic-release": "should-semantic-release --verbose"
"test": "vitest"
},
"lint-staged": {
"*": "prettier --ignore-unknown --write"
Expand All @@ -37,14 +37,15 @@
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@types/node": "^18.16.3",
"all-contributors-for-repository": "^0.0.5",
"execa": "^7.1.1"
"all-contributors-for-repository": "^0.0.8"
},
"devDependencies": {
"@types/eslint": "^8.21.1",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"@vercel/ncc": "^0.36.1",
"@vitest/coverage-istanbul": "^0.31.0",
"console-fail-test": "^0.2.1",
"cspell": "^6.19.2",
"eslint": "^8.32.0",
"eslint-config-prettier": "^8.6.0",
Expand All @@ -53,9 +54,11 @@
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsonc": "^2.6.0",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-regexp": "^1.12.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-typescript-sort-keys": "^2.1.0",
"eslint-plugin-vitest": "^0.2.2",
"eslint-plugin-yml": "^1.5.0",
"husky": "^8.0.3",
"jsonc-eslint-parser": "^2.1.0",
Expand All @@ -65,15 +68,14 @@
"markdownlint-cli": "^0.33.0",
"npm-package-json-lint": "^6.4.0",
"npm-package-json-lint-config-default": "^5.0.0",
"pnpm-deduplicate": "^0.4.1",
"prettier": "^2.8.3",
"prettier-plugin-packagejson": "^2.4.2",
"sentences-per-line": "^0.2.1",
"should-semantic-release": "^0.1.0",
"typescript": "^5.0.0",
"vitest": "^0.31.0",
"yaml-eslint-parser": "^1.2.0"
},
"packageManager": "pnpm@7.32.2",
"packageManager": "pnpm@8.3.1",
"engines": {
"node": ">=18"
}
Expand Down
Loading

0 comments on commit 63cb7ba

Please sign in to comment.