mirror of
https://github.com/ru-de/faq.git
synced 2024-11-21 18:02:23 +00:00
Github Actions for checks (#574)
* github actions ci * github actions ci * github actions ci * github actions ci * github actions ci * github actions ci * no deprecation * debug * debug * debug * fix * fix * fix * fix * fix * forgotten files * fix * fix * fix * fix * oganize everything related to ci in one folder * add check * fix path * get changed files * try this env * expected codes file moved * test check * test check * test check * docker for local test ci and fix dict download * local setup and some updates * rollback * right email
This commit is contained in:
parent
fe05229112
commit
9788ccd5e1
@ -1,4 +1,4 @@
|
||||
name: Update github pages
|
||||
name: Continuous delivery
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -6,6 +6,19 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
sort_dictionary:
|
||||
if: github.repository == 'ru-de/faq'
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Sort dictionary
|
||||
run: |
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "Github Actions"
|
||||
LC_ALL=ru_RU.UTF8 sort files/ci/dictionary.dic -o files/ci/dictionary.dic -f
|
||||
if ! git diff HEAD --quiet; then git commit -q -am "dictionary rearrangement" && git push; fi
|
||||
update_github_pages:
|
||||
if: github.repository == 'ru-de/faq'
|
||||
runs-on: ubuntu-18.04
|
||||
@ -13,7 +26,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 100
|
||||
- name: update
|
||||
- name: Update github pages
|
||||
run: |
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "Github Actions"
|
23
.github/workflows/ci.yml
vendored
Normal file
23
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
name: Continious integration
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
spell_and_dead_links_checks:
|
||||
if: github.repository == 'ru-de/faq'
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
stable: 'false'
|
||||
go-version: '1.15.4'
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Install utils
|
||||
run: |
|
||||
sudo bash files/ci/check-install.sh
|
||||
- name: Check spell and dead links
|
||||
run: |
|
||||
bash files/ci/check.sh
|
21
.github/workflows/sort_dictionary.yml
vendored
21
.github/workflows/sort_dictionary.yml
vendored
@ -1,21 +0,0 @@
|
||||
name: Sort dictionary
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
sort_dictionary:
|
||||
if: github.repository == 'ru-de/faq'
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: sort
|
||||
run: |
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "Github Actions"
|
||||
LC_ALL=ru_RU.UTF8 sort files/dictionary.dic -o files/dictionary.dic -f
|
||||
if ! git diff HEAD --quiet; then git commit -q -am "dictionary rearrangement" && git push; fi
|
19
.travis.yml
19
.travis.yml
@ -1,19 +0,0 @@
|
||||
language: go
|
||||
sudo: required
|
||||
|
||||
dist: trusty
|
||||
|
||||
git:
|
||||
depth: 3
|
||||
submodules: false
|
||||
|
||||
install:
|
||||
- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace:$GOPATH"
|
||||
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
|
||||
- sudo env PATH=$PATH GOPATH=$GOPATH bash files/check-install.sh
|
||||
|
||||
script:
|
||||
- bash files/check.sh
|
||||
|
||||
notifications:
|
||||
email: false
|
@ -30,5 +30,5 @@
|
||||
|
||||
После создания Pull Request измененные файлы будут проверены роботом на содержание орфографических ошибок и недоступные ссылки, дождитесь пожалуйста
|
||||
выполнения проверок, если какой-то check не прошел, посмотрите лог, возможно где-то допущена опечатка, использовано не словарное слово, либо ссылка на какую-то страницу недоступна.
|
||||
В случае если слово, на которое ругается проверка является широко употребимым, можно внести его в словарь, для этого добавьте его в файл "files/dictionary.dic".
|
||||
В случае если ссылка на самом деле доступна, но отдает нестандартный ответ, можно внести такой ответ как корректный в файл "files/known_url.csv"
|
||||
В случае если слово, на которое ругается проверка является широко употребимым, можно внести его в словарь, для этого добавьте его в файл "files/ci/dictionary.dic".
|
||||
В случае если ссылка на самом деле доступна, но отдает нестандартный ответ, можно внести такой ответ как корректный в файл "files/ci/expected_codes.csv"
|
@ -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
files/ci/Dockerfile
Normal file
11
files/ci/Dockerfile
Normal 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
|
@ -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
|
@ -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
|
@ -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
|
@ -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,
|
@ -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
files/ci/go/go.mod
Normal file
10
files/ci/go/go.mod
Normal 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
files/ci/go/go.sum
Normal file
11
files/ci/go/go.sum
Normal 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=
|
Loading…
Reference in New Issue
Block a user