Commit f57a4164 authored by I-Al-Istannen's avatar I-Al-Istannen
Browse files

Add "label"

parent e71731fe
......@@ -6,6 +6,7 @@ stages:
variables:
GRADLE_USER_HOME: "gradle-cache"
FLAMMENWEHRFER_AUTH: "$FLAMMENWEHRFER_AUTH"
gruppen:
stage: run
......@@ -21,19 +22,30 @@ gruppen:
parallel:
matrix:
- GITHUB:
- https://github.com/Firmwehr/gentle
- https://github.com/compilerpraktikum/compiler
- https://github.com/larsk21/compiler-minijava
- https://github.com/iComputerfreak/DerCompiler
- https://github.com/CompPrakt21/Compiler
- Gruppe: 1
GITHUB_PATH: ["Firmwehr/gentle"]
USE_FLAMMENWEHRFER: 1
- Gruppe: 2
GITHUB_PATH: ["compilerpraktikum/compiler"]
USE_FLAMMENWEHRFER: 0
- Gruppe: 3
GITHUB_PATH: ["larsk21/compiler-minijava"]
USE_FLAMMENWEHRFER: 0
- Gruppe: 4
GITHUB_PATH: ["iComputerfreak/DerCompiler"]
USE_FLAMMENWEHRFER: 0
- Gruppe: 5
GITHUB_PATH: ["CompPrakt21/Compiler"]
USE_FLAMMENWEHRFER: 0
script:
- export GRADLE_USER_HOME="$PWD/gradle-cache"
- export MAVEN_OPTS="-Dmaven.repo.local=$PWD/.repository"
- git clone $GITHUB /compiler-under-test
- git clone "https://github.com/$GITHUB_PATH" /compiler-under-test
- /compiler-under-test/build
- ln -s "$PWD" "/mjtest/tests"
- export AUTH="$FLAMMENWEHRFER_AUTH"
- export USE_FLAMMENWEHRFER="$USE_FLAMMENWEHRFER"
- /mjtest/mjt.py lexer /compiler-under-test/run
tags:
- alive
#!/bin/bash
# _ _
# | | | |___ __ _ __ _ ___
# | | | / __|/ _` |/ _` |/ _ \
# | |_| \__ \ (_| | (_| | __/
# \___/|___/\__,_|\__, |\___|
# |___/
if [[ "$GITHUB_PATH" == "" ]] || [[ "$AUTH" == "" ]]; then
echo "GITHUB_PATH ('user/repo') and AUTH ('user:PAT') env vars must be set"
exit 1
fi
# ____ _ _
# / ___|___ _ __ ___| |_ __ _ _ __ | |_ ___
# | | / _ \| '_ \/ __| __/ _` | '_ \| __/ __|
# | |__| (_) | | | \__ \ || (_| | | | | |_\__ \
# \____\___/|_| |_|___/\__\__,_|_| |_|\__|___/
#
BODY="Greetings traveller,\n\nsticks and stones won't break your bones but https://git.scc.kit.edu/IPDSnelting/mjtest-tests broke your compiler :(\n\nHave fun and take good care of it :lady_beetle:"
GITHUB_URL="https://api.github.com/repos/$GITHUB_PATH"
# _____ _ _
# |_ _|__ ___| |_(_)_ __ __ _
# | |/ _ \/ __| __| | '_ \ / _` |
# | | __/\__ \ |_| | | | | (_| | _ _ _
# |_|\___||___/\__|_|_| |_|\__, | (_) (_) (_)
# |___/
MJ_OUTPUT="$(/mjtest/mjt.py lexer /compiler-under-test/run 2>&1)"
MJ_EXIT_CODE="$?"
if [[ "$USE_FLAMMENWEHRFER" != 1 ]]; then
echo "Flammenwehrfer disabled"
echo -e "Output: $MJ_OUTPUT"
exit $MJ_EXIT_CODE
fi
# ____ _ _
# | _ \ ___ _ __ ___ ___| |_ __ _| |_ ___
# | |_) / _ \ '_ \ / _ \ / __| __/ _` | __/ _ \
# | _ < __/ |_) | (_) | \__ \ || (_| | || __/
# |_| \_\___| .__/ \___/ |___/\__\__,_|\__\___|
# |_|
FETCHED_ISSUES="$(curl -Ss \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/I-Al-Istannen/discord-invite-link-icon-fetcher/issues\?author\=I-Al-Istannen\&state\=all)"
ISSUE_COUNT="$(echo "$FETCHED_ISSUES" | jq "length")"
echo "Found $ISSUE_COUNT Github issue(s)"
# ____
# / ___| _ _ ___ ___ ___ ___ ___
# \___ \| | | |/ __/ __/ _ \/ __/ __|
# ___) | |_| | (_| (_| __/\__ \__ \
# |____/ \__,_|\___\___\___||___/___/
#
if [[ "$MJ_EXIT_CODE" == "0" ]]; then
echo "Test successful"
if [[ "$ISSUE_COUNT" > 0 ]] && [[ "$(echo "$FETCHED_ISSUES" | jq ".[0].state")" == '"open"' ]]; then
ISSUE_NUMBER="$(echo "$FETCHED_ISSUES" | jq ".[0].number")"
echo "Closing issue $ISSUE_NUMBER!"
curl -Ss \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-u "$AUTH" \
"$GITHUB_URL/issues/$ISSUE_NUMBER" \
-d '{"state":"closed"}' \
-o /dev/null
fi
exit 0
fi
# _____ _ _
# | ___|_ _(_) |_ _ _ __ ___
# | |_ / _` | | | | | | '__/ _ \
# | _| (_| | | | |_| | | | __/
# |_| \__,_|_|_|\__,_|_| \___|
#
echo "Test failed"
CODE_BLOCK_HEADER='```'
BODY="$BODY\n\n----\n\n<details>\n<summary>mjtest output</summary>\n\n$CODE_BLOCK_HEADER\n$MJ_OUTPUT\n$CODE_BLOCK_HEADER\n\n</details>"
if [[ "$ISSUE_COUNT" == "0" ]]; then
echo "Found no issues, creating new one"
# Create new issue
JSON="
{
\"title\": \"Failing test detected\",
\"body\" : $(echo -e "$BODY" | jq -R -s),
\"labels\": [\"test-failure-bot\"]
}
"
curl -Ss \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-u "$AUTH" \
"$GITHUB_URL/issues" \
-d "$JSON" \
-o /dev/null
exit 0
fi
ISSUE_NUMBER="$(echo "$FETCHED_ISSUES" | jq ".[0].number")"
echo "Commenting on issue $ISSUE_NUMBER"
curl -Ss \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-u "$AUTH" \
"$GITHUB_URL/issues/$ISSUE_NUMBER" \
-d '{"state":"open"}' \
-o /dev/null
curl -Ss \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-u "$AUTH" \
"$GITHUB_URL/issues/$ISSUE_NUMBER/comments" \
-d "{\"body\":$(echo -e "$BODY" | jq -R -s)}" \
-o /dev/null
exit $MJ_EXIT_CODE
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment