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

Travis #785: sync github pages

This commit is contained in:
Travis CI 2018-05-06 00:29:15 +00:00
parent 1c2a77cea5
commit 3686762e63
4 changed files with 44 additions and 133 deletions

View File

@ -2,7 +2,9 @@
set -xe
apt-get -yqq update && apt-get install -y hunspell hunspell-ru hunspell-en-us hunspell-de-de
DIR=`dirname $0`
apt-get -yqq update && apt-get install -y hunspell hunspell-ru hunspell-en-us hunspell-de-de jq
curl -s https://extensions.libreoffice.org/extensions/russian-spellcheck-dictionary.-based-on-works-of-aot-group > .dict_page
cat .dict_page | grep -oP "<a href.+title=\"Current release for the project\"" | grep -oP "https://extensions.libreoffice.org/extensions/russian-spellcheck-dictionary.-based-on-works-of-aot-group/[^\"]+" > .current_release
echo -n $(cat .current_release) > .current_release
@ -27,4 +29,17 @@ for dic in $dicList
cat /usr/share/hunspell/$dic.aff | iconv --from ISO8859-1 --to UTF-8 | sed 's/SET ISO8859-1/SET UTF-8/' > /usr/share/hunspell/$dic-utf8.aff
done
go get -u github.com/russross/blackfriday-tool
go get ./...
go get -u github.com/ewgRa/ci-utils/utils/diff_liner
go get -u github.com/ewgRa/ci-utils/utils/hunspell_parser
go get -u github.com/ewgRa/ci-utils/utils/github_comments_diff
go get -u github.com/ewgRa/ci-utils/utils/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
(cat $DIR/dictionary.dic; echo) | sed '/^$/d' | wc -l > /tmp/dictionary.dic
(cat $DIR/dictionary.dic; echo) | sed '/^$/d' >> /tmp/dictionary.dic
echo "SET UTF-8" >> /tmp/dictionary.aff
sudo mv /tmp/dictionary.* /usr/share/hunspell

View File

@ -1,66 +1,45 @@
#!/bin/bash
DIR=`dirname $0`
EXIT_CODE=0
git config --global core.quotepath false
(cat $DIR/dictionary.dic; echo) | sed '/^$/d' | wc -l > /tmp/dictionary.dic
(cat $DIR/dictionary.dic; echo) | sed '/^$/d' >> /tmp/dictionary.dic
echo "SET UTF-8" >> /tmp/dictionary.aff
sudo mv /tmp/dictionary.* /usr/share/hunspell
git diff HEAD^ --name-status | grep "^D" -v | sed 's/^.\t//g' | grep "\.md$" > /tmp/changed_files
go build -o /tmp/spell-checker $DIR/spell-checker.go
curl -sH "Accept: application/vnd.github.v3.diff.json" https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST > /tmp/pr.diff
cat /tmp/pr.diff | diff_liner > /tmp/pr_liner.json
rm -f /tmp/comments.json
touch /tmp/comments.json
while read FILE; do
echo -n "Проверка файла $FILE на опечатки... ";
COMMIT=$(git log --pretty=format:"%H" -1 "$FILE");
echo "Проверка изменений в файле $FILE на опечатки... ";
OUTPUT=$(cat "$FILE" | sed 's/https\?:[^ ]*//g' | sed "s/[(][^)]*\.md[)]//g" | sed "s/[(]files[^)]*[)]//g" | hunspell -d dictionary,russian-aot-utf8,ru_RU,de_DE-utf8,en_US-utf8 | /tmp/spell-checker);
OUTPUT_EXIT_CODE=$?
cat "$FILE" | sed 's/https\?:[^ ]*//g' | sed "s/[(][^)]*\.md[)]//g" | sed "s/[(]files[^)]*[)]//g" | hunspell -d dictionary,russian-aot-utf8,ru_RU,de_DE-utf8,en_US-utf8 > /tmp/hunspell.out
cat /tmp/hunspell.out | hunspell_parser > /tmp/hunspell_parsed.json
/tmp/check_spell -file "$FILE" -commit=$COMMIT -pr-liner /tmp/pr_liner.json -hunspell-parsed-file /tmp/hunspell_parsed.json >> /tmp/comments.json
if [ $OUTPUT_EXIT_CODE -ne 0 ]; then
EXIT_CODE=1
echo "ошибка";
echo "$OUTPUT";
else
echo "пройдена";
fi
echo "Проверка изменений в файле $FILE на недоступные ссылки... ";
rm -f /tmp/file.html
blackfriday-tool "$FILE" /tmp/file.html
if [ -f "/tmp/file.html" ]; then
grep -Po '(?<=href=")http[^"]*(?=")' "/tmp/file.html" > /tmp/links
if [ -s /tmp/links ]; then
echo "Проверка файла $FILE на недоступные ссылки... ";
while read LINK; do
REGEXP_LINK=$(echo $LINK | sed 's/[]\.|$(){}?+*^[]/\\&/g')
LINK=$(echo "$LINK" | sed -e 's/\[/\\\[/g' -e 's/\]/\\\]/g' -e 's/\&amp;/\&/g')
status=$(curl --insecure -XGET -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" -m 10 -L -s --head -w %{http_code} $LINK -o /dev/null)
expectedStatus=$(grep -oP "[^,]+,$REGEXP_LINK$" $DIR/known_url.csv | cut -d',' -f1)
if [ -z "$expectedStatus" ]; then
expectedStatus="200"
fi
if [ "$status" != "$expectedStatus" -a "$status" != "200" ]; then
EXIT_CODE=1
echo "Ссылка $LINK ... недоступна с кодом $status, ожидается $expectedStatus";
echo
fi
done < /tmp/links
echo
fi
fi
/tmp/check_links -file "$FILE" -commit=$COMMIT -pr-liner /tmp/pr_liner.json -expected-codes files/expected_codes.csv >> /tmp/comments.json
echo
done < /tmp/changed_files
jq -s '[.[][]]' /tmp/comments.json > /tmp/comments_array.json
curl -s https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST/comments > /tmp/pr_comments.json
github_comments_diff -comments /tmp/comments_array.json -exists-comments /tmp/pr_comments.json > /tmp/send_comments.json
OUTPUT=$(cat /tmp/comments_array.json | grep "\[]");
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
github_comments_send -file /tmp/send_comments.json -repo $TRAVIS_REPO_SLUG -pr $TRAVIS_PULL_REQUEST
fi
cat /tmp/comments_array.json
exit $EXIT_CODE

View File

@ -1,14 +0,0 @@
000,https://www.momondo.com/
000,https://www.vueling.com/en
000,https://www.hertz.com/rentacar/reservation/
429,https://www.idealo.de
302,https://github.com/ru-de/faq/blob/master/files/Einladung%20(short%20term).docx?raw=true
302,https://github.com/ru-de/faq/blob/master/files/Einladung%20(long%20term).docx?raw=true
404,https://www.clark.de/de/invitation/8hvwkbv2gh
000,https://www.envivas.de/de/tarife-und-service/zusatzversicherungen/auslandsreise/travelxl
000,https://www.envivas.de/de/tarife-und-service/zusatzversicherungen/auslandsreise/travelxf
000,https://www.envivas.de/
000,https://www.apotheken.de/
000,http://www.vpngate.net/en/
418,https://www.ebay-kleinanzeigen.de
418,http://kleinanzeigen.ebay.de
1 000 https://www.momondo.com/
2 000 https://www.vueling.com/en
3 000 https://www.hertz.com/rentacar/reservation/
4 429 https://www.idealo.de
5 302 https://github.com/ru-de/faq/blob/master/files/Einladung%20(short%20term).docx?raw=true
6 302 https://github.com/ru-de/faq/blob/master/files/Einladung%20(long%20term).docx?raw=true
7 404 https://www.clark.de/de/invitation/8hvwkbv2gh
8 000 https://www.envivas.de/de/tarife-und-service/zusatzversicherungen/auslandsreise/travelxl
9 000 https://www.envivas.de/de/tarife-und-service/zusatzversicherungen/auslandsreise/travelxf
10 000 https://www.envivas.de/
11 000 https://www.apotheken.de/
12 000 http://www.vpngate.net/en/
13 418 https://www.ebay-kleinanzeigen.de
14 418 http://kleinanzeigen.ebay.de

View File

@ -1,69 +0,0 @@
package main
import (
"fmt"
"os"
"bufio"
"regexp"
"strings"
)
type TypeResult struct {
results []Result
}
type Result struct {
line int
word string
}
func main() {
scanner := bufio.NewScanner(os.Stdin)
types := parseHunspellOutput(scanner);
_, ok := types["&"]
if ok {
var dropCol = regexp.MustCompile(`^([^ ]+) \d+ \d+:(.*)$`)
var minimumWord = regexp.MustCompile(`^[^ ]{3}`)
exitCode := 0
for _, result := range types["&"].results {
if minimumWord.MatchString(result.word) {
exitCode = 1
fmt.Println("Строка " + fmt.Sprintf("%v", result.line) + ": " + dropCol.ReplaceAllString(result.word, "$1 >$2"))
}
}
os.Exit(exitCode)
}
}
func parseHunspellOutput(scanner *bufio.Scanner) map[string]*TypeResult {
line := 1;
types := make(map[string]*TypeResult)
scanner.Scan()
for scanner.Scan() {
text := scanner.Text()
if text == "" {
line++;
} else {
resultType := text[0:1]
typeResult, ok := types[resultType]
if !ok {
typeResult = &TypeResult{}
types[resultType] = typeResult
}
typeResult.results = append(typeResult.results, Result{line: line, word: strings.Trim(text[1:], " ")})
}
}
return types
}