Koiran jälkeen siistein lemmikki. Testausserverin siistein botti

Overview

testauskameli

Testausserverin siistein botti

Ominaisuuksia

Kieliajurit

Kun pingaat kamelin viestiin, jossa on tuetun kielen koodipalikka kameli yrittää ajaa kyseisen koodin ja tulostaa vastausviestiin sen tulosteen ja mahdolliset virheet.

Tuetut kielet:

  • Haskell
  • C

Meemi generaattori

Kun pingaat kamelin viestiin, joka toteutaa regexin "no\s+(.*)??", kameli lähettää sinulle hienon meemin

Echo

Kun pingaat kamelin viestiin, joka alkaa sanalla "echo", kameli lähettää sinulle loput viestistä. Hyödyllinen testaukseen.

Vaatimuksia

Kamelin vaatimat ohjelmistot ja muut

.env

.env-nimisessä tiedostossa tulee olla seuraavat muuttujat määriteltyinä:

DISCORD_TOKEN=
GHC_ARGS=
KAMELI_MEMLIMIT=
KAMELI_TIMELIMIT=
KAMELI_FILELIMIT=
KAMELI_PROCESSLIMIT=
KAMELI_RUNUSER=
FONT_PATH=

Ohjelmistot

Seuraavat ohjelmistot tulevat olla ladattuna ja kamelin käytettävissä:

  1. s6 (tark. s6-softlimit)
  2. sudo: /etc/sudoers:sta tulisi löytyä vastaava configuraatio:
    %sudo   ALL=(runhaskell) NOPASSWD: ALL
    
    Jossa runhaskell vastaa $KAMELI_RUNUSER-muuttujaa
  3. ghc

Muut

Kamelia ajavalle koneelle tulee olla luotuna $KAMELI_RUNUSER mukainen käyttäjä. On suositeltavaa, ettei tällä käyttäjällä ole mitään oikeuksia.

Tarkoitus

Kamelin tarkoitus on olla sekä viihdyttävä, että hyödyllinen. Jatkossa kameliin voi lisätä esim. meemi-generaatio-komentoja.

Lyh. Kameliin on tarkoitus lisätä kaikki ne komennot, jotka halutaan, mutta jotka eivät sovi testauskoiraan

Comments
  • Handsome refactoring and upgrades (I am going to kill god)

    Handsome refactoring and upgrades (I am going to kill god)

    Gentlemen, there is a couple of TODOs, but I still want to show you this cock.

    This essentially rewrites testauskameli in such away, that you can reasonably easily add backends (shit like language playgrounds, latex, no meme?) and such that you can also somewhat easily add frontends (Discord, cli, http, whatever)

    To create a backend:

    • Create a structure
    • Implement MrSnippet on it (named so in honor of Luukasa)

    To create a frontend:

    • Do whatever you need to make a bot or sumshit
    • Create a structure, which has some way to hold MrSnippet trait objects, such that it is valid in an async, Send + Sync, interior mutability context
    • Implement Executor on said structure

    To run the executor then, you just need to spawn a tokio::task that awaits the future from Executor::run.

    You then send it inputs via a flume channel (in async mode, or youre mom gay), and with the Context type that you need to set for the executor trait, the executor will send the response messages automatically.

    This is a WIP, here is a couple outstanding issues that I know of:

    • I want to implement the cli frontend, so that it is easier to test testauskameli locally
    • It needs testing
    • Haskell schizma:
      • The async Command provides both methods for unlimited and constrained execution
      • I think it is better to call shell scripts which do appropriate amount of limitation for languages like Haskell which need to be compiled, and thus these should be passed in there as env variables and the final call of the shell script shall be the sudo with s6 limits
      • Things that can be run directly better use the Command with limitations, ie. shell scripts
      • I don't have the haskell script yet lmao

    The async command can also automatically create temporary directories and files to run the code in. The run methods which use any of the temporary IO return a FIles object along with a future in a tuple.

    The Future is the actual command, awaiting it will run it.

    The Files is a guard for the temporary files, once it's dropped, da files are gone

    opened by luciusmagn 5
  • easy: Filter out lines that start with ``` in output in discord bot

    easy: Filter out lines that start with ``` in output in discord bot

    It is easy to mess up the resulting formatting if you are Mixu and try printing ``` everywhere. To maintain handsomeness, the discord bot should filter out lines that start with ``` (in other places, it is meaningless)

    This change needs to be done here: https://github.com/Testausserveri/testauskameli/blob/3ad1f5c9716bdf5c9e1fa977d593cc255665906a/bot/src/executor.rs#L45-L80

    And it concerns the bindings output and error in respective match arms.

    Cookbook:

    • For each mach block, add a let output and optionally let error which will contain the filtered text
    • This variable will shadow the original one, so no further changes should be necessary

    Tips:

    • Iterators over strings and chars can collect into strings
    • you can use the str::lines() iterator on String to get lines
    • then you can use the filter method to filter out undesirable lines, and subsequently collect into a String
    good first issue 
    opened by luciusmagn 4
  • easy: Test env propagation behavior and refactor based on that

    easy: Test env propagation behavior and refactor based on that

    In our async Command wrapper, there is this monstrosity:

    https://github.com/Testausserveri/testauskameli/blob/3ad1f5c9716bdf5c9e1fa977d593cc255665906a/testauskameli/src/cmd.rs#L69-L89

    An astute observer might recognize, that this is not nice cock.

    Tasks:

    • Try removing either one or the other and see how these propagate - use the cli program, so you can test Testauskameli from the comfort of your Unix-compliant computer. you can use the following snippet for seeing what's up:
    cat <your-test-input> | env RUST_LOG="testauskameli=debug" cargo run -p cli
    
    • Try one of the snippets, maybe haskell or c, or something. Look into their runner script (located under bin/) and insert echo $VARs for the variable(s) you are testing
    • You should find out, if the env invocation from line 73 is needed, or if just the method calls above are enough

    Recipe:

    • if the method calls are enough, yeet the lines 73-95
    • if they aren't, yeet lines 69-72

    In case they aren't, report here, because we will need smarter refactoring, especially with regards to this: https://github.com/Testausserveri/testauskameli/blob/3ad1f5c9716bdf5c9e1fa977d593cc255665906a/testauskameli/src/cmd.rs#L90-L95

    good first issue 
    opened by luciusmagn 0
  • easy+: Add a reasonable CI (rustfmt check, verify compilation)

    easy+: Add a reasonable CI (rustfmt check, verify compilation)

    It should be easy to add these, the harder part is making it fast (perhaps by adding sccache or looking into github actions caching options)

    • use cargo fmt --check to verify formatting -> run from repo root with the flag --all
    • for now, I think only doing a cargo check --all --all-targets is enough to verify the code compiles

    In other words, if you commit unformatted code, I will bombard your mom

    good first issue 
    opened by luciusmagn 1
  • easy: Truncation should be done at bot level, not snippet level

    easy: Truncation should be done at bot level, not snippet level

    https://github.com/Testausserveri/testauskameli/blob/3ad1f5c9716bdf5c9e1fa977d593cc255665906a/testauskameli/src/snippets/haskell.rs#L65-L70

    cookbook:

    • remove these lines
    • do the truncation in bot/src/executor.rs
    opened by luciusmagn 0
Owner
Testausserveri ry
Community of young Finnish hackers
Testausserveri ry