-
Notifications
You must be signed in to change notification settings - Fork 4.2k
86 lines (81 loc) · 2.99 KB
/
text-changes-analyzer.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Text Changes Analyzer
on:
pull_request:
branches:
- master
paths:
- '.github/workflows/text-changes-analyzer.yml'
- 'tools/pot_diff.py'
- 'lang/extract_json_strings.py'
- 'lang/string_extractor/**'
- 'src/*.h'
- 'src/*.cpp'
- '**.json'
permissions:
contents: read
jobs:
analyze-text-changes:
runs-on: ubuntu-20.04
steps:
- name: "Install dependencies"
run: |
sudo apt-get update
sudo apt-get install python3-pip gettext
sudo pip3 install polib pyspellchecker regex
- name: "Checkout test merge commit"
uses: actions/checkout@v4
- name: "Compute base commit and test merge commit"
id: get-commit-hash
run: |
echo "test_merge_commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "head_commit=$(git log -1 --format='%B' | grep -o -E -e 'Merge\s([0-9a-f]{40})\sinto' | grep -o -E -e '[0-9a-f]{40}')" >> $GITHUB_OUTPUT
echo "base_commit=$(git log -1 --format='%B' | grep -o -E -e 'into\s([0-9a-f]{40})$' | grep -o -E -e '[0-9a-f]{40}')" >> $GITHUB_OUTPUT
- name: "Generate translation template on test merge commit"
run: |
rm -f lang/po/cataclysm-dda.pot
./lang/update_pot.sh
cp lang/po/cataclysm-dda.pot ~/merge.pot
- name: "Checkout base commit"
uses: actions/checkout@v4
with:
ref: ${{ steps.get-commit-hash.outputs.base_commit }}
- name: "Generate translation template on base commit"
run: |
rm -f lang/po/cataclysm-dda.pot
./lang/update_pot.sh
cp lang/po/cataclysm-dda.pot ~/base.pot
- name: "Checkout test merge commit"
uses: actions/checkout@v4
with:
ref: ${{ steps.get-commit-hash.outputs.test_merge_commit }}
- name: "List text changes"
run: |
python3 ./tools/pot_diff.py ~/base.pot ~/merge.pot
- name: "Write text changes"
run: |
python3 ./tools/pot_diff.py ~/base.pot ~/merge.pot -j ~/pot_diff.json
- name: "Run spell checker unit tests"
run: |
python3 ./tools/spell_check_unit_test.py
- name: "Spell check on text changes"
run: |
python3 ./tools/spell_check_pr.py -i ~/pot_diff.json > spell_check_output
- name: "Get length of spell check output"
id: get_length
run: |
wc -c spell_check_output | grep -o '[0-9]*' > spell_check_retcode
echo "length=$(cat spell_check_retcode)" >> $GITHUB_OUTPUT
- run: echo ${{ github.event.number }} > pull_request_id
- uses: actions/upload-artifact@v4
with:
name: pull_request_id
path: pull_request_id
- uses: actions/upload-artifact@v4
with:
name: spell_check_retcode
path: spell_check_retcode
- uses: actions/upload-artifact@v4
if: steps.get_length.outputs.length >= 1
with:
name: spell_check_output
path: spell_check_output