From fdc09d845573f5ca3b633c5c3bc426dd5a472651 Mon Sep 17 00:00:00 2001 From: scarf Date: Mon, 17 Jun 2024 07:55:33 +0900 Subject: [PATCH] docs: PR title generator & update contributing guideline (#4812) * fix: use relative path * feat: save `semantic.json` * chore: update scopes * ci: auto update mod list * docs: PR title generator * docs: remove `Summary` section was being unused and potentially confusing * docs: visible PR template checklist * docs: advice against commiting on `main` --------- Co-authored-by: nocontribute <> --- .github/pull_request_template.md | 67 ++++++----- .github/semantic.yml | 5 +- .github/workflows/autofix.yml | 1 + doc/src/assets/semantic.json | 89 ++++++++++++++ doc/src/components/Conventional.astro | 109 ++++++++++++++++++ ...guidelines.md => changelog_guidelines.mdx} | 19 ++- .../docs/en/contribute/contributing.md | 14 --- scripts/semantic.ts | 13 ++- 8 files changed, 267 insertions(+), 50 deletions(-) create mode 100644 doc/src/assets/semantic.json create mode 100644 doc/src/components/Conventional.astro rename doc/src/content/docs/en/contribute/{changelog_guidelines.md => changelog_guidelines.mdx} (90%) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 4db9f9c4ee54..1cc819c0d630 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -17,12 +17,49 @@ If you use GitHub's web editor to edit files, you shouldn't need to do this as t PR TITLE: Please follow Conventional Commits: https://www.conventionalcommits.org This makes it clear at a glance what the PR is about. For example: - feat(content, mods/DinoMod): new dinosaur species + feat(content,mods/DinoMod): new dinosaur species For more info on which categories are available, see: https://docs.cataclysmbn.org/en/contribute/changelog_guidelines/ If the PR is a port or adaptation of DDA content, please indicate it by adding "port" in PR title, like: feat(port): from DDA --> +## Checklist + + + +### Required + +- [ ] I wrote the PR title in [conventional commit format](https://docs.cataclysmbn.org/en/contribute/changelog_guidelines/). +- [ ] I ran the [code formatter](https://docs.cataclysmbn.org/en/contribute/contributing/#code-style). +- [ ] I linked any relevant issues using [github keyword syntax](https://docs.cataclysmbn.org/en/contribute/contributing/#pull-request-notes) so it can be closed automatically. +- [ ] I have [committed my changes to new branch that isn't `main`](https://docs.cataclysmbn.org/en/contribute/contributing/#make-your-changes) so it won't cause conflict when updating `main` branch later. + +### Optional + + + +- [ ] This PR ports commits from DDA or other cataclysm forks. + - [ ] I have attributed original authors in the commit messages adding [`Co-Authored-By`](https://docs.github.com/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors) in the commit message. + - [ ] I have linked the URL of original PR(s) in the description. +- [ ] This is a C++ PR that modifies JSON loading or behavior. + - [ ] I have documented the changes in the appropriate location in the `doc/` folder. + - [ ] If documentation for this feature does not exist, please write it or at least note its lack in PR description. + - [ ] New localizable fields need to be added to the `lang/bn_extract_json_strings.sh` script if it does not support them yet. + - [ ] If applicable, add checks on game load that would validate the loaded data. + - [ ] If it modifies format of save files, please add migration from the old format. +- [ ] This is a PR that modifies build process or code organization. + - [ ] Please document the changes in the appropriate location in the `doc/` folder. + - [ ] If documentation for this feature or process does not exist, please write it. + - [ ] If the change alters versions of software required to build or work with the game, please document it. + +- [ ] This is a PR that removes JSON entities. + - [ ] The removed JSON entities have new entries in `data/json/obsoletion/` folder or use some other migration process for existing saves. + + ## Purpose of change - -## Checklist - - diff --git a/.github/semantic.yml b/.github/semantic.yml index f4f44513051e..282fd5816e16 100644 --- a/.github/semantic.yml +++ b/.github/semantic.yml @@ -42,9 +42,9 @@ scopes: - mods/No_Ferals - mods/No_Fungi - mods/No_Rail_Stations + - mods/No_Wasps - mods/Old_Mutations - mods/Only_Wildlife - - mods/pride_flags - mods/RL_Classes - mods/StatsThroughSkills - mods/UDP_BN_FAKE_SNOW @@ -61,6 +61,7 @@ scopes: - mods/elevated_bridges - mods/fuji_mpp - mods/generic_guns + - mods/innawoods - mods/limit_fungal_growth - mods/magiclysm - mods/manualbionicinstall @@ -79,7 +80,9 @@ scopes: - mods/no_rivtech_guns - mods/no_scifi - mods/no_survivor_armor + - mods/no_zombify - mods/novitamins + - mods/pride_flags - mods/ruralbiome - mods/saveload_lua_test - mods/sees_player_hitbutton diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index dfd650ea3ca1..e692f044eba8 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -73,3 +73,4 @@ jobs: run: | deno lint deno test + deno run --allow-read --allow-write scripts/semantic.ts diff --git a/doc/src/assets/semantic.json b/doc/src/assets/semantic.json new file mode 100644 index 000000000000..e50d684b6e4a --- /dev/null +++ b/doc/src/assets/semantic.json @@ -0,0 +1,89 @@ +{ + "types": [ + "feat", + "fix", + "docs", + "style", + "refactor", + "perf", + "test", + "build", + "ci", + "chore", + "revert" + ], + "scopes": [ + "content", + "UI", + "i18n", + "balance", + "port", + "mods/DinoMod", + "mods/FujiStruct", + "mods/Graphical_Overmap", + "mods/Graphical_Overmap_Fujistruct", + "mods/Graphical_Overmap_More_Locations", + "mods/Graphical_Overmap_Urban_Development", + "mods/MMA", + "mods/Mundane_Zombies", + "mods/No_Acid_Zombies", + "mods/No_Anthills", + "mods/No_Bees", + "mods/No_Big_Zombies", + "mods/No_Blobs", + "mods/No_Explosive_Zombies", + "mods/No_Ferals", + "mods/No_Fungi", + "mods/No_Rail_Stations", + "mods/No_Wasps", + "mods/Old_Mutations", + "mods/Only_Wildlife", + "mods/RL_Classes", + "mods/StatsThroughSkills", + "mods/UDP_BN_FAKE_SNOW", + "mods/Zombie_Nightvision", + "mods/aftershock", + "mods/alt_map_key", + "mods/cbm_slots", + "mods/classic_zombies", + "mods/craftgp", + "mods/crazy_cataclysm", + "mods/crt_expansion", + "mods/desertpack", + "mods/disable_lifting", + "mods/elevated_bridges", + "mods/fuji_mpp", + "mods/generic_guns", + "mods/innawoods", + "mods/limit_fungal_growth", + "mods/magiclysm", + "mods/manualbionicinstall", + "mods/modular_turrets", + "mods/more_classes_scenarios", + "mods/my_sweet_cataclysm", + "mods/no_filthy_clothing", + "mods/no_flaming_weapons", + "mods/no_hope", + "mods/no_medieval_items", + "mods/no_mutagen", + "mods/no_npc_food", + "mods/no_olg_guns", + "mods/no_religious_Texts", + "mods/no_reviving_zombies", + "mods/no_rivtech_guns", + "mods/no_scifi", + "mods/no_survivor_armor", + "mods/no_zombify", + "mods/novitamins", + "mods/pride_flags", + "mods/ruralbiome", + "mods/saveload_lua_test", + "mods/sees_player_hitbutton", + "mods/sees_player_retro", + "mods/smart_house_remote_mod", + "mods/speedydex", + "mods/stats_through_kills", + "mods/teleportation_tech", + "mods/test_data" + ] +} diff --git a/doc/src/components/Conventional.astro b/doc/src/components/Conventional.astro new file mode 100644 index 000000000000..b3617669ed53 --- /dev/null +++ b/doc/src/components/Conventional.astro @@ -0,0 +1,109 @@ +--- +import json from "../assets/semantic.json" + +const generalScopes = json.scopes.filter((scope) => !scope.startsWith("mods/")) +const modScopes = json.scopes.filter((scope) => scope.startsWith("mods/")) +--- + + + + + +
+
+ + + + + + +
+ + + +
diff --git a/doc/src/content/docs/en/contribute/changelog_guidelines.md b/doc/src/content/docs/en/contribute/changelog_guidelines.mdx similarity index 90% rename from doc/src/content/docs/en/contribute/changelog_guidelines.md rename to doc/src/content/docs/en/contribute/changelog_guidelines.mdx index 40745957902f..484a7bd25cbf 100644 --- a/doc/src/content/docs/en/contribute/changelog_guidelines.md +++ b/doc/src/content/docs/en/contribute/changelog_guidelines.mdx @@ -2,12 +2,20 @@ title: Changelog Guidelines --- +import Conventional from "../../../../components/Conventional.astro" + +## PR Title Generator + + + +--- + PR title follows [Convensional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for easier changelog generation. The format is one of: ``` -: -(, , ...): +: +(, , ...): ``` For Example, a PR title can be: @@ -17,9 +25,10 @@ feat: add new mutation feat(content, port): port mutation description from DDA ``` -## Category -The category is the first word in the PR title. They specify the type of change being made. When in +## Type + +The type is the first word in the PR title. They specify the type of change being made. When in doubt, use `feat` for new features, and `fix` for bugfixes. Here are some frequently used categories: @@ -147,5 +156,5 @@ feat(balance): Give moose pelts instead of hides Example PR title: ``` -feat(content, port): game shop +feat(content,port): game shop ``` diff --git a/doc/src/content/docs/en/contribute/contributing.md b/doc/src/content/docs/en/contribute/contributing.md index 4595db80c2e9..33fc5c22ad78 100644 --- a/doc/src/content/docs/en/contribute/contributing.md +++ b/doc/src/content/docs/en/contribute/contributing.md @@ -253,20 +253,6 @@ for it, and will prevent anything that isn't completely ready from being merged It is not required to solve or reference an open issue to file a PR, however, if you do so, you need to explain the problem your PR is solving in full detail. -### All PRs should have a `"Summary"` line - -Summary is a one-line description of your change that will be extracted and added to the -[project changelog](../game/changelog/index.md) - -The format is: `SUMMARY: Category "description"` - -The categories to choose from are: Features, Content, Interface, Mods, Balance, Bugfixes, -Performance, Infrastructure, Build, I18N. - -Example: `SUMMARY: Content "Adds new mutation category 'Mouse'"` - -See the [Changelog Guidelines](./changelog_guidelines.md) for explanations of the categories. - ### Closing issues using keywords One more thing: when marking your PR as closing, fixing, or resolving issues, please include this diff --git a/scripts/semantic.ts b/scripts/semantic.ts index 39e9a9a1435e..c392d9018ec2 100644 --- a/scripts/semantic.ts +++ b/scripts/semantic.ts @@ -4,6 +4,7 @@ * 1. collects list of all mod IDs * 2. generate list of allowed scopes using mod IDs * 3. write to `.github/semantic.yaml` file + * 4. write to `doc/src/assets/semantic.json` file */ import type { Config } from "https://raw.githubusercontent.com/Ezard/semantic-prs/d6970fded0b5bcb1a2d55778e5be94a83453a897/functions/src/config.ts" import mod from "https://raw.githubusercontent.com/commitizen/conventional-commit-types/c3a9be4c73e47f2e8197de775f41d981701407fb/index.json" with { @@ -15,6 +16,7 @@ import { SafeParseSuccess, z } from "$zod/mod.ts" import * as YAML from "$std/yaml/stringify.ts" import type {} from "$ts-reset/entrypoints/filter-boolean.d.ts" import { outdent } from "$outdent/mod.ts" +import { resolve } from "$std/path/resolve.ts" type Modinfo = z.infer @@ -80,5 +82,14 @@ if (import.meta.main) { # Validate the PR title, and ignore all commit messages ${setting} ` - await Deno.writeTextFile(".github/semantic.yml", content) + + const rootPath = resolve(import.meta.dirname!, "..") + + await Promise.all([ + Deno.writeTextFile(resolve(rootPath, ".github/semantic.yml"), content), + Deno.writeTextFile( + resolve(rootPath, "doc/src/assets/semantic.json"), + JSON.stringify({ types: config.types, scopes: config.scopes }, null, 2) + "\n", + ), + ]) }