From 9be65873af95bd4af854254fe90af102fe30abd0 Mon Sep 17 00:00:00 2001 From: Github Actions Date: Thu, 12 Nov 2020 22:42:41 +0000 Subject: [PATCH] sync github pages --- pages/files/Dockerfile | 10 ---------- pages/files/ci/Dockerfile | 11 +++++++++++ pages/files/{ => ci}/check-install.sh | 12 +++++++----- pages/files/{ => ci}/check.sh | 17 +++++++---------- pages/files/{ => ci}/dictionary.dic | 0 pages/files/{ => ci}/docker-compose.yml | 5 ++--- pages/files/{ => ci}/expected_codes.csv | 0 pages/files/{ => ci}/go/check_links/main.go | 4 ++-- pages/files/{ => ci}/go/check_spell/main.go | 2 +- pages/files/ci/go/go.mod | 10 ++++++++++ pages/files/ci/go/go.sum | 11 +++++++++++ 11 files changed, 51 insertions(+), 31 deletions(-) delete mode 100644 pages/files/Dockerfile create mode 100644 pages/files/ci/Dockerfile rename pages/files/{ => ci}/check-install.sh (80%) rename pages/files/{ => ci}/check.sh (65%) rename pages/files/{ => ci}/dictionary.dic (100%) rename pages/files/{ => ci}/docker-compose.yml (53%) rename pages/files/{ => ci}/expected_codes.csv (100%) rename pages/files/{ => ci}/go/check_links/main.go (94%) rename pages/files/{ => ci}/go/check_spell/main.go (96%) create mode 100644 pages/files/ci/go/go.mod create mode 100644 pages/files/ci/go/go.sum diff --git a/pages/files/Dockerfile b/pages/files/Dockerfile deleted file mode 100644 index 299b086..0000000 --- a/pages/files/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -# check https://docs.travis-ci.com/user/common-build-problems/#troubleshooting-locally-in-a-docker-image -FROM travisci/ci-garnet:packer-1512502276-986baf0 -MAINTAINER Evgenii Sokolov - -USER travis -ENV GOPATH "/home/travis/gopath" -ENV GOROOT "/home/travis/.gimme/versions/go1.7.4.linux.amd64" -ENV PATH "$GOPATH/bin:$GOROOT/bin:$PATH" -COPY . $GOPATH/src/github.com/ru-de/faq/files -RUN cd $GOPATH/src/github.com/ru-de/faq && sudo env PATH=$PATH GOPATH=$GOPATH bash files/check-install.sh diff --git a/pages/files/ci/Dockerfile b/pages/files/ci/Dockerfile new file mode 100644 index 0000000..0272412 --- /dev/null +++ b/pages/files/ci/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:18.04 +MAINTAINER Evgenii Sokolov + +RUN apt-get -yqq update && apt-get install -y wget git locales +RUN cd /tmp && wget https://golang.org/dl/go1.15.5.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.15.5.linux-amd64.tar.gz +ENV PATH "$PATH:/usr/local/go/bin:/root/go/bin" +RUN locale-gen --no-purge en_US.UTF-8 +RUN update-locale LANG=en_US.UTF-8 +ENV LC_ALL "en_US.UTF-8" +COPY . /tmp/files/ci +RUN cd /tmp/files/ci && bash check-install.sh diff --git a/pages/files/check-install.sh b/pages/files/ci/check-install.sh similarity index 80% rename from pages/files/check-install.sh rename to pages/files/ci/check-install.sh index 80b9bb9..e375e09 100644 --- a/pages/files/check-install.sh +++ b/pages/files/ci/check-install.sh @@ -2,12 +2,13 @@ set -xe +PWD_DIR=`pwd` DIR=`dirname $0` -apt-get -yqq update && apt-get install -y hunspell hunspell-ru hunspell-en-us hunspell-de-de jq +apt-get -yqq update && apt-get install -y curl wget unzip binutils hunspell hunspell-ru hunspell-en-us hunspell-de-de jq curl -s https://extensions.libreoffice.org/en/extensions/show/russian-spellcheck-dictionary > .dict_page echo -n "https://extensions.libreoffice.org" > .current_release -strings .dict_page | grep -ozP '
  • (\n|.)*?
  • ' | grep -zoP 'href=".*?">Download' | head -1 | sed 's/href="//' | sed 's/">Download//' >> .current_release +strings .dict_page | grep -ozP '
  • (\n|.)*?
  • ' | grep -zoP -m 1 'href=".*?">Download' | head -1 | sed 's/href="//' | sed 's/">Download//' >> .current_release cat .current_release | wget -q -i - -O /tmp/dictionary.otx unzip /tmp/dictionary.otx -d /tmp cp /tmp/*.dic /usr/share/hunspell @@ -34,11 +35,12 @@ done echo "SET UTF-8" >> /tmp/dictionary.aff mv /tmp/dictionary.* /usr/share/hunspell -go get ./... go get -u github.com/ewgRa/ci-utils/cmd/diff_liner go get -u github.com/ewgRa/ci-utils/cmd/hunspell_parser go get -u github.com/ewgRa/ci-utils/cmd/github_comments_diff go get -u github.com/ewgRa/ci-utils/cmd/github_comments_send -go build -o /tmp/check_spell $DIR/go/check_spell/main.go -go build -o /tmp/check_links $DIR/go/check_links/main.go +cd $DIR/go +go build -o /tmp/check_spell check_spell/main.go +go build -o /tmp/check_links check_links/main.go +cd $PWD_DIR \ No newline at end of file diff --git a/pages/files/check.sh b/pages/files/ci/check.sh similarity index 65% rename from pages/files/check.sh rename to pages/files/ci/check.sh index 596d707..0263ad7 100644 --- a/pages/files/check.sh +++ b/pages/files/ci/check.sh @@ -1,17 +1,12 @@ #!/bin/bash -if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then - echo "Skip, because not a PR" - exit 0 -fi - DIR=`dirname $0` git config --global core.quotepath false -git diff HEAD^ --name-status | grep "^D" -v | sed 's/^.\t//g' | grep "\.md$" > /tmp/changed_files +PULL_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") -curl "https://github-api-bot.herokuapp.com/diff?repo=$TRAVIS_REPO_SLUG&pr=$TRAVIS_PULL_REQUEST" > /tmp/pr.diff +curl "https://github-api-bot.herokuapp.com/diff?repo=${GITHUB_REPOSITORY}&pr=${PULL_NUMBER}" > /tmp/pr.diff if [ "$?" != "0" ]; then echo "Can't get github pull request diff, probably rate limit? Try to restart CI build" @@ -23,6 +18,8 @@ cat /tmp/pr.diff | diff_liner > /tmp/pr_liner.json rm -f /tmp/comments.json touch /tmp/comments.json +curl -s -X GET -G https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PULL_NUMBER}/files | jq -r '.[] | .filename' | grep "^D" -v | sed 's/^.\t//g' | grep "\.md$" > /tmp/changed_files + while read FILE; do COMMIT=$(git log --pretty=format:"%H" -1 "$FILE"); echo "Проверка изменений в файле $FILE на опечатки... "; @@ -33,7 +30,7 @@ while read FILE; do echo "Проверка изменений в файле $FILE на недоступные ссылки... "; - /tmp/check_links -file "$FILE" -commit=$COMMIT -pr-liner /tmp/pr_liner.json -expected-codes files/expected_codes.csv >> /tmp/comments.json + /tmp/check_links -file "$FILE" -commit=$COMMIT -pr-liner /tmp/pr_liner.json -expected-codes files/ci/expected_codes.csv >> /tmp/comments.json echo done < /tmp/changed_files @@ -45,7 +42,7 @@ cat /tmp/comments_array.json EXIT_CODE=0 if [ "$(cat /tmp/comments_array.json)" != "[]" ]; then - curl "https://github-api-bot.herokuapp.com/comments?repo=$TRAVIS_REPO_SLUG&pr=$TRAVIS_PULL_REQUEST" > /tmp/pr_comments.json + curl "https://github-api-bot.herokuapp.com/comments?repo=${GITHUB_REPOSITORY}&pr=${PULL_NUMBER}" > /tmp/pr_comments.json if [ "$?" != "0" ]; then echo "Can't get github comments, probably rate limit? Try to restart ci build" @@ -54,7 +51,7 @@ if [ "$(cat /tmp/comments_array.json)" != "[]" ]; then github_comments_diff -comments /tmp/comments_array.json -exists-comments /tmp/pr_comments.json > /tmp/send_comments.json - curl -XPOST "https://github-api-bot.herokuapp.com/send_review?repo=$TRAVIS_REPO_SLUG&pr=$TRAVIS_PULL_REQUEST&body=Спасибо%20за%20PR.%20Обратите%20внимание%20на%20результаты%20автоматической%20проверки%20орфографии%20и%20ссылок" -d @/tmp/send_comments.json + curl -XPOST "https://github-api-bot.herokuapp.com/send_review?repo=${GITHUB_REPOSITORY}&pr=${PULL_NUMBER}&body=Спасибо%20за%20PR.%20Обратите%20внимание%20на%20результаты%20автоматической%20проверки%20орфографии%20и%20ссылок" -d @/tmp/send_comments.json EXIT_CODE=1 fi diff --git a/pages/files/dictionary.dic b/pages/files/ci/dictionary.dic similarity index 100% rename from pages/files/dictionary.dic rename to pages/files/ci/dictionary.dic diff --git a/pages/files/docker-compose.yml b/pages/files/ci/docker-compose.yml similarity index 53% rename from pages/files/docker-compose.yml rename to pages/files/ci/docker-compose.yml index 5c0cf1e..9d3cff6 100644 --- a/pages/files/docker-compose.yml +++ b/pages/files/ci/docker-compose.yml @@ -6,7 +6,6 @@ services: context: . dockerfile: Dockerfile container_name: ru_de_checker - user: travis - command: bash -l -c "cd /home/travis/ru-de-faq && bash files/check.sh" + command: bash -l -c "cd /home/ru-de-faq && bash files/ci/check.sh" volumes: - - ../.:/home/travis/ru-de-faq + - ../../.:/home/ru-de-faq diff --git a/pages/files/expected_codes.csv b/pages/files/ci/expected_codes.csv similarity index 100% rename from pages/files/expected_codes.csv rename to pages/files/ci/expected_codes.csv diff --git a/pages/files/go/check_links/main.go b/pages/files/ci/go/check_links/main.go similarity index 94% rename from pages/files/go/check_links/main.go rename to pages/files/ci/go/check_links/main.go index 8583cfc..b2505a0 100644 --- a/pages/files/go/check_links/main.go +++ b/pages/files/ci/go/check_links/main.go @@ -2,13 +2,13 @@ package main import ( "fmt" + "github.com/russross/blackfriday/v2" "os" "flag" "bufio" "regexp" "github.com/ewgRa/ci-utils/src/diff_liner" "github.com/ewgRa/ci-utils/src/links_checker" - "gopkg.in/russross/blackfriday.v2" "encoding/json" "github.com/google/go-github/github" ) @@ -65,7 +65,7 @@ func main() { continue } - body := fmt.Sprintf("Ссылка **%s** ... недоступна с кодом **%v**, ожидается **%v**.\nЕсли это ожидаемый ответ, внесите \"%v,%s\" в files/expected_codes.csv", link, respCode, expectedCodes, respCode, link) + body := fmt.Sprintf("Ссылка **%s** ... недоступна с кодом **%v**, ожидается **%v**.\nЕсли это ожидаемый ответ, внесите \"%v,%s\" в files/ci/expected_codes.csv", link, respCode, expectedCodes, respCode, link) comments = append(comments, &github.PullRequestComment{ Body: &body, diff --git a/pages/files/go/check_spell/main.go b/pages/files/ci/go/check_spell/main.go similarity index 96% rename from pages/files/go/check_spell/main.go rename to pages/files/ci/go/check_spell/main.go index e7c8153..9a2bc62 100644 --- a/pages/files/go/check_spell/main.go +++ b/pages/files/ci/go/check_spell/main.go @@ -35,7 +35,7 @@ func main() { continue } - body := fmt.Sprintf("Возможная ошибка в слове \"**%s**\".\n Варианты правильного написания \"**%s**\".\nЕсли слово \"%s\" является правильным, добавьте его в files/dictionary.dic", resp.Word, resp.Alternative, resp.Word) + body := fmt.Sprintf("Возможная ошибка в слове \"**%s**\".\n Варианты правильного написания \"**%s**\".\nЕсли слово \"%s\" является правильным, добавьте его в files/ci/dictionary.dic", resp.Word, resp.Alternative, resp.Word) comments = append(comments, &github.PullRequestComment{ Body: &body, diff --git a/pages/files/ci/go/go.mod b/pages/files/ci/go/go.mod new file mode 100644 index 0000000..3eda43e --- /dev/null +++ b/pages/files/ci/go/go.mod @@ -0,0 +1,10 @@ +module github.com/ru-de/faq + +go 1.15 + +require ( + github.com/ewgRa/ci-utils v0.0.0-20180607200228-15dd1fde41f9 + github.com/google/go-github v17.0.0+incompatible + github.com/google/go-querystring v1.0.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect +) diff --git a/pages/files/ci/go/go.sum b/pages/files/ci/go/go.sum new file mode 100644 index 0000000..422f0e2 --- /dev/null +++ b/pages/files/ci/go/go.sum @@ -0,0 +1,11 @@ +github.com/ewgRa/ci-utils v0.0.0-20180607200228-15dd1fde41f9 h1:G+RMure2Z4ebQs/jCfeeqFB4k73bO7H9FJN4B/DX+vw= +github.com/ewgRa/ci-utils v0.0.0-20180607200228-15dd1fde41f9/go.mod h1:VOwWqySz9ACgsDQRgWcJmOQL0HYyugfTvP1adEmGWbE= +github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= +github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= +github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday v1.6.0-pre.1 h1:APCbYYLyOoAWCgZNdHFH3o9uon5Z+N7gp6pThPjuvwI= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=