Skip to content

Commit

Permalink
Random things on my todo list, mostly github related (#607)
Browse files Browse the repository at this point in the history
* Makes the Haunted Eight Ball work(?) (better?) (#78196)

From my recollection the haunted eight ball has been "broken" for like 3
or 4 years. So uh... yea

Makes the Haunted Eight Ball actually, like, work good.

- Fixes all votes counting to 0

- Fixes votes being reported as their vote key and not a flavor message

- Allows ghosts to change their vote

- General small code cleanup

- Calls parent in topic so stat panel clicks work

- Fixes #41718 , again? If it was actually ever fixed, not sure

:cl: Melbert
qol: Haunted 8-ball no longer requires the ghost orbit the petitioner to
submit votes
qol: Haunted 8-ball ghosts can now change their vote after submitting it
fix: Haunted 8-ball no longer always reports "yes"
fix: Haunted 8-ball no longer always reports default "yes", "no", or
"maybe" and now gives a proper eight ball response
fix: Haunted 8-ball can be picked up via the stat panel
/:cl:

* Replace DreamAnnotate action with a python script (#78225)

This PR removes the "Annotate Lints" job step and merges it with the
"Run Linters" step above. To achieve this, I wrote a python script that
should be identical to the action. I even added the ability to read the
output from a file to the script if we ever needed that, but I decided
to have the job step pipe the output into the script instead.

It always bugged me a bit that we had to check the results for a
separate step if we wanted to see the linter results for dm code. I also
noticed a few people getting confused as to why their CI failed on
linters.

Turns out that the action is just a few lines that match the
dreamchecker output and reformat it to a format that GitHub can annotate
code with. It's so brain dead simple that it shouldn't need to be a
whole new step, and for the previous two reasons.

not playerfacing

* Split Run Linters step into multiple steps (#78265)

Splits the big "Run Linters" step into multiple steps. Also since all of
these steps are independent of eachother, I've made them all run
regardless of if the job is currently failing.

<details>
<summary>Proof of testing:</summary>

Fail in install tools, all linting steps are skipped:
https://github.com/distributivgesetz/tgstation/actions/runs/6151628214/job/16692089726
Fail in Run DreamChecker, other steps continue to run:
https://github.com/distributivgesetz/tgstation/actions/runs/6151664705/job/16692203569?pr=2
</details>

<details>
<summary>Pictured: me breaking CI for a day</summary>

https://github.com/tgstation/tgstation/assets/47710522/ea12ad30-2b69-4aa3-9642-7d0818eab2d1

</details>

Going through the Run Linters step has always been a slog. Finding an
error is like finding a needle in a haystack. Seeing what command
exactly went wrong is going to go a long way in helping people find out
which linters have failed.

nothing playerfacing

* Fix some odd vscode highlighting errors in workflow files  (#78274)

few errors which were odd and annoying

stealing PRs from san7890, they wanted to do this

nothing playerfacing

* fuck

* fuck 2

---------

Co-authored-by: MrMelbert <[email protected]>
Co-authored-by: distributivgesetz <[email protected]>
  • Loading branch information
3 people committed Sep 16, 2023
1 parent 2dd982e commit 56b37a6
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 45 deletions.
56 changes: 35 additions & 21 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- 'project/**'
jobs:
run_linters:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
name: Run Linters
runs-on: ubuntu-20.04
steps:
Expand All @@ -34,24 +34,38 @@ jobs:
bash tools/ci/install_node.sh
bash tools/ci/install_spaceman_dmm.sh dreamchecker
tools/bootstrap/python -c ''
- name: Run Linters
- name: Give Linters A Go
id: linter-setup
run: ':'
- name: Run Grep Checks
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: bash tools/ci/check_grep.sh
- name: Run DreamChecker
if: steps.linter-setup.conclusion == 'success' && !cancelled()
shell: bash
run: ~/dreamchecker 2>&1 | bash tools/ci/annotate_dm.sh
- name: Run Map Checks
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: |
bash tools/ci/check_filedirs.sh daedalus.dme
bash tools/ci/check_changelogs.sh
bash tools/ci/check_grep.sh
bash tools/ci/check_misc.sh
tools/build/build --ci lint tgui-test
tools/bootstrap/python -m dmi.test
tools/bootstrap/python -m mapmerge2.dmm_test
~/dreamchecker > ${GITHUB_WORKSPACE}/output-annotations.txt 2>&1
- name: Annotate Lints
uses: yogstation13/DreamAnnotate@v2
if: always()
with:
outputFile: output-annotations.txt
- name: Run DMI Tests
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: tools/bootstrap/python -m dmi.test
- name: Check File Directories
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: bash tools/ci/check_filedirs.sh daedalus.dme
- name: Check Changelogs
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: bash tools/ci/check_changelogs.sh
- name: Check Miscellaneous Files
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: bash tools/ci/check_misc.sh
- name: Run TGUI Checks
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: tools/build/build --ci lint tgui-test

compile_all_maps:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
name: Compile Maps
runs-on: ubuntu-20.04
steps:
Expand All @@ -68,7 +82,7 @@ jobs:
tools/build/build --ci dm -DCIBUILDING -DCITESTING -DALL_MAPS
find_all_maps:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
name: Find Maps to Test
runs-on: ubuntu-20.04
outputs:
Expand All @@ -93,7 +107,7 @@ jobs:
echo "alternate_tests=$ALTERNATE_TESTS_JSON" >> $GITHUB_OUTPUT
run_all_tests:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
name: Integration Tests
needs: [find_all_maps]
strategy:
Expand All @@ -108,7 +122,7 @@ jobs:
map: ${{ matrix.map }}

run_alternate_tests:
if: "!contains(github.event.head_commit.message, '[ci skip]') && needs.find_all_maps.outputs.alternate_tests != '[]'"
if: ( !contains(github.event.head_commit.message, '[ci skip]') && needs.find_all_maps.outputs.alternate_tests != '[]' )
name: Alternate Tests
needs: [find_all_maps]
strategy:
Expand All @@ -125,15 +139,15 @@ jobs:
minor: ${{ matrix.setup.minor }}

check_alternate_tests:
if: "!contains(github.event.head_commit.message, '[ci skip]') && needs.find_all_maps.outputs.alternate_tests != '[]'"
if: ( !contains(github.event.head_commit.message, '[ci skip]') && needs.find_all_maps.outputs.alternate_tests != '[]' )
name: Check Alternate Tests
needs: [run_alternate_tests]
runs-on: ubuntu-20.04
steps:
- run: echo Alternate tests passed.

compare_screenshots:
if: "!contains(github.event.head_commit.message, '[ci skip]') && always()"
if: ( !contains(github.event.head_commit.message, '[ci skip]') && (success() || failure()) )
needs: [run_all_tests, run_alternate_tests]
name: Compare Screenshot Tests
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -168,7 +182,7 @@ jobs:
path: artifacts/screenshot_comparisons

test_windows:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
name: Windows Build
runs-on: windows-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
publish:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/generate_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ on:
- master
jobs:
generate_documentation:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
permissions:
contents: write # for JamesIves/github-pages-deploy-action to push changes in repo
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
runs-on: ubuntu-20.04
concurrency: gen-docs
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/show_screenshot_test_results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- completed
jobs:
show_screenshot_test_results:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
if: ( !contains(github.event.head_commit.message, '[ci skip]') && github.event.workflow_run.run_attempt == 1 )
name: Show Screenshot Test Results
runs-on: ubuntu-20.04
steps:
Expand Down
51 changes: 31 additions & 20 deletions code/game/objects/items/eightball.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
var/shaking = FALSE
var/on_cooldown = FALSE

var/shake_time = 50
var/cooldown_time = 100
var/shake_time = 5 SECONDS
var/cooldown_time = 10 SECONDS

var/static/list/possible_answers = list(
"It is certain",
Expand Down Expand Up @@ -42,11 +42,16 @@
return INITIALIZE_HINT_QDEL

/obj/item/toy/eightball/proc/MakeHaunted()
. = prob(1)
if(.)
if(prob(1))
new /obj/item/toy/eightball/haunted(loc)
return TRUE
return FALSE

/obj/item/toy/eightball/attack_self(mob/user)
if(..())
return

. = TRUE
if(shaking)
return

Expand All @@ -60,23 +65,19 @@

start_shaking(user)
if(do_after(user, time = shake_time))
var/answer = get_answer()
say(answer)
say(get_answer())

on_cooldown = TRUE
addtimer(CALLBACK(src, PROC_REF(clear_cooldown)), cooldown_time)
addtimer(VARSET_CALLBACK(src, on_cooldown, FALSE), cooldown_time)

shaking = FALSE

/obj/item/toy/eightball/proc/start_shaking(user)
/obj/item/toy/eightball/proc/start_shaking(mob/user)
return

/obj/item/toy/eightball/proc/get_answer()
return pick(possible_answers)

/obj/item/toy/eightball/proc/clear_cooldown()
on_cooldown = FALSE

// A broken magic eightball, it only says "YOU SUCK" over and over again.

/obj/item/toy/eightball/broken
Expand All @@ -97,7 +98,7 @@
/obj/item/toy/eightball/haunted
shake_time = 30 SECONDS
cooldown_time = 3 MINUTES
var/last_message
var/last_message = "Nothing!"
var/selected_message
//these kind of store the same thing but one is easier to work with.
var/list/votes = list()
Expand Down Expand Up @@ -160,6 +161,7 @@
notify_ghosts("[user] is shaking [src], hoping to get an answer to \"[selected_message]\"", source=src, enter_link="<a href=?src=[REF(src)];interact=1>(Click to help)</a>", action=NOTIFY_ATTACK, header = "Magic eightball")

/obj/item/toy/eightball/haunted/Topic(href, href_list)
. = ..()
if(href_list["interact"])
if(isobserver(usr))
interact(usr)
Expand All @@ -169,7 +171,7 @@
var/top_vote

for(var/vote in votes)
var/amount_of_votes = length(votes[vote])
var/amount_of_votes = votes[vote]
if(amount_of_votes > top_amount)
top_vote = vote
top_amount = amount_of_votes
Expand All @@ -186,12 +188,19 @@

voted.Cut()

return top_vote
var/list/top_options = haunted_answers[top_vote]
return pick(top_options)

// Only ghosts can interact because only ghosts can open the ui
/obj/item/toy/eightball/haunted/can_interact(mob/living/user)
return isobserver(user)

/obj/item/toy/eightball/haunted/ui_state(mob/user)
return GLOB.observer_state

/obj/item/toy/eightball/haunted/ui_interact(mob/user, datum/tgui/ui)
if(!isobserver(user))
return
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "EightBallVote", name)
Expand Down Expand Up @@ -224,9 +233,11 @@
var/selected_answer = params["answer"]
if(!(selected_answer in haunted_answers))
return
if(user.ckey in voted)
return
else
votes[selected_answer] += 1
voted[user.ckey] = selected_answer
. = TRUE
var/oldvote = voted[user.ckey]
if(oldvote)
// detract their old vote
votes[oldvote] -= 1

votes[selected_answer] += 1
voted[user.ckey] = selected_answer
return TRUE
2 changes: 1 addition & 1 deletion tgui/packages/tgui/sanitize.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let defTag = [
'u',
'ul',
];
let defAttr = ['class', 'style'];
let defAttr = ['class', 'style', 'background'];

/**
* Feed it a string and it should spit out a sanitized version.
Expand Down
51 changes: 51 additions & 0 deletions tools/ci/annotate_dm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sys
import re
import os.path as path

# Usage: python3 annotate_dm.py [filename]
# If filename is not provided, stdin is checked instead

def red(text):
return "\033[31m" + str(text) + "\033[0m"

def green(text):
return "\033[32m" + str(text) + "\033[0m"

def yellow(text):
return "\033[33m" + str(text) + "\033[0m"

def annotate(raw_output):
# Remove ANSI escape codes
raw_output = re.sub(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]', '', raw_output)

print("::group::DreamChecker Output")
print(raw_output)
print("::endgroup::")

annotation_regex = r'(?P<filename>.*?), line (?P<line>\d+), column (?P<column>\d+):\s{1,2}(?P<type>error|warning): (?P<message>.*)'
has_issues = False

print("DM Code Annotations:")
for annotation in re.finditer(annotation_regex, raw_output):
print(f"::{annotation['type']} file={annotation['filename']},line={annotation['line']},col={annotation['column']}::{annotation['message']}")
has_issues = True

if not has_issues:
print(green("No DM issues found"))

def main():
if len(sys.argv) > 1:
if not path.exists(sys.argv[1]):
print(red(f"Error: Annotations file '{sys.argv[1]}' does not exist"))
sys.exit(1)
with open(sys.argv[1], 'r') as f:
annotate(f.read())
elif not sys.stdin.isatty():
annotate(sys.stdin.read())
else:
print(red("Error: No input provided"))
print("Usage: tools/ci/annotate_dm.sh [filename]")
sys.exit(1)

if __name__ == '__main__':
main()
4 changes: 4 additions & 0 deletions tools/ci/annotate_dm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

set -euo pipefail
tools/bootstrap/python tools/ci/annotate_dm.py "$@"

0 comments on commit 56b37a6

Please sign in to comment.