diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..f88e455b19 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{dme,dmf,dmm,dm}] +end_of_line = crlf +indent_style = tab + +[*.md] +trim_trailing_whitespace = false + +[*.py] +indent_style = space +indent_size = 4 + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..1718e43a3c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 + +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/autochangelog.yml b/.github/workflows/autochangelog.yml index 7953929ce5..e698a55feb 100644 --- a/.github/workflows/autochangelog.yml +++ b/.github/workflows/autochangelog.yml @@ -1,43 +1,41 @@ name: Autochangelog -on: - pull_request_target: - types: closed - branches: - - master - + +on: + pull_request_target: + types: closed + branches: + - master + env: - BASENAME: "polaris" + BASENAME: "polaris" jobs: - autochangelog: - name: Autochangelog - runs-on: ubuntu-16.04 - if: github.event.pull_request.merged == true - steps: - - uses: /actions/checkout@v2 - with: - ref: master - - name: Update repository to master - run: git pull "origin" master - - name: Ensure +x on CI directory - run: | - chmod -R +x ./tools/ci - - uses: actions/setup-python@v2 - with: - python-version: '3.7' - - name: Generate Changelog - run: | - pip install pyyaml - python tools/GenerateChangelog/ss13_autochangelog.py \ - html/changelogs \ - ${{ github.event.pull_request.number }} \ - "${{ github.event.pull_request.user.login }}" \ - "${{ github.event.pull_request.body }}" - python tools/GenerateChangelog/ss13_genchangelog.py \ - html/changelog.html \ - html/changelogs - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Automatic changelog generation for ${{ github.events.pull_request.number }} - branch: ${{ github.events.pull_request.base }} - commit_user_name: Autochangelog Bot + autochangelog: + name: Autochangelog + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + steps: + - uses: /actions/checkout@v2 + with: + ref: master + - name: Update repository to master + run: git pull "origin" master + - name: Ensure +x on CI directory + run: | + chmod -R +x ./tools/ci + - name: Generate Changelog + run: | + pip install pyyaml + python tools/GenerateChangelog/ss13_autochangelog.py \ + html/changelogs \ + ${{ github.event.pull_request.number }} \ + "${{ github.event.pull_request.user.login }}" \ + "${{ github.event.pull_request.body }}" + python tools/GenerateChangelog/ss13_genchangelog.py \ + html/changelog.html \ + html/changelogs + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Automatic changelog generation for ${{ github.events.pull_request.number }} + branch: ${{ github.events.pull_request.base }} + commit_user_name: Autochangelog Bot diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1312e71180..6daee401f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ env: jobs: file_tests: name: Run Linters - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Ensure +x on CI directory @@ -26,7 +26,7 @@ jobs: dreamchecker: name: DreamChecker - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -36,25 +36,25 @@ jobs: path: ~/SpacemanDMM key: ${{ runner.os }}-dreamchecker-${{ hashFiles('dependencies.sh')}} restore-keys: ${{ runner.os }}-dreamchecker - + - name: Install Dependencies run: | tools/ci/install_spaceman_dmm.sh dreamchecker - + - name: Run Linter id: linter run: | ~/dreamchecker > ${GITHUB_WORKSPACE}/output-annotations.txt 2>&1 - + - name: Annotate Linter uses: yogstation13/DreamAnnotate@v1 if: always() - with: + with: outputFile: output-annotations.txt unit_tests: name: Integration Tests - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Ensure +x on CI directory diff --git a/.github/workflows/enforce_lables.yml b/.github/workflows/enforce_lables.yml index c70b6ab672..b5e2d25198 100644 --- a/.github/workflows/enforce_lables.yml +++ b/.github/workflows/enforce_lables.yml @@ -8,4 +8,4 @@ jobs: steps: - uses: yogevbd/enforce-label-action@2.1.0 with: - BANNED_LABELS: "Input: Staff,Input: Author,Needs Announcement,Needs Changelog,Needs Documentation,Stale" \ No newline at end of file + BANNED_LABELS: "Input: Staff,Input: Author,Needs Announcement,Needs Changelog,Needs Documentation,Stale" diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000000..55c4a5843b --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "gbasood.byond-dm-language-support", + "platymuus.dm-langclient", + "EditorConfig.EditorConfig", + "eamodio.gitlens" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 5b262cca64..f90c2f78ee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,11 +1,45 @@ { - "editor.detectIndentation": false, - "editor.insertSpaces": false, - "editor.tabSize": 4, - "files.eol": "\r\n", - "gitblame.commitUrl": "https://github.com/polarisss13/polaris/commit/${hash}", - "gitlens.advanced.blame.customArguments": [ - "--ignore-revs-file", - ".git-blame-ignore-revs" - ] + "files.eol": "\n", + "files.encoding": "utf8", + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "files.trimTrailingWhitespace": true, + + "files.associations": { + "*.{dme,dmf,dmm,dm}": "dm", + }, + "[dm]": { + "files.eol": "\r\n", + "editor.detectIndentation": false, + "editor.insertSpaces": false + }, + + "[markdown]": { + "files.trimTrailingWhitespace": false + }, + + "[python]": { + "editor.detectIndentation": false, + "editor.insertSpaces": true, + "editor.tabSize": 4 + }, + + "[yaml]": { + "editor.detectIndentation": false, + "editor.insertSpaces": true, + "editor.tabSize": 2 + }, + + "workbench.editorAssociations": { + "*.dmi": "imagePreview.previewEditor" + }, + + "debug.onTaskErrors": "abort", + "dreammaker.objectTreePane": true, + "dreammaker.autoUpdate": true, + "dreammaker.tickOnCreate": true, + + "gitlens.advanced.blame.customArguments": [ + "--ignore-revs-file", ".git-blame-ignore-revs" + ] } diff --git a/tools/GenerateChangelog/ss13_autochangelog.py b/tools/GenerateChangelog/ss13_autochangelog.py index 0699dece02..e60ffaf264 100644 --- a/tools/GenerateChangelog/ss13_autochangelog.py +++ b/tools/GenerateChangelog/ss13_autochangelog.py @@ -26,32 +26,32 @@ all_changelog_entries = {} validPrefixes = { "fix": 'bugfix', - "fixes": 'bugfix', - "bugfix": 'bugfix', + "fixes": 'bugfix', + "bugfix": 'bugfix', "wip": 'wip', "tweak": 'tweak', - "tweaks": 'tweak', - "rsctweak": 'tweak', + "tweaks": 'tweak', + "rsctweak": 'tweak', "soundadd": 'soundadd', "sounddel": 'sounddel', "add": 'rscadd', "adds": 'rscadd', - "rscadd": 'rscadd', + "rscadd": 'rscadd', "del": 'rscdel', - "dels": 'rscdel', - "delete": 'rscdel', - "deletes": 'rscdel', - "rscdeldel": 'rscdel', - "imageadd": 'imageadd', + "dels": 'rscdel', + "delete": 'rscdel', + "deletes": 'rscdel', + "rscdeldel": 'rscdel', + "imageadd": 'imageadd', "imagedel": 'imagedel', "maptweak": 'maptweak', - "remap": 'maptweak', - "remaps": 'maptweak', + "remap": 'maptweak', + "remaps": 'maptweak', "typo": 'spellcheck', - "spellcheck": 'spellcheck', + "spellcheck": 'spellcheck', "experimental": 'experiment', - "experiments": 'experiment', - "experiment": 'experiment' + "experiments": 'experiment', + "experiment": 'experiment' } incltag = False @@ -62,60 +62,60 @@ new = 0 # Parse PR body for changelog entries print('Reading changelogs...') for line in args.pr_body.splitlines(): - print(f"Checking line '{line}'") - if line[:1] == "🆑": # Find the start of the changelog - print("Found opening :cl: tag") - if incltag == True: # If we're already reading logs, skip - continue - incltag = True - - # Fetch the author name - author = line[1:] - author.strip() - - if not len(author): - author = args.pr_author - - if author not in new_logs: - new_logs[author] = [] # Make array entry for the author - continue - - # If we hit a /cl, we're no longer reading logs - elif line == "/🆑": - print("Found closing /:cl: tag") - incltag = False + print(f"Checking line '{line}'") + if line[:1] == "🆑": # Find the start of the changelog + print("Found opening :cl: tag") + if incltag == True: # If we're already reading logs, skip + continue + incltag = True - # If we aren't reading logs, we don't care about any other line contents - if not incltag: - continue - - # Split line into tag (icon) and body (comment) - body = re.split("[ ,:-]", line, 1) - if len(body) != 2: - continue # If there's just one word, then it can't really be a changelog, now can it - - if body[0] in validPrefixes: - tag = validPrefixes[body[0]] - body = body[1].strip(" ,-:\t\n") - else: # If the tag is invalid, just default to rscadd - tag = "rscadd" - body = line.strip(" ,-:\t\n") - - new_logs[author].append(f" - {tag}: \"{body}\"") - new += 1 + # Fetch the author name + author = line[1:] + author.strip() + + if not len(author): + author = args.pr_author + + if author not in new_logs: + new_logs[author] = [] # Make array entry for the author + continue + + # If we hit a /cl, we're no longer reading logs + elif line == "/🆑": + print("Found closing /:cl: tag") + incltag = False + + # If we aren't reading logs, we don't care about any other line contents + if not incltag: + continue + + # Split line into tag (icon) and body (comment) + body = re.split("[ ,:-]", line, 1) + if len(body) != 2: + continue # If there's just one word, then it can't really be a changelog, now can it + + if body[0] in validPrefixes: + tag = validPrefixes[body[0]] + body = body[1].strip(" ,-:\t\n") + else: # If the tag is invalid, just default to rscadd + tag = "rscadd" + body = line.strip(" ,-:\t\n") + + new_logs[author].append(f" - {tag}: \"{body}\"") + new += 1 print(f"Writing {new} new changelog entries.") # f supposedly formats new into the var for auth in new_logs: - # Sanitize authors without changes - if not len(new_logs[auth]): - continue - - f = open(os.path.join(args.target_dir, f"{auth}{args.pr_numb}.yml"), 'w') - print(f"Writing changes to {f}") - f.write(f'author: {auth}\n') - f.write('delete-after: True\n') - f.write('changes:\n') - for log in new_logs[auth]: - f.write(f'{log}\n') - f.close() + # Sanitize authors without changes + if not len(new_logs[auth]): + continue + + f = open(os.path.join(args.target_dir, f"{auth}{args.pr_numb}.yml"), 'w') + print(f"Writing changes to {f}") + f.write(f'author: {auth}\n') + f.write('delete-after: True\n') + f.write('changes:\n') + for log in new_logs[auth]: + f.write(f'{log}\n') + f.close() diff --git a/tools/GenerateChangelog/ss13_genchangelog.py b/tools/GenerateChangelog/ss13_genchangelog.py index 16daa785d4..e597ac7a6c 100644 --- a/tools/GenerateChangelog/ss13_genchangelog.py +++ b/tools/GenerateChangelog/ss13_genchangelog.py @@ -1,215 +1,215 @@ -''' -Usage: - $ python ss13_genchangelog.py [--dry-run] html/changelog.html html/changelogs/ - -ss13_genchangelog.py - Generate changelog from YAML. - -Copyright 2013 Rob "N3X15" Nelson - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -''' - -from __future__ import print_function -import yaml, os, glob, sys, re, time, argparse -from datetime import datetime, date -from time import time - -today = date.today() - -dateformat = "%d %B %Y" - -opt = argparse.ArgumentParser() -opt.add_argument('-d', '--dry-run', dest='dryRun', default=False, action='store_true', help='Only parse changelogs and, if needed, the targetFile. (A .dry_changelog.yml will be output for debugging purposes.)') -opt.add_argument('targetFile', help='The HTML changelog we wish to update.') -opt.add_argument('ymlDir', help='The directory of YAML changelogs we will use.') - -args = opt.parse_args() - -all_changelog_entries = {} - -validPrefixes = [ - 'bugfix', - 'wip', - 'tweak', - 'soundadd', - 'sounddel', - 'rscdel', - 'rscadd', - 'imageadd', - 'imagedel', - 'maptweak', - 'spellcheck', - 'experiment' -] - -def dictToTuples(inp): - return [(k, v) for k, v in inp.items()] - -changelog_cache = os.path.join(args.ymlDir, '.all_changelog.yml') - -failed_cache_read = True -if os.path.isfile(changelog_cache): - try: - with open(changelog_cache) as f: - (_, all_changelog_entries) = yaml.load_all(f) - failed_cache_read = False - - # Convert old timestamps to newer format. - new_entries = {} - for _date in all_changelog_entries.keys(): - ty = type(_date).__name__ - # print(ty) - if ty in ['str', 'unicode']: - temp_data = all_changelog_entries[_date] - _date = datetime.strptime(_date, dateformat).date() - new_entries[_date] = temp_data - else: - new_entries[_date] = all_changelog_entries[_date] - all_changelog_entries = new_entries - except Exception as e: - print("Failed to read cache:") - print(e, file=sys.stderr) - -if args.dryRun: - changelog_cache = os.path.join(args.ymlDir, '.dry_changelog.yml') - -if failed_cache_read and os.path.isfile(args.targetFile): - from bs4 import BeautifulSoup - from bs4.element import NavigableString - print(' Generating cache...') - with open(args.targetFile, 'r') as f: - soup = BeautifulSoup(f) - for e in soup.find_all('div', {'class':'commit'}): - entry = {} - date = datetime.strptime(e.h2.string.strip(), dateformat).date() # key - for authorT in e.find_all('h3', {'class':'author'}): - author = authorT.string - # Strip suffix - if author.endswith('updated:'): - author = author[:-8] - author = author.strip() - - # Find