All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiang Xin <worldhello.net@gmail.com>
To: Git List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Jeff King <peff@peff.net>
Cc: "Jiang Xin" <zhiyou.jx@alibaba-inc.com>,
	"Alexander Shopov" <ash@kambanaria.org>,
	"Jordi Mas" <jmas@softcatala.org>,
	"Matthias Rüster" <matthias.ruester@gmail.com>,
	"Jimmy Angelakos" <vyruss@hellug.gr>,
	"Christopher Díaz" <christopher.diaz.riv@gmail.com>,
	"Jean-Noël Avila" <jn.avila@free.fr>,
	"Bagas Sanjaya" <bagasdotme@gmail.com>,
	"Alessandro Menti" <alessandro.menti@alessandromenti.it>,
	"Gwan-gyeong Mun" <elongbug@gmail.com>, Arusekk <arek_koz@o2.pl>,
	"Daniel Santos" <daniel@brilhante.top>,
	"Dimitriy Ryazantcev" <DJm00n@mail.ru>,
	"Peter Krefting" <peter@softwolves.pp.se>,
	"Emir SARI" <bitigchi@me.com>,
	"Trần Ngọc Quân" <vnwildman@gmail.com>,
	"Fangyi Zhou" <me@fangyi.io>, "Yi-Jyun Pan" <pan93412@gmail.com>,
	"Jiang Xin" <worldhello.net@gmail.com>
Subject: [PATCH v4 0/1] ci: new github-action for git-l10n code review
Date: Thu,  2 Sep 2021 10:31:38 +0800	[thread overview]
Message-ID: <20210902023139.89251-1-worldhello.net@gmail.com> (raw)
In-Reply-To: <CANYiYbESO7bvyuRcypmVKvqAdLk5492q5fUPu5ArdCY5PHzFSQ@mail.gmail.com>

From: Jiang Xin <zhiyou.jx@alibaba-inc.com>

## Changes since v3

* Update commit message.

* Wrap the long if conditions to make them easier to read. See:
  https://yaml-multiline.info/

* Create partial clone using one command by adding "--filter=blob:none"
  option to "git fetch".

* In the if condition of the last step, use `env.COMMENT_BODY != ''`,
  and do not need "steps.check-commits.outputs.create_comment".


## range-diff v3...v4

1:  06a6c1c ! 1:  0067ccc ci: new github-action for git-l10n code review
    @@ Metadata
      ## Commit message ##
         ci: new github-action for git-l10n code review
     
    -    Repository of git-l10n is a fork from "git/git" on GitHub, and uses
    +    The repository of git-l10n is a fork of "git/git" on GitHub, and uses
         GitHub pull request for code review. A helper program "git-po-helper"
         can be used to check typos in ".po" files, validate syntax, and check
         commit messages. It would be convenient to integrate this helper program
         to CI and add comments in pull request.
     
    -    The new github-action workflow is added in ".github/workflows/". It will
    -    only be enabled for the following cases:
    +    The new github-action workflow will be enabled for l10n related
    +    operations, such as:
     
    -     * A repository named as "git-po", such as a repository forked from
    -       "git-l10n/git-po".
    +     * Operations on a repository named as "git-po", such as a repository
    +       forked from "git-l10n/git-po".
     
    -     * Push to the branch that contains "l10n" in the name.
    +     * Push to a branch that contains "l10n" in the name.
     
    -     * Pull reqeust from a remote branch which has "l10n" in the name, such
    +     * Pull request from a remote branch which has "l10n" in the name, such
            as: "l10n/fix-fuzzy-translations".
     
         The new l10n workflow listens to two types of github events:
    @@ Commit message
             on: [push, pull_request_target]
     
         The reason we use "pull_request_target" instead of "pull_request" is
    -    that for security reasons, pull requests from forks receive a read-only
    -    GITHUB_TOKEN and workflows cannot write comments back to pull requests.
    -    GitHub provides a "pull_request_target" event to resolve security risks
    -    by checking out the base commit from the target repository, and provide
    -    write permissions for the workflow.
    +    that pull requests from forks receive a read-only GITHUB_TOKEN and
    +    workflows cannot write comments back to pull requests for security
    +    reasons. GitHub provides a "pull_request_target" event to resolve
    +    security risks by checking out the base commit from the target
    +    repository, and provide write permissions for the workflow.
     
    -    By default, adminstrators can set strict permissions for workflows. The
    +    By default, administrators can set strict permissions for workflows. The
         following code is used to modify the permissions for the GITHUB_TOKEN
    -    and give write permission in order to create comments in pull-requests.
    +    and grant write permission in order to create comments in pull-requests.
     
             permissions:
               pull-requests: write
    @@ Commit message
         like a l10n commit (no file in "po/" has been changed), the scan process
         will stop immediately. For a "push" event, no error will be reported
         because it is normal to push non-l10n commits merged from upstream. But
    -    for the "pull_request_target" event, errors will be reported.
    -    For this reason, additional option is provided for "git-po-helper".
    +    for the "pull_request_target" event, errors will be reported. For this
    +    reason, additional option is provided for "git-po-helper".
     
             git-po-helper check-commits \
                 --github-action-event="${{ github.event_name }}" -- \
    @@ Commit message
         package named "logrus" for logging, and I use an additional option
         "ForceColor" to initialize "logrus" to print messages in a user-friendly
         format in logfile output. These color codes help produce beautiful
    -    output for logs of workflow, but they must be stripped off when creating
    -    comments for pull requests. E.g.:
    +    output for the log of workflow, but they must be stripped off when
    +    creating comments for pull requests. E.g.:
     
             perl -pe 's/\e\[[0-9;]*m//g' git-po-helper.out
     
         "git-po-helper" may generate two kinds of suggestions, errors and
    -    warnings. All the errors and warnings will be reported in the log
    -    the l10n workflow. For a "pull_request_target" event, an additional
    -    comment will be created in the pull request to report the result.
    -    A l10n contributor should try to fix all the errors, and should pay
    -    attention to the warnings.
    +    warnings. All the errors and warnings will be reported in the log of the
    +    l10n workflow. However, warnings in the log of the workflow for a
    +    successfully running "git-po-helper" can easily be ignored by users.
    +    For the "pull_request_target" event, this issue is resolved by creating
    +    an additional comment in the pull request. A l10n contributor should try
    +    to fix all the errors, and should pay attention to the warnings.
     
         Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
         Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
    @@ .github/workflows/l10n.yml (new)
     +
     +jobs:
     +  git-po-helper:
    -+    if: endsWith(github.repository, '/git-po') || contains(github.head_ref, 'l10n') || contains(github.ref, 'l10n')
    ++    if: >-
    ++      endsWith(github.repository, '/git-po') ||
    ++      contains(github.head_ref, 'l10n') ||
    ++      contains(github.ref, 'l10n')
     +    runs-on: ubuntu-latest
     +    permissions:
     +      pull-requests: write
    @@ .github/workflows/l10n.yml (new)
     +      - name: Fetch missing commits
     +        id: fetch-commits
     +        run: |
    -+          # Setup partial clone.
    -+          git config remote.origin.promisor true
    -+          git config remote.origin.partialCloneFilter blob:none
     +          if test "${{ github.event_name }}" = "pull_request_target"
     +          then
     +            base=${{ github.event.pull_request.base.sha }}
    @@ .github/workflows/l10n.yml (new)
     +              ;;
     +            esac
     +          done
    -+          # Unshallow the repository, and fetch missing commits.
    -+          # "$base" may be missing due to forced push, and "$head"
    ++          # Unshallow the repository, and fetch missing commits using partial
    ++          # clone.  "$base" may be missing due to forced push, and "$head"
     +          # may be missing due to the "pull_request_target" event.
    -+          git fetch --unshallow origin $args
    ++          git fetch --unshallow --filter=blob:none origin $args
     +          echo "::set-output name=base::$base"
     +          echo "::set-output name=head::$head"
     +      - uses: actions/setup-go@v2
    @@ .github/workflows/l10n.yml (new)
     +        id: check-commits
     +        run: |
     +          exit_code=0
    -+          create_comment=
     +          git-po-helper check-commits \
     +              --github-action-event="${{ github.event_name }}" -- \
     +              ${{ steps.fetch-commits.outputs.base }}..${{ steps.fetch-commits.outputs.head }} \
     +              >git-po-helper.out 2>&1 ||
     +            exit_code=$?
    -+          if test $exit_code -ne 0 ||
    -+            grep -q -e "^level=warning" -e WARNING git-po-helper.out
    ++          if test $exit_code -ne 0 || grep -q WARNING git-po-helper.out
     +          then
    -+            create_comment=yes
     +            # Remove ANSI colors which are proper for console logs but not
     +            # proper for PR comment.
     +            echo "COMMENT_BODY<<EOF" >>$GITHUB_ENV
     +            perl -pe 's/\e\[[0-9;]*m//g; s/\bEOF$//g' git-po-helper.out >>$GITHUB_ENV
     +            echo "EOF" >>$GITHUB_ENV
     +          fi
    -+          echo "::set-output name=create_comment::$create_comment"
     +          cat git-po-helper.out
     +          exit $exit_code
    -+      - name: Report in comment for pull request
    ++      - name: Create comment in pull request for report
     +        uses: mshick/add-pr-comment@v1
    -+        if: always() && steps.check-commits.outputs.create_comment== 'yes' && github.event_name == 'pull_request_target'
    -+        continue-on-error: true
    ++        if: >-
    ++          always() &&
    ++          github.event_name == 'pull_request_target' &&
    ++          env.COMMENT_BODY != ''
     +        with:
     +          repo-token: ${{ secrets.GITHUB_TOKEN }}
     +          repo-token-user-login: 'github-actions[bot]'
    -+          message: |
    -+            ${{ steps.check-commits.outcome == 'failure' && 'Errors and warnings' || 'Warnings' }} found by [git-po-helper](https://github.com/git-l10n/git-po-helper#readme) in workflow [#${{ github.run_number }}](${{ env.GITHUB_SERVER_URL }}/${{ github.repository }}/actions/runs/${{ github.run_id }}):
    ++          message: >
    ++            ${{ steps.check-commits.outcome == 'failure' && 'Errors and warnings' || 'Warnings' }}
    ++            found by [git-po-helper](https://github.com/git-l10n/git-po-helper#readme) in workflow
    ++            [#${{ github.run_number }}](${{ env.GITHUB_SERVER_URL }}/${{ github.repository }}/actions/runs/${{ github.run_id }}):
     +
     +            ```
    ++
     +            ${{ env.COMMENT_BODY }}
    ++
     +            ```

## diff stat

Jiang Xin (1):
  ci: new github-action for git-l10n code review

 .github/workflows/l10n.yml | 93 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100644 .github/workflows/l10n.yml

-- 
2.33.0

  parent reply	other threads:[~2021-09-02  2:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-22 16:13 [PATCH 0/1] ci: new github-action for git-l10n code review Jiang Xin
2021-08-22 16:13 ` [PATCH 1/1] " Jiang Xin
2021-08-23  6:28   ` Bagas Sanjaya
2021-08-23  6:42     ` Jiang Xin
2021-08-23 21:02   ` Johannes Schindelin
2021-08-23 21:36     ` Junio C Hamano
2021-08-24  9:27       ` Johannes Schindelin
2021-08-24 19:04         ` Junio C Hamano
2021-08-24 21:34         ` Jean-Noël AVILA
2021-08-31  1:03           ` Jiang Xin
2021-08-24 13:36       ` Jiang Xin
2021-08-24 19:06         ` Junio C Hamano
2021-08-24 13:21     ` Jiang Xin
2021-08-25 12:14       ` Johannes Schindelin
2021-08-26  2:25         ` Jiang Xin
2021-08-27  2:10         ` Jeff King
2021-08-27  2:49           ` Jiang Xin
2021-08-27  7:13             ` [PATCH v3] " Jiang Xin
2021-09-02  2:31             ` Jiang Xin [this message]
2021-09-09  9:09               ` [PATCH v5 0/1] " Jiang Xin
2021-09-09  9:09               ` [PATCH v5 1/1] " Jiang Xin
2021-09-02  2:31             ` [PATCH v4 " Jiang Xin
2021-08-23 14:28 ` [PATCH v2 0/1] " Jiang Xin
2021-08-23 14:28 ` [PATCH v2 1/1] " Jiang Xin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210902023139.89251-1-worldhello.net@gmail.com \
    --to=worldhello.net@gmail.com \
    --cc=DJm00n@mail.ru \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=alessandro.menti@alessandromenti.it \
    --cc=arek_koz@o2.pl \
    --cc=ash@kambanaria.org \
    --cc=bagasdotme@gmail.com \
    --cc=bitigchi@me.com \
    --cc=christopher.diaz.riv@gmail.com \
    --cc=daniel@brilhante.top \
    --cc=elongbug@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jmas@softcatala.org \
    --cc=jn.avila@free.fr \
    --cc=matthias.ruester@gmail.com \
    --cc=me@fangyi.io \
    --cc=pan93412@gmail.com \
    --cc=peff@peff.net \
    --cc=peter@softwolves.pp.se \
    --cc=vnwildman@gmail.com \
    --cc=vyruss@hellug.gr \
    --cc=zhiyou.jx@alibaba-inc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.