Created
July 7, 2021 07:43
-
-
Save dima117/46a21a6b299fa1e737eaf89af7c2e724 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# init | |
rm -rf repo_* | |
npm ci | |
# generate vars | |
export REPO_FOLDER=$(node ./runner/generate-id.js) | |
export REPO_PATH=$(node ./runner/resolve-path.js) | |
export TMP_BRANCH=$(node ./runner/generate-branch-name.js) | |
# clone repo | |
echo "CLONE: [email protected]:${REPO}.git into ${REPO_FOLDER}" | |
git clone "[email protected]:${REPO}.git" $REPO_FOLDER | |
if [ "$?" != "0" ]; then | |
node ./runner/generate-result.js "Ошибка при получении файлов с Github. Проверьте, что выбран правильный репозиторий и пользователь yndx-shri является коллаборатором." > result.json | |
exit 0 | |
fi | |
# run | |
if [ "$EXERCISE" = "html-css" ]; then | |
cp -f task1/content/index.html "${REPO_FOLDER}/build/index.html" | |
if [ "$?" != "0" ]; then | |
node ./runner/generate-result.js "Не удалось запустить проект. Убедитесь, что в репозитории есть папка build с файлами stories.js и stories.css" > result.json | |
exit 0 | |
fi | |
rm ./pidfile | |
npx http-server "${REPO_FOLDER}/build" & echo $! > ./pidfile | |
if [ "$?" != "0" ]; then | |
node ./runner/generate-result.js "Не удалось запустить проект" > result.json | |
exit 0 | |
fi | |
npx --no-install jest ./task1/test.ts | |
if [ "$?" != "0" ] && [ ! -f result.json ]; then | |
node ./runner/generate-result.js "Не удалось запустить автотесты для репозитория" > result.json | |
exit 0 | |
fi | |
pkill -F ./pidfile && rm ./pidfile | |
if [ -d "task1/__image_snapshots__/__diff_output__" ]; then | |
rm -rf "${REPO_FOLDER}/__diff_output__" && \ | |
cp -rf task1/__image_snapshots__/__diff_output__ "${REPO_FOLDER}/__diff_output__" && \ | |
cd $REPO_FOLDER && \ | |
git checkout -b $TMP_BRANCH && \ | |
git add __diff_output__ && \ | |
git commit -m "$TMP_BRANCH" && \ | |
git push --set-upstream origin $TMP_BRANCH | |
fi | |
exit 0 | |
fi | |
if [ "$EXERCISE" = "js" ]; then | |
export TASK2_TARGET_FILE="build/index.js" | |
echo "COPY: ${REPO_PATH}/${TASK2_TARGET_FILE}" | |
mkdir -p ./task2/tmp && cp "${REPO_PATH}/${TASK2_TARGET_FILE}" ./task2/tmp/testing-module.js | |
if [ "$?" != "0" ]; then | |
node ./runner/generate-result.js "В репозитории ${REPO} не найден файл ${TASK2_TARGET_FILE}" > result.json | |
exit 0 | |
fi | |
npx --no-install jest ./task2/test.ts | |
if [ "$?" != "0" ] && [ ! -f result.json ]; then | |
node ./runner/generate-result.js "Не удалось запустить автотесты для репозитория" > result.json | |
exit 0 | |
fi | |
exit 0 | |
fi | |
echo "invalid exercise code $EXERCISE" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment