TranslateProject/Makefile

59 lines
2.2 KiB
Makefile
Raw Normal View History

2018-01-02 11:53:16 +08:00
DIR_PATTERN := (news|talk|tech)
NAME_PATTERN := [0-9]{8} [a-zA-Z0-9_.,() -]*\.md
2017-12-15 12:37:16 +08:00
RULES := rule-source-added \
rule-translation-requested \
rule-translation-completed \
rule-translation-revised \
rule-translation-published
.PHONY: check match $(RULES)
CHANGE_FILE := /tmp/changes
check: $(CHANGE_FILE)
echo 'PR #$(TRAVIS_PULL_REQUEST) Changes:'
cat $(CHANGE_FILE)
echo
echo 'Check for rules...'
2017-12-15 13:18:15 +08:00
make -k $(RULES) 2>/dev/null | grep '^Rule Matched: '
2017-12-15 12:37:16 +08:00
$(CHANGE_FILE):
2018-10-23 23:45:49 +08:00
git --no-pager diff $(TRAVIS_BRANCH) origin/master --no-renames --name-status > $@
2017-12-15 12:37:16 +08:00
rule-source-added:
2018-01-02 11:53:16 +08:00
echo 'Unmatched Files:'
egrep -v '^A\s*"?sources/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) || true
echo '[End of Unmatched Files]'
[ $(shell egrep '^A\s*"?sources/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) -ge 1 ]
[ $(shell egrep -v '^A\s*"?sources/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 0 ]
2017-12-15 12:37:16 +08:00
echo 'Rule Matched: $(@)'
rule-translation-requested:
2018-01-02 11:53:16 +08:00
[ $(shell egrep '^M\s*"?sources/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 1 ]
2017-12-15 13:29:34 +08:00
[ $(shell cat $(CHANGE_FILE) | wc -l) = 1 ]
2017-12-15 12:37:16 +08:00
echo 'Rule Matched: $(@)'
rule-translation-completed:
2018-01-02 11:53:16 +08:00
[ $(shell egrep '^D\s*"?sources/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 1 ]
[ $(shell egrep '^A\s*"?translated/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 1 ]
2017-12-15 13:29:34 +08:00
[ $(shell cat $(CHANGE_FILE) | wc -l) = 2 ]
2017-12-15 12:37:16 +08:00
echo 'Rule Matched: $(@)'
rule-translation-revised:
2018-01-02 11:53:16 +08:00
[ $(shell egrep '^M\s*"?translated/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 1 ]
2017-12-15 13:29:34 +08:00
[ $(shell cat $(CHANGE_FILE) | wc -l) = 1 ]
2017-12-15 12:37:16 +08:00
echo 'Rule Matched: $(@)'
rule-translation-published:
2018-01-02 11:53:16 +08:00
[ $(shell egrep '^D\s*"?translated/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 1 ]
[ $(shell egrep '^A\s*"?published/$(NAME_PATTERN)' $(CHANGE_FILE) | wc -l) = 1 ]
2017-12-15 13:29:34 +08:00
[ $(shell cat $(CHANGE_FILE) | wc -l) = 2 ]
2017-12-15 12:37:16 +08:00
echo 'Rule Matched: $(@)'
2018-10-23 18:14:35 +08:00
2018-10-23 20:13:32 +08:00
badge:
2018-10-23 20:55:20 +08:00
mkdir -p build/badge
./lctt-scripts/show_status.sh -s published >build/badge/published.svg
./lctt-scripts/show_status.sh -s translated >build/badge/translated.svg
./lctt-scripts/show_status.sh -s translating >build/badge/translating.svg
./lctt-scripts/show_status.sh -s sources >build/badge/sources.svg