commit-reach(paint_down_to_common): plug two memory leaks
[git.git] / .github / workflows / l10n.yml
blobe2c3dbdcb50f0cedbf990677e234e7114ecd7746
1 name: git-l10n
3 on: [push, pull_request_target]
5 # Avoid unnecessary builds. Unlike the main CI jobs, these are not
6 # ci-configurable (but could be).
7 concurrency:
8   group: ${{ github.workflow }}-${{ github.ref }}
9   cancel-in-progress: true
11 jobs:
12   git-po-helper:
13     if: >-
14       endsWith(github.repository, '/git-po') ||
15       contains(github.head_ref, 'l10n') ||
16       contains(github.ref, 'l10n')
17     runs-on: ubuntu-latest
18     permissions:
19       pull-requests: write
20     steps:
21       - name: Setup base and head objects
22         id: setup-tips
23         run: |
24           if test "${{ github.event_name }}" = "pull_request_target"
25           then
26             base=${{ github.event.pull_request.base.sha }}
27             head=${{ github.event.pull_request.head.sha }}
28           else
29             base=${{ github.event.before }}
30             head=${{ github.event.after }}
31           fi
32           echo base=$base >>$GITHUB_OUTPUT
33           echo head=$head >>$GITHUB_OUTPUT
34       - name: Run partial clone
35         run: |
36           git -c init.defaultBranch=master init --bare .
37           git remote add \
38             --mirror=fetch \
39             origin \
40             https://github.com/${{ github.repository }}
41           # Fetch tips that may be unreachable from github.ref:
42           # - For a forced push, "$base" may be unreachable.
43           # - For a "pull_request_target" event, "$head" may be unreachable.
44           args=
45           for commit in \
46             ${{ steps.setup-tips.outputs.base }} \
47             ${{ steps.setup-tips.outputs.head }}
48           do
49             case $commit in
50             *[^0]*)
51               args="$args $commit"
52               ;;
53             *)
54               # Should not fetch ZERO-OID.
55               ;;
56             esac
57           done
58           git -c protocol.version=2 fetch \
59             --progress \
60             --no-tags \
61             --no-write-fetch-head \
62             --filter=blob:none \
63             origin \
64             ${{ github.ref }} \
65             $args
66       - uses: actions/setup-go@v5
67         with:
68           go-version: '>=1.16'
69           cache: false
70       - name: Install git-po-helper
71         run: go install github.com/git-l10n/git-po-helper@main
72       - name: Install other dependencies
73         run: |
74           sudo apt-get update -q &&
75           sudo apt-get install -q -y gettext
76       - name: Run git-po-helper
77         id: check-commits
78         run: |
79           exit_code=0
80           git-po-helper check-commits \
81             --github-action-event="${{ github.event_name }}" -- \
82             ${{ steps.setup-tips.outputs.base }}..${{ steps.setup-tips.outputs.head }} \
83             >git-po-helper.out 2>&1 || exit_code=$?
84           if test $exit_code -ne 0 || grep -q WARNING git-po-helper.out
85           then
86             # Remove ANSI colors which are proper for console logs but not
87             # proper for PR comment.
88             echo "COMMENT_BODY<<EOF" >>$GITHUB_ENV
89             perl -pe 's/\e\[[0-9;]*m//g; s/\bEOF$//g' git-po-helper.out >>$GITHUB_ENV
90             echo "EOF" >>$GITHUB_ENV
91           fi
92           cat git-po-helper.out
93           exit $exit_code
94       - name: Create comment in pull request for report
95         uses: mshick/add-pr-comment@v2
96         if: >-
97           always() &&
98           github.event_name == 'pull_request_target' &&
99           env.COMMENT_BODY != ''
100         with:
101           repo-token: ${{ secrets.GITHUB_TOKEN }}
102           message: >
103             ${{ steps.check-commits.outcome == 'failure' && 'Errors and warnings' || 'Warnings' }}
104             found by [git-po-helper](https://github.com/git-l10n/git-po-helper#readme) in workflow
105             [#${{ github.run_number }}](${{ env.GITHUB_SERVER_URL }}/${{ github.repository }}/actions/runs/${{ github.run_id }}):
107             ```
109             ${{ env.COMMENT_BODY }}
111             ```