1
0
mirror of https://github.com/ru-de/faq.git synced 2024-11-22 10:22:20 +00:00

sync github pages

This commit is contained in:
Github Actions 2020-11-12 22:42:41 +00:00
parent 626e738678
commit 9be65873af
11 changed files with 51 additions and 31 deletions

View File

@ -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 <e.sokolov@sevensenders.com>
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

11
pages/files/ci/Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM ubuntu:18.04
MAINTAINER Evgenii Sokolov <ewgraf@gmail.com>
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

View File

@ -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 '<li class="releaseRow">(\n|.)*?</li>' | grep -zoP 'href=".*?">Download' | head -1 | sed 's/href="//' | sed 's/">Download//' >> .current_release
strings .dict_page | grep -ozP '<li class="releaseRow">(\n|.)*?</li>' | 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

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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,

10
pages/files/ci/go/go.mod Normal file
View File

@ -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
)

11
pages/files/ci/go/go.sum Normal file
View File

@ -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=