File: text-changes-analyzer.yml

package info (click to toggle)
cataclysm-dda 0.H-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 710,808 kB
  • sloc: cpp: 524,019; python: 11,580; sh: 1,228; makefile: 1,169; xml: 507; javascript: 150; sql: 56; exp: 41; perl: 37
file content (83 lines) | stat: -rw-r--r-- 2,964 bytes parent folder | download
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
name: Text Changes Analyzer


on:
  pull_request:
    branches:
      - 0.H-branch
    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
      - name: "Checkout test merge commit"
        uses: actions/checkout@v3
      - 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@v3
        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@v3
        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: "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@v3.1.2
        with:
          name: pull_request_id
          path: pull_request_id
      - uses: actions/upload-artifact@v3.1.2
        with:
          name: spell_check_retcode
          path: spell_check_retcode
      - uses: actions/upload-artifact@v3.1.2
        if: steps.get_length.outputs.length >= 1
        with:
          name: spell_check_output
          path: spell_check_output