mirror of
https://github.com/ru-de/faq.git
synced 2024-11-09 12:11:02 +00:00
исправление travis и локальный docker-compose для проверок (#327)
This commit is contained in:
parent
723634d04e
commit
5e51dc9f51
13
.travis.yml
13
.travis.yml
@ -3,19 +3,10 @@ sudo: required
|
||||
before_install:
|
||||
- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace:$GOPATH"
|
||||
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
|
||||
- sudo apt-get -qq update
|
||||
- sudo apt-get install -y hunspell hunspell-ru hunspell-en-us hunspell-de-de
|
||||
- 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
|
||||
- echo -n "/@@download[^\"]+" >> .current_release
|
||||
- cat .dict_page | grep -oP -f .current_release | wget -q -i - -O dictionary.otx
|
||||
- unzip dictionary.otx
|
||||
- git config core.quotepath false
|
||||
- go get -u github.com/russross/blackfriday-tool
|
||||
- sudo env PATH=$PATH GOPATH=$GOPATH sh files/check-install.sh
|
||||
|
||||
script:
|
||||
- sh files/.travis.sh
|
||||
- sh files/check.sh
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
9
files/Dockerfile
Normal file
9
files/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
# check https://docs.travis-ci.com/user/common-build-problems/#Running-a-Container-Based-Docker-Image-Locally
|
||||
FROM travisci/ci-garnet:packer-1512502276-986baf0
|
||||
MAINTAINER Evgenii Sokolov <e.sokolov@sevensenders.com>
|
||||
|
||||
ENV GOPATH "/home/travis/gopath"
|
||||
ENV GOROOT "/home/travis/.gimme/versions/go1.7.4.linux.amd64"
|
||||
ENV PATH "$GOPATH/bin:$GOROOT/bin:$PATH"
|
||||
COPY check-install.sh /tmp
|
||||
RUN sh /tmp/check-install.sh
|
32
files/check-install.sh
Normal file
32
files/check-install.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
apt-get -qq update
|
||||
apt-get install -y hunspell hunspell-ru hunspell-en-us hunspell-de-de
|
||||
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
|
||||
echo -n "/@@download[^\"]+" >> .current_release
|
||||
cat .dict_page | grep -oP -f .current_release | wget -q -i - -O /tmp/dictionary.otx
|
||||
unzip /tmp/dictionary.otx -d /tmp
|
||||
cp /tmp/*.dic /usr/share/hunspell
|
||||
cp /tmp/*.aff /usr/share/hunspell
|
||||
chmod +r /usr/share/hunspell/*
|
||||
|
||||
dicList=""russian-aot""
|
||||
for dic in $dicList
|
||||
do
|
||||
cat /usr/share/hunspell/$dic.dic | iconv --from KOI8-R --to UTF-8 > /usr/share/hunspell/$dic-utf8.dic
|
||||
cat /usr/share/hunspell/$dic.aff | iconv --from KOI8-R --to UTF-8 | sed 's/SET KOI8-R/SET UTF-8/' > /usr/share/hunspell/$dic-utf8.aff
|
||||
done
|
||||
|
||||
dicList=""de_DE" "en_US""
|
||||
for dic in $dicList
|
||||
do
|
||||
cat /usr/share/hunspell/$dic.dic | iconv --from ISO8859-1 --to UTF-8 > /usr/share/hunspell/$dic-utf8.dic
|
||||
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
|
||||
|
||||
git config --global core.quotepath false
|
||||
go get -u github.com/russross/blackfriday-tool
|
@ -3,21 +3,20 @@
|
||||
DIR=`dirname $0`
|
||||
EXIT_CODE=0
|
||||
|
||||
find *.md -exec blackfriday-tool {} {}.html \;
|
||||
go build -o $DIR/spell-checker $DIR/spell-checker.go
|
||||
cat $DIR/dictionary.dic | tr '\n' '|' | sed 's/\x27/\\x27/g' > /tmp/dictionary_processed
|
||||
|
||||
cat $DIR/dictionary.dic | tr '\n' '|' | sed 's/\x27/\\x27/g' > dictionary_processed
|
||||
|
||||
DICT_REGEXP=$(cat dictionary_processed | sed 's/|/[^[:alnum:]]\\|/g')
|
||||
DICT_REGEXP_EOF=$(cat dictionary_processed | sed 's/|$//g' | sed 's/|/$\\|/g')
|
||||
DICT_REGEXP=$(cat /tmp/dictionary_processed | sed 's/|/[^[:alnum:]]\\|/g')
|
||||
DICT_REGEXP_EOF=$(cat /tmp/dictionary_processed | sed 's/|$//g' | sed 's/|/$\\|/g')
|
||||
DICT_REGEXP="$DICT_REGEXP$DICT_REGEXP_EOF$"
|
||||
|
||||
git diff HEAD^ --name-status | grep "^D" -v | sed 's/^.\t//g' | grep "\.md$" > changed_files
|
||||
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
|
||||
|
||||
while read FILE; do
|
||||
echo -n "Проверка файла $FILE на опечатки... ";
|
||||
|
||||
OUTPUT=$(cat "$FILE" | sed "s/$DICT_REGEXP//gi" | sed 's/https\?:[^ ]*//g' | sed "s/[(][^)]*\.md[)]//g" | hunspell -d russian-aot,ru_RU,de_DE,en_US | $DIR/spell-checker);
|
||||
OUTPUT=$(cat "$FILE" | sed "s/$DICT_REGEXP//gi" | sed 's/https\?:[^ ]*//g' | sed "s/[(][^)]*\.md[)]//g" | hunspell -d russian-aot-utf8,ru_RU,de_DE-utf8,en_US-utf8 | /tmp/spell-checker);
|
||||
OUTPUT_EXIT_CODE=$?
|
||||
|
||||
if [ $OUTPUT_EXIT_CODE -ne 0 ]; then
|
||||
@ -28,14 +27,13 @@ while read FILE; do
|
||||
echo "пройдена";
|
||||
fi
|
||||
|
||||
echo
|
||||
done < changed_files
|
||||
rm -f /tmp/file.html
|
||||
blackfriday-tool $FILE /tmp/file.html
|
||||
|
||||
while read FILE; do
|
||||
if [ -f "${FILE}.html" ]; then
|
||||
grep -Po '(?<=href=")http[^"]*(?=")' "${FILE}.html" > links
|
||||
if [ -f "/tmp/file.html" ]; then
|
||||
grep -Po '(?<=href=")http[^"]*(?=")' "/tmp/file.html" > /tmp/links
|
||||
|
||||
if [ -s links ]; then
|
||||
if [ -s /tmp/links ]; then
|
||||
echo "Проверка файла $FILE на недоступные ссылки... ";
|
||||
|
||||
while read LINK; do
|
||||
@ -54,11 +52,13 @@ while read FILE; do
|
||||
echo
|
||||
fi
|
||||
|
||||
done < links
|
||||
done < /tmp/links
|
||||
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
done < changed_files
|
||||
|
||||
echo
|
||||
done < /tmp/changed_files
|
||||
|
||||
exit $EXIT_CODE
|
12
files/docker-compose.yml
Normal file
12
files/docker-compose.yml
Normal file
@ -0,0 +1,12 @@
|
||||
version: "3.2"
|
||||
|
||||
services:
|
||||
ru_de_checker:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: ru_de_checker
|
||||
user: travis
|
||||
command: bash -c "env && cd /home/travis/ru-de-faq && sh files/check.sh"
|
||||
volumes:
|
||||
- ../.:/home/travis/ru-de-faq
|
Loading…
Reference in New Issue
Block a user