From 62c8820bf715bc188a1a392e415307ac437d109c Mon Sep 17 00:00:00 2001 From: Mikhail Dzianishchyts Date: Sat, 18 Jan 2025 14:57:59 +0300 Subject: [PATCH] Changelog Generation | BandaStation (#1012) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Что этот PR делает Изменяет пути к чейнджлогам в системе ТГ. Кастомизирует окно чейнджлога. По результатам бурного обсуждения в дисе стало ясно, что у системы чейнджлога есть 2 основные проблемы: 1. Изменение чейнджлога в индексированном архивном файле может приводить к конфликтам при мерже апстрима. 2. Изменение чейнджлога происходит с созданием дополнительного коммита. Проблема 1 решается этим ПРом, поскольку чейнджлог лежит в поддиректории. Проблема 2 может решиться наличием отдельной ветки и ленивыми HTTP запросами, но она мне не кажется существенной, особенно с учетом того, что коммиты ТГ уже переносятся в наш мастер `как-есть` и чейнджлог коммиты все равно останутся. ## Тестирование https://github.com/m-dzianishchyts/BandaStation/commit/b15f7eb7f35753297ce3274c94f3ee7f25a40295 https://github.com/m-dzianishchyts/BandaStation/commit/9b6bb0b306286800bafe141b4ad22eeacc496df5
Картинко

![image](https://github.com/user-attachments/assets/e98a258a-5db6-4fec-8258-22bd96fd0b1e)

## Summary by Sourcery Update changelog paths and customize the changelog window. New Features: - Add a new changelog interface for BandaStation. Build: - Update changelog compilation path. CI: - Update CI workflows to use the new changelog path and always run the changelog generation job when a PR is merged. --------- Co-authored-by: Gaxeer <44334376+Gaxeer@users.noreply.github.com> --- .github/workflows/auto_changelog.yml | 2 +- .github/workflows/compile_changelogs.yml | 4 +- .../bandastation/archive/2025-01.yml | 3 + modular_bandastation/changelog/_changelog.dm | 8 + modular_bandastation/changelog/_changelog.dme | 4 + .../changelog/code/changelog.dm | 15 + .../changelog/code/changelog_item.dm | 3 + modular_bandastation/modular_bandastation.dme | 1 + .../tgui/interfaces/ChangelogBandaStation.jsx | 388 ++++++++++++++++++ tools/ci/check_changelogs.sh | 2 +- tools/makeChangelog.bat | 2 +- tools/pull_request_hooks/autoChangelog.js | 2 +- tools/ss13_genchangelog.py | 2 +- 13 files changed, 429 insertions(+), 7 deletions(-) create mode 100644 html/changelogs/bandastation/archive/2025-01.yml create mode 100644 modular_bandastation/changelog/_changelog.dm create mode 100644 modular_bandastation/changelog/_changelog.dme create mode 100644 modular_bandastation/changelog/code/changelog.dm create mode 100644 modular_bandastation/changelog/code/changelog_item.dm create mode 100644 tgui/packages/tgui/interfaces/ChangelogBandaStation.jsx diff --git a/.github/workflows/auto_changelog.yml b/.github/workflows/auto_changelog.yml index c1fcf82e76890..45303ec0c92af 100644 --- a/.github/workflows/auto_changelog.yml +++ b/.github/workflows/auto_changelog.yml @@ -11,7 +11,7 @@ permissions: jobs: auto_changelog: runs-on: ubuntu-latest - if: github.event.pull_request.merged == true && github.head_ref != 'merge-upstream' + if: github.event.pull_request.merged == true steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/compile_changelogs.yml b/.github/workflows/compile_changelogs.yml index aaf01306a806e..902791316452c 100644 --- a/.github/workflows/compile_changelogs.yml +++ b/.github/workflows/compile_changelogs.yml @@ -44,7 +44,7 @@ jobs: - name: "Compile" if: steps.value_holder.outputs.ACTIONS_ENABLED run: | - python tools/ss13_genchangelog.py html/changelogs + python tools/ss13_genchangelog.py html/changelogs/bandastation - name: Commit if: steps.value_holder.outputs.ACTIONS_ENABLED @@ -52,7 +52,7 @@ jobs: git config --local user.name "tgstation-ci[bot]" git config --local user.email "179393467+tgstation-ci[bot]@users.noreply.github.com" git pull origin master - git add html/changelogs + git add html/changelogs/bandastation git commit -m "Automatic changelog compile [ci skip]" -a || true - name: Generate App Token diff --git a/html/changelogs/bandastation/archive/2025-01.yml b/html/changelogs/bandastation/archive/2025-01.yml new file mode 100644 index 0000000000000..beec62969a6a8 --- /dev/null +++ b/html/changelogs/bandastation/archive/2025-01.yml @@ -0,0 +1,3 @@ +2025-01-18: + AyIong: + - bugfix: Лейтджоин ИИ, больше не будут смотреть на лобби арт и общаться IC diff --git a/modular_bandastation/changelog/_changelog.dm b/modular_bandastation/changelog/_changelog.dm new file mode 100644 index 0000000000000..b9a97b6aa02e6 --- /dev/null +++ b/modular_bandastation/changelog/_changelog.dm @@ -0,0 +1,8 @@ +/datum/modpack/changelog + name = "Чейнджлог" + desc = "Кастомизация чейнджлога BandaStation." + author = "Maxiemar" + +/datum/modpack/changelog/initialize() + var/latest_changelog = file("[global.config.directory]/../html/changelogs/bandastation/archive/" + time2text(world.timeofday, "YYYY-MM") + ".yml") + GLOB.changelog_hash = fexists(latest_changelog) ? md5(latest_changelog) : 0 //for telling if the changelog has changed recently diff --git a/modular_bandastation/changelog/_changelog.dme b/modular_bandastation/changelog/_changelog.dme new file mode 100644 index 0000000000000..9e591e9595295 --- /dev/null +++ b/modular_bandastation/changelog/_changelog.dme @@ -0,0 +1,4 @@ +#include "_changelog.dm" + +#include "code/changelog.dm" +#include "code/changelog_item.dm" diff --git a/modular_bandastation/changelog/code/changelog.dm b/modular_bandastation/changelog/code/changelog.dm new file mode 100644 index 0000000000000..5a2f97cdef778 --- /dev/null +++ b/modular_bandastation/changelog/code/changelog.dm @@ -0,0 +1,15 @@ +/datum/changelog/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if (!ui) + ui = new(user, src, "ChangelogBandaStation") + ui.open() + +/datum/changelog/ui_static_data() + var/list/data = list("dates" = list()) + var/static/regex/yml_regex = regex(@"\.yml", "g") + + for(var/archive_file in sort_list(flist("html/changelogs/bandastation/archive/"))) + var/archive_date = yml_regex.Replace(archive_file, "") + data["dates"] = list(archive_date) + data["dates"] + + return data diff --git a/modular_bandastation/changelog/code/changelog_item.dm b/modular_bandastation/changelog/code/changelog_item.dm new file mode 100644 index 0000000000000..266ac6cedb4d6 --- /dev/null +++ b/modular_bandastation/changelog/code/changelog_item.dm @@ -0,0 +1,3 @@ +/datum/asset/changelog_item/New(date) + item_filename = SANITIZE_FILENAME("[date].yml") + SSassets.transport.register_asset(item_filename, file("html/changelogs/bandastation/archive/" + item_filename)) diff --git a/modular_bandastation/modular_bandastation.dme b/modular_bandastation/modular_bandastation.dme index 057aa3a0243dd..f171704432e88 100644 --- a/modular_bandastation/modular_bandastation.dme +++ b/modular_bandastation/modular_bandastation.dme @@ -16,6 +16,7 @@ #include "autohiss/_autohiss.dme" #include "balance/_balance.dme" #include "barsigns/_barsigns.dme" +#include "changelog/_changelog.dme" #include "chat_badges/_chat_badges.dme" #include "communication/_communication.dme" #include "customization/_customization.dme" diff --git a/tgui/packages/tgui/interfaces/ChangelogBandaStation.jsx b/tgui/packages/tgui/interfaces/ChangelogBandaStation.jsx new file mode 100644 index 0000000000000..c9f84a1e04538 --- /dev/null +++ b/tgui/packages/tgui/interfaces/ChangelogBandaStation.jsx @@ -0,0 +1,388 @@ +import dateformat from 'dateformat'; +import yaml from 'js-yaml'; +import { Component, Fragment } from 'react'; +import { + Box, + Button, + Dropdown, + Icon, + Section, + Stack, + Table, +} from 'tgui-core/components'; +import { classes } from 'tgui-core/react'; + +import { resolveAsset } from '../assets'; +import { useBackend } from '../backend'; +import { Window } from '../layouts'; + +const icons = { + add: { icon: 'check-circle', color: 'green' }, + admin: { icon: 'user-shield', color: 'purple' }, + balance: { icon: 'balance-scale-right', color: 'yellow' }, + bugfix: { icon: 'bug', color: 'green' }, + code_imp: { icon: 'code', color: 'green' }, + config: { icon: 'cogs', color: 'purple' }, + expansion: { icon: 'check-circle', color: 'green' }, + experiment: { icon: 'radiation', color: 'yellow' }, + image: { icon: 'image', color: 'green' }, + imageadd: { icon: 'tg-image-plus', color: 'green' }, + imagedel: { icon: 'tg-image-minus', color: 'red' }, + qol: { icon: 'hand-holding-heart', color: 'green' }, + refactor: { icon: 'tools', color: 'green' }, + rscadd: { icon: 'check-circle', color: 'green' }, + rscdel: { icon: 'times-circle', color: 'red' }, + server: { icon: 'server', color: 'purple' }, + sound: { icon: 'volume-high', color: 'green' }, + soundadd: { icon: 'tg-sound-plus', color: 'green' }, + sounddel: { icon: 'tg-sound-minus', color: 'red' }, + spellcheck: { icon: 'spell-check', color: 'green' }, + map: { icon: 'map', color: 'green' }, + tgs: { icon: 'toolbox', color: 'purple' }, + tweak: { icon: 'wrench', color: 'green' }, + unknown: { icon: 'info-circle', color: 'label' }, + wip: { icon: 'hammer', color: 'orange' }, +}; + +export class ChangelogBandaStation extends Component { + constructor(props) { + super(props); + this.state = { + data: 'Loading changelog data...', + selectedDate: '', + selectedIndex: 0, + }; + this.dateChoices = []; + } + + setData(data) { + this.setState({ data }); + } + + setSelectedDate(selectedDate) { + this.setState({ selectedDate }); + } + + setSelectedIndex(selectedIndex) { + this.setState({ selectedIndex }); + } + + getData = (date, attemptNumber = 1) => { + const { act } = useBackend(); + const self = this; + const maxAttempts = 6; + + if (attemptNumber > maxAttempts) { + return this.setData( + 'Failed to load data after ' + maxAttempts + ' attempts', + ); + } + + act('get_month', { date }); + + fetch(resolveAsset(date + '.yml')).then(async (changelogData) => { + const result = await changelogData.text(); + const errorRegex = /^Cannot find/; + + if (errorRegex.test(result)) { + const timeout = 50 + attemptNumber * 50; + + self.setData('Loading changelog data' + '.'.repeat(attemptNumber + 3)); + setTimeout(() => { + self.getData(date, attemptNumber + 1); + }, timeout); + } else { + self.setData(yaml.load(result, { schema: yaml.CORE_SCHEMA })); + } + }); + }; + + componentDidMount() { + const { + data: { dates = [] }, + } = useBackend(); + + if (dates) { + dates.forEach((date) => + this.dateChoices.push(dateformat(date, 'mmmm yyyy', true)), + ); + this.setSelectedDate(this.dateChoices[0]); + this.getData(dates[0]); + } + } + + render() { + const { data, selectedDate, selectedIndex } = this.state; + const { + data: { dates }, + } = useBackend(); + const { dateChoices } = this; + + const dateDropdown = dateChoices.length > 0 && ( + + +