TranslateProject/Makefile

46 lines
1.8 KiB
Makefile
Raw Normal View History

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):
2017-12-15 13:10:59 +08:00
git --no-pager diff $(TRAVIS_BRANCH) FETCH_HEAD --no-renames --name-status > $@
2017-12-15 12:37:16 +08:00
rule-source-added:
2017-12-19 23:25:26 +08:00
[ $(shell grep '^A\s\+sources/(news|talk|tech)/\d{8} [a-zA-Z0-9_.,\-\(\)\[\] ]*\.md' $(CHANGE_FILE) | wc -l) -ge 1 ]
2017-12-20 15:55:05 +08:00
[ $(shell grep -v '^A\s\+sources/(news|talk|tech)/\d{8} [a-zA-Z0-9_-.,\(\)\[\] ]*\.md' $(CHANGE_FILE) | wc -l) = 0 ]
2017-12-15 12:37:16 +08:00
echo 'Rule Matched: $(@)'
rule-translation-requested:
2017-12-19 23:25:26 +08:00
[ $(shell grep '^M\s\+sources/(news|talk|tech)/\d{8} [a-zA-Z0-9_.,\-\(\)\[\] ]*\.md' $(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:
2017-12-19 23:25:26 +08:00
[ $(shell grep '^D\s\+sources/(news|talk|tech)/\d{8} [a-zA-Z0-9_.,\-\(\)\[\] ]*\.md' $(CHANGE_FILE) | wc -l) = 1 ]
[ $(shell grep '^A\s\+translated/(news|talk|tech)/\d{8} [a-zA-Z0-9_.,\-\(\)\[\] ]*\.md' $(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:
2017-12-19 23:25:26 +08:00
[ $(shell grep '^M\s\+translated/(news|talk|tech)/\d{8} [a-zA-Z0-9_.,\-\(\)\[\] ]*\.md' $(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:
2017-12-19 23:25:26 +08:00
[ $(shell grep '^D\s\+translated/(news|talk|tech)/\d{8} [a-zA-Z0-9_.,\-\(\)\[\] ]*\.md' $(CHANGE_FILE) | wc -l) = 1 ]
[ $(shell grep '^A\s\+published/\d{8} [a-zA-Z0-9_.,\-\(\)\[\] ]*\.md' $(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: $(@)'