Skip to content

Commit

Permalink
Merge pull request #359 from Catrobat/develop
Browse files Browse the repository at this point in the history
[RELEASE] 1.4.0
  • Loading branch information
wslany authored Apr 6, 2022
2 parents 465e3bd + 4e869fd commit baef888
Show file tree
Hide file tree
Showing 114 changed files with 12,071 additions and 7,699 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module"
},
"extends": [
Expand All @@ -9,7 +8,7 @@
],
"env": {
"browser": true,
"es6": true,
"es2022": true,
"node": true,
"jest": true
},
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/interval_catroid_check_action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ jobs:
- name: run checker for brick support and language updates
uses: ./github_actions/catroid-support-checker-action/
with:
slack_webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
slack_webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
github-token: ${{ secrets.PAT }} # PAT has to be defined in Repository > Settings > Secrets
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides": {
"webpack:///./*": "${workspaceFolder}/*"
"webpack:///./*": "${workspaceFolder}/*",
"webpack://catblocks/./*": "${workspaceFolder}/*"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions assets/empty_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docker/po-review/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:10-alpine
FROM node:16-alpine

MAINTAINER Catblocks "https://github.com/Catrobat/Catblocks"
LABEL org.opencontainers.image.authors="Catblocks https://github.com/Catrobat/Catblocks"

ARG REPO="https://github.com/Catrobat/Catblocks.git"
ARG SHAREROOT="https://share.catrob.at/app/download/"
Expand Down
3 changes: 2 additions & 1 deletion github_actions/catroid-support-checker-action/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu

ARG CATBLOCKSREPO="https://github.com/Catrobat/Catblocks.git"
ARG CATBLOCKSREPO="Catrobat/Catblocks"
ARG CATROIDREPO="https://github.com/Catrobat/Catroid.git"
ARG WORKDIR="/checker/"

Expand All @@ -9,6 +9,7 @@ RUN apt update
RUN apt install python3 python3-pip --assume-yes
RUN apt install build-essential --assume-yes
RUN apt install git --assume-yes
RUN apt install curl --assume-yes

# install required python packages
RUN pip3 install --upgrade pip
Expand Down
6 changes: 5 additions & 1 deletion github_actions/catroid-support-checker-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ inputs:
slack_webhook:
description: 'Webhook to post on in #catblocks Slack channel'
required: true
github-token:
description: 'Github token for push'
required: true
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.slack_webhook }}
- ${{ inputs.slack_webhook }}
- ${{ inputs.github-token }}
45 changes: 43 additions & 2 deletions github_actions/catroid-support-checker-action/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,52 @@
Catrobat Brick Support Checker Action
'

GITTOKEN="$2"
LANGUAGE_UPDATE_FLAG="/langupdate.txt"
BRANCH="BLOCKS-MAINTENANCE-language_update"

# Create directory where the Catroid and Catblocks projects should be cloned to
mkdir $WORKDIR && cd $WORKDIR

git clone $CATBLOCKS
git clone "https://github.com/${CATBLOCKS}.git"
git clone $CATROID

cd Catblocks/
git config user.email "[email protected]"
git config user.name "Catblocks GitHub Action"

if git show-ref --quiet refs/remotes/origin/${BRANCH}; then
git fetch origin ${BRANCH}
git checkout ${BRANCH}
git merge origin develop
echo '>> Existing branch found!'
else
git checkout -b ${BRANCH}
git push -u origin ${BRANCH}
echo '<< New branch created!'
fi

cd ..

# run checker & send report
python3 /checker.py "$WORKDIR" "$1"
rm -f $LANGUAGE_UPDATE_FLAG
python3 /checker.py "$WORKDIR" "$1"
RETVALUE="$?"

# push language updates to repository and create PR
# checker.py creates a file if the PR is necessary
if test -f $LANGUAGE_UPDATE_FLAG; then
echo '>> Language update found! PR will be created.'

cd Catblocks/

git add i18n/catroid_strings/
git commit -m 'BLOCK-MAINTENANCE update languages'
git push "https://${GITHUB_ACTOR}:${GITTOKEN}@github.com/${CATBLOCKS}.git" $BRANCH

curl -s -o /dev/null -w "%{http_code}" -i -H "Authorization: token ${GITTOKEN}" -X POST -d '{ "title": "BLOCK-MAINTENANCE update languages", "body": "Languages automatically fetched from Catroid.", "head": "'${BRANCH}'", "base": "develop" }' https://api.github.com/repos/$CATBLOCKS/pulls | tac | tac | grep -qsE "200|201|422"
RETVALUE=$(($? + $RETVALUE))
fi

echo $RETVALUE
exit $RETVALUE
94 changes: 93 additions & 1 deletion github_actions/catroid-support-checker-action/require/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@
('WhenStartedBrick', 'StartScript'),
]

bricksToCheck = [' Motion bricks ', ' Physics ', ' Look bricks ', ' Pen bricks ', ' Sound bricks ',
' Embroidery bricks ', ' Device bricks ', ' Control bricks ', ' Arduino Bricks ', ' Raspi Bricks ',
' Drone Bricks ', ' Jumping Sumo Bricks ', ' Phiro bricks ']

ignoreStrings = ['brick_option_place_visually', 'brick_and_wait', 'brick_next_background', 'brick_previous_background',
'brick_edit_background', 'brick_delete_background', 'brick_ask_default_question',
'brick_ask_dialog_hint', 'brick_ask_dialog_submit', 'brick_ask_speech_default_question',
'brick_paint_new_background', 'brick_paint_new_look_name', 'brick_copy_look_name',
'brick_copy_background', 'brick_speak_default_value', 'speech_recognition_not_available',
'speech_recognition_offline_mode_error_dialog_title',
'speech_recognition_offline_mode_missing_data_error_dialog_msg', 'collision_with_anything',
'brick_loop_end', 'brick_if_end', 'brick_write_variable_to_file_default_value',
'brick_write_variable_to_file_success', 'brick_note_default_value', 'brick_think_bubble_default_value',
'brick_say_bubble_default_value', 'brick_broadcast_default_value', 'brick_web_request_default_value',
'web_request_warning_title', 'web_request_warning_message', 'web_request_trust_domain_warning_title',
'web_request_trust_domain_warning_message', 'trusted_domains_edit_hint',
'look_request_http_error_message', 'look_request_type_error_message', 'second_plural', 'brick_store_csv_into_userlist_data',
'brick_drone_set_config', 'brick_drone_set_altitude', 'brick_drone_set_vertical_speed','brick_drone_set_rotation_speed',
'brick_drone_set_tilt_limit']

# Loads the bricks supported by Catblocks from the JSON data.
def loadCatblocksBricks():
global path
Expand Down Expand Up @@ -228,15 +248,80 @@ def compareLanguageSupport(catroid_languages, catblocks_languages):

def generateLanguageMessage(updated_languages):
updated_languages.sort()
msg = '*Updated Languages*:\n'
msg = '*Automatically Updated Languages*:\n'
for lang in updated_languages:
msg += lang.replace('values-', '') + ', '
return msg.strip().strip(',')

def generateStringsToJsonMessage(missing_strings):
missing_strings_in_json = str(missing_strings)
msg = '*Strings missing in strings_to_json_mapping.json*:\n'
msg += missing_strings_in_json.replace("[", "").replace("]", "").replace("'", "")
return msg

def sendSlackMessage(webhook, message):
json_data = {'text': message}
requests.post(webhook, json=json_data)

def fetchLanguages():
global path
base_dir = path + '/Catroid/catroid/src/main/res/'
copy_dir = path + '/Catblocks/i18n/catroid_strings/'
repo = git.Git(path + '/Catblocks')
git.Git(path + '/Catroid')
folders = os.listdir(base_dir)
languages = {}
for folder in folders:
xml_file = base_dir + folder + '/strings.xml'
if os.path.exists(xml_file):
if folder == 'values':
folder = folder + '-en'
elif not os.path.exists(copy_dir + folder):
os.mkdir(copy_dir + folder)
cat_blocks_xml = copy_dir + folder + '/strings.xml'
os.replace(xml_file, cat_blocks_xml)
else:
languages[folder] = None

def checkStringsToJson():
global path
catblocks_language = path + '/Catblocks/i18n/catroid_strings/values-en/strings.xml'
catblocks_stringstojson = path + '/Catblocks/i18n/strings_to_json_mapping.json'
repo = git.Git(path + '/Catblocks')
catblocks_strings = []

if os.path.exists(catblocks_language):
parser = ET.XMLParser(target=ET.TreeBuilder(insert_comments=True))
tree = ET.parse(catblocks_language, parser=parser)
root = tree.getroot()
append_list = False
for line in root:
if "function Comment" in str(line.tag):
if line.text in bricksToCheck:
append_list = True
else:
append_list = False
if append_list:
text = str(line.items()).replace("[('name', '", "").replace("')]", "")
if text != '[]':
catblocks_strings.append(text)

if os.path.exists(catblocks_stringstojson):
file = open(catblocks_stringstojson)
data = json.load(file)
check_list = catblocks_strings[:]
for string_line in catblocks_strings:
for json_line in data:
if (str(string_line)) in str(data[json_line]):
check_list.remove(string_line)
break
result = [x for x in check_list if x not in ignoreStrings]
return result

def setCreateLanguageUpdateFlag():
print('Writing language update flag!')
with open('/langupdate.txt', 'w') as f:
f.write('Langues updated');

# Requires the following Args:
# [1] Path to the parent folder of Catblocks & Catroid project
Expand All @@ -263,9 +348,16 @@ def main():
catroid_languages = loadSupportedCatroidLanguages()
catblocks_languages = loadSupportedCatblocksLanguages()
language_updates = compareLanguageSupport(catroid_languages, catblocks_languages)
catblocks_stringsToJson = checkStringsToJson()

if catblocks_stringsToJson is not None and len(catblocks_stringsToJson) > 0:
slack_msg += '\n\n' + generateStringsToJsonMessage(catblocks_stringsToJson)
send_msg = True

if language_updates is not None and len(language_updates) > 0:
fetchLanguages()
slack_msg += '\n\n' + generateLanguageMessage(language_updates)
setCreateLanguageUpdateFlag()
send_msg = True

if send_msg:
Expand Down
5 changes: 3 additions & 2 deletions github_actions/gh-pages-deploy-action/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cd /github/workspace/
# build render
yarn install
yarn clean
yarn render:build
yarn render:ghpages
RETVALUE="$?"

mv ./dist ./../dist
Expand All @@ -31,8 +31,9 @@ COMMITMSG="Deploy: Merged Pull Request #${PRNUMBER}"
git config user.email "[email protected]"
git config user.name "GitHub Action"
git add ./develop
git commit -m $COMMITMSG
git commit -m "$COMMITMSG"

git push "https://${GITHUB_ACTOR}:${GITTOKEN}@github.com/Catrobat/Catblocks.git" "gh-pages"
RETVALUE=$(($? + $RETVALUE))

exit $RETVALUE
Loading

0 comments on commit baef888

Please sign in to comment.