Skip to content

Commit 3bab735

Browse files
feat: add Octoguide (#2220)
## PR Checklist - [x] Addresses an existing open issue: fixes #2219 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Adds [Octoguide](https://octo.guide) as a new `--add-octoguide` Block. This replaces two existing bot workflows: * `accessibility-alt-text-bot.yml`: which was previously always included by default * `compliance.yml`: which was `--add-pr-compliance` and enabled in the _everything_ preset OctoGuide is now enabled in the _common_ preset, with its `strict` config enabled with `--add-octoguide-strit` in _everything_. 🎁
1 parent 8f36f9c commit 3bab735

19 files changed

+551
-339
lines changed

.github/workflows/accessibility-alt-text-bot.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/compliance.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/octoguide.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
jobs:
2+
octoguide:
3+
if: ${{ !endsWith(github.actor, '[bot]') }}
4+
runs-on: ubuntu-latest
5+
steps:
6+
- uses: JoshuaKGoldberg/[email protected]
7+
with:
8+
config: strict
9+
github-token: ${{ secrets.GITHUB_TOKEN }}
10+
11+
name: OctoGuide
12+
13+
on:
14+
discussion:
15+
types:
16+
- created
17+
- edited
18+
discussion_comment:
19+
types:
20+
- created
21+
- deleted
22+
- edited
23+
issue_comment:
24+
types:
25+
- created
26+
- deleted
27+
- edited
28+
issues:
29+
types:
30+
- edited
31+
- opened
32+
pull_request_review_comment:
33+
types:
34+
- created
35+
- deleted
36+
- edited
37+
pull_request_target:
38+
types:
39+
- edited
40+
- opened
41+
42+
permissions:
43+
discussions: write
44+
issues: write
45+
pull-requests: write

cspell.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"joshuakgoldberg",
2222
"markdownlintignore",
2323
"mshick",
24-
"mtfoley",
2524
"npmjs",
25+
"octoguide",
2626
"stefanzweifel"
2727
]
2828
}

docs/Blocks.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ This table summarizes each block and which base levels they're included in:
3737
| MIT License | `--add-mit-license`, `--exclude-mit-license` | ✔️ || 💯 |
3838
| ncc | `--add-ncc`, `--exclude-ncc` | | | |
3939
| nvmrc | `--add-nvmrc`, `--exclude-nvmrc` | | | 💯 |
40+
| OctoGuide | `--add-octoguide`, `--exclude-octoguide` | || 💯 |
41+
| OctoGuide Strict | `--add-octoguide-strict`, `--exclude-octoguide-strict` | | | 💯 |
4042
| Package JSON | `--add-package-json`, `--exclude-package-json` | ✔️ || 💯 |
4143
| pnpm Dedupe | `--add-pnpm-dedupe`, `--exclude-pnpm-dedupe` | | | 💯 |
42-
| PR Compliance | `--add-pr-compliance`, `--exclude-pr-compliance` | | | 💯 |
4344
| Prettier | `--add-prettier`, `--exclude-prettier` | ✔️ || 💯 |
4445
| Prettier Plugin Curly | `--add-prettier-plugin-curly`, `--exclude-prettier-plugin-curly` | | | 💯 |
4546
| Prettier Plugin Package JSON | `--add-prettier-plugin-package-json`, `--exclude-prettier-plugin-package-json` | | | 💯 |
@@ -176,6 +177,7 @@ This is recommended for most users of `create-typescript-app` to start with.
176177

177178
- [Contributors](#contributors)
178179
- [Lint Knip](#lint-knip)
180+
- [OctoGuide](#octoguide)
179181
- [Releases](#releases)
180182
- [Renovate](#renovate)
181183
- [Testing](#testing)
@@ -195,6 +197,11 @@ Running Knip:
195197
pnpm run lint:knip
196198
```
197199

200+
### OctoGuide
201+
202+
[**OctoGuide**](https://octo.guide): checks that contributor activity on your GitHub repository aligns with common expectations of smoothly-running projects.
203+
It will automatically post friendly comments when contributors take actions you don’t want them to.
204+
198205
### Releases
199206

200207
[**release-it**](https://github.com/release-it/release-it): Generates changelogs, bumps the package version, and publishes to GitHub and npm based on [conventional commits](https://www.conventionalcommits.org).
@@ -235,7 +242,6 @@ pnpm run test run --coverage
235242
This level is for developers who are eager to get the maximum tooling benefits in a repository.
236243
Using the _"everything"_ level will gain you comprehensive, strict coverage of all sorts of repository issues, including auto-sorting of properties and strict ESLint configs.
237244

238-
- [Compliance](#compliance)
239245
- [Lint ESLint](#lint-eslint)
240246
- [Lint JSDoc](#lint-jsdoc)
241247
- [Lint JSON](#lint-json)
@@ -248,10 +254,7 @@ Using the _"everything"_ level will gain you comprehensive, strict coverage of a
248254
- [Lint Strict](#lint-strict)
249255
- [Lint Stylistic](#lint-stylistic)
250256
- [Lint YML](#lint-yml)
251-
252-
### Compliance
253-
254-
[**PR Compliance Action**](https://github.com/mtfoley/pr-compliance-action): Checks PRs for compliance such as addressing a linked issue and proper title formatting.
257+
- [OctoGuide Strict](#octoguide-strict)
255258

256259
### Lint ESLint
257260

@@ -320,3 +323,7 @@ Enables [typescript-eslint's stylistic configs](https://typescript-eslint.io/lin
320323
### Lint YML
321324

322325
[`eslint-plugin-yml`](https://ota-meshi.github.io/eslint-plugin-yml): Adds linting for `yaml` and `.yml` files, such as sorting keys.
326+
327+
### OctoGuide Strict
328+
329+
[**OctoGuide's Strict Config**](https://octo.guide/configs#rules-table): additionally enforces enforcing semantic pull request conventions.

src/blocks/actions/steps.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { IntakeDirectory } from "bingo-fs";
2+
import _ from "lodash";
3+
import { z } from "zod";
4+
5+
import { intakeFileAsYaml } from "../intake/intakeFileAsYaml.js";
6+
7+
export const zActionStep = z.intersection(
8+
z.object({
9+
env: z.record(z.string(), z.string()).optional(),
10+
if: z.string().optional(),
11+
with: z.record(z.string(), z.string()).optional(),
12+
}),
13+
z.union([z.object({ run: z.string() }), z.object({ uses: z.string() })]),
14+
);
15+
16+
export interface JobOrRunStep {
17+
env?: Record<string, string>;
18+
uses?: unknown;
19+
with?: Record<string, string>;
20+
}
21+
22+
export function intakeFileYamlSteps(
23+
files: IntakeDirectory,
24+
filePath: string[],
25+
ymlPath: string[],
26+
) {
27+
const actionYml = intakeFileAsYaml(files, filePath);
28+
if (!actionYml) {
29+
return undefined;
30+
}
31+
32+
const steps = _.get(actionYml, ymlPath) as JobOrRunStep[] | undefined;
33+
if (!steps || !Array.isArray(steps)) {
34+
return undefined;
35+
}
36+
37+
return steps;
38+
}

src/blocks/blockCodecov.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
import _ from "lodash";
21
import { z } from "zod";
32

43
import { base } from "../base.js";
54
import { resolveUses } from "./actions/resolveUses.js";
5+
import { intakeFileYamlSteps } from "./actions/steps.js";
66
import { blockGitHubApps } from "./blockGitHubApps.js";
77
import { blockREADME } from "./blockREADME.js";
88
import { blockRemoveFiles } from "./blockRemoveFiles.js";
99
import { blockVitest } from "./blockVitest.js";
10-
import { intakeFileAsYaml } from "./intake/intakeFileAsYaml.js";
11-
12-
interface JobStep {
13-
env?: Record<string, string>;
14-
uses?: unknown;
15-
}
1610

1711
export const blockCodecov = base.createBlock({
1812
about: {
@@ -22,14 +16,11 @@ export const blockCodecov = base.createBlock({
2216
env: z.record(z.string(), z.string()).optional(),
2317
},
2418
intake({ files }) {
25-
const ciYaml = intakeFileAsYaml(files, [".github", "workflows", "ci.yml"]);
26-
if (!ciYaml) {
27-
return undefined;
28-
}
29-
30-
const steps = _.get(ciYaml, ["jobs", "test", "steps"]) as
31-
| JobStep[]
32-
| undefined;
19+
const steps = intakeFileYamlSteps(
20+
files,
21+
[".github", "workflows", "ci.yml"],
22+
["jobs", "test", "steps"],
23+
);
3324
if (!steps) {
3425
return undefined;
3526
}

0 commit comments

Comments
 (0)