git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jiang Xin <worldhello.net@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, Git List <git@vger.kernel.org>
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>
Subject: [PATCH v2 0/1] ci: new github-action for git-l10n code review
Date: Mon, 23 Aug 2021 22:28:20 +0800	[thread overview]
Message-ID: <20210823142821.26658-1-worldhello.net@gmail.com> (raw)
In-Reply-To: <20210822161325.22038-1-worldhello.net@gmail.com>

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

Git l10n 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 message. It would be convenient to integrate
this helper program to CI and add comments in pull request.

A repository is created for testing git-l10n CI workflow. L10n
contributors can fork and try.

- https://github.com/jiangxin/github-action-test


## Changes since v1

+ Listen to event "pull_request_target" instead of event "pull_request".
  Event "pull_request_target" provides write permissions for
  GITHUB_TOKEN, and the workflow triggered by a pull request from a fork
  repository can create new comment in the pull request.
 
+ Because for "pull_request_target", only checkout base commit of the
  target repository, add a new step "Fetch missing commits".

+ Add new option "--github-action-event <event>" for git-po-helper.

+ Add "--end-of-options" for "git rev-parse" command.


## Range diff v1...v2

1:  25c5645 ! 1:  c2618b9 ci: new github-action for git-l10n code review
    @@ Commit message
         "ci-config" and create a simple shell script at "ci/config/allow-l10n"
         in this branch.
     
    -    The new l10n workflow listens to two types of github events: push and
    -    pull_request.
    +    The new l10n workflow listens to two types of github events: "push" and
    +    "pull_request_target". The "pull_request_target" event is just like the
    +    "pull_request" event, but provides write permission to create comments
    +    for pull request.
     
    -    For a push event, it will scan commits one by one. If a commit does not
    -    look like a l10n commit (no file in "po/" has been changed), it will
    -    immediately fail without checking for further commits. While for a
    -    pull_request event, all new introduced commits will be scanned.
    +    For a "push" event, it will scan commits one by one. If a commit does
    +    not look like a l10n commit (no file in "po/" has been changed), it
    +    will immediately fail without checking for further commits. While for a
    +    "pull_request_target" event, all new introduced commits will be scanned.
     
         "git-po-helper" will generate two kinds of suggestions, errors and
         warnings. A l10n contributor should try to fix all the errors, and
         should pay attention to the warnings. All the errors and warnings will
    -    be reported in the last step of the l10n workflow as two message groups.
    -    For a pull_request event, will create additional comments in pull
    -    request to report the result.
    +    be reported in the last step of the l10n workflow with two message
    +    groups. For a "pull_request_target" event, will create additional
    +    comments in the pull request to report the result.
     
         Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
     
    @@ .github/workflows/l10n.yml (new)
     @@
     +name: git-l10n
     +
    -+on: [push, pull_request]
    ++on: [push, pull_request_target]
     +
     +jobs:
     +  ci-config:
    @@ .github/workflows/l10n.yml (new)
     +    - uses: actions/checkout@v2
     +      with:
     +        fetch-depth: '0'
    ++    - name: Fetch missing commits
    ++      id: fetch-commits
    ++      run: |
    ++        if test "${{ github.event_name }}" = "pull_request_target"
    ++        then
    ++          base=${{ github.event.pull_request.base.sha }}
    ++          head=${{ github.event.pull_request.head.sha }}
    ++        else
    ++          base=${{ github.event.before }}
    ++          head=${{ github.event.after }}
    ++        fi
    ++        for commit in $base $head
    ++        do
    ++          if echo $commit | grep -q "^00*$"
    ++          then
    ++            continue
    ++          fi
    ++          if ! git rev-parse --verify --end-of-options "$commit^{commit}" --
    ++          then
    ++            git fetch origin $commit
    ++          fi
    ++        done
    ++        echo "::set-output name=base::$base"
    ++        echo "::set-output name=head::$head"
    ++
     +    - uses: actions/setup-go@v2
     +      with:
     +        go-version: ">=1.16"
    @@ .github/workflows/l10n.yml (new)
     +      run: |
     +        sudo apt-get update -q &&
     +        sudo apt-get install -q -y gettext
    -+    - id: check-commits
    -+      name: Run git-po-helper
    ++    - name: Run git-po-helper
    ++      id: check-commits
     +      run: |
    -+        if test "${{ github.event_name }}" = "pull_request"
    -+        then
    -+          commit_from=${{ github.event.pull_request.base.sha }}
    -+          commit_to=${{ github.event.pull_request.head.sha }}
    -+        else
    -+          commit_from=${{ github.event.before }}
    -+          commit_to=${{ github.event.after }}
    -+          if ! echo $commit_from | grep -q "^00*$"
    -+          then
    -+            if ! git rev-parse "$commit_from^{commit}"
    -+            then
    -+              git fetch origin $commit_from
    -+            fi
    -+          fi
    -+        fi
     +        exit_code=0
    -+        git-po-helper check-commits --github-action -- \
    -+          $commit_from..$commit_to >git-po-helper.out 2>&1 ||
    -+        exit_code=$?
    ++        git-po-helper check-commits \
    ++            --github-action \
    ++            --github-action-event "${{ github.event_name }}" -- \
    ++            ${{ steps.fetch-commits.outputs.base }}..${{ steps.fetch-commits.outputs.head }} \
    ++            >git-po-helper.out 2>&1 ||
    ++          exit_code=$?
     +        echo "::set-output name=exit_code::$exit_code"
     +        has_error_msg=
     +        has_warning_msg=
     +        if test $exit_code -ne 0
     +        then
     +          has_error_msg=yes
    -+          if test "${{ github.event_name }}" = "pull_request"
    ++          if test "${{ github.event_name }}" = "pull_request_target"
     +          then
     +            echo "ERROR_MSG<<EOF" >>$GITHUB_ENV
     +            grep -v -e "^level=warning" -e WARNING git-po-helper.out |
    @@ .github/workflows/l10n.yml (new)
     +        if grep -q -e "^level=warning" -e WARNING git-po-helper.out
     +        then
     +          has_warning_msg=yes
    -+          if test "${{ github.event_name }}" = "pull_request"
    ++          if test "${{ github.event_name }}" = "pull_request_target"
     +          then
     +            echo "WARNING_MSG<<EOF" >>$GITHUB_ENV
     +            grep -v -e "^level=error" -e ERROR git-po-helper.out |
    @@ .github/workflows/l10n.yml (new)
     +        echo "::set-output name=has_warning_msg::$has_warning_msg"
     +    - name: Report errors in comment for pull request
     +      uses: mshick/add-pr-comment@v1
    -+      if: steps.check-commits.outputs.has_error_msg == 'yes' && github.event_name == 'pull_request'
    ++      if: steps.check-commits.outputs.has_error_msg == 'yes' && github.event_name == 'pull_request_target'
     +      continue-on-error: true
     +      with:
     +        repo-token: ${{ secrets.GITHUB_TOKEN }}
    @@ .github/workflows/l10n.yml (new)
     +          ```
     +    - name: Report warnings in comment for pull request
     +      uses: mshick/add-pr-comment@v1
    -+      if: steps.check-commits.outputs.has_warning_msg == 'yes' && github.event_name == 'pull_request'
    ++      if: steps.check-commits.outputs.has_warning_msg == 'yes' && github.event_name == 'pull_request_target'
     +      continue-on-error: true
     +      with:
     +        repo-token: ${{ secrets.GITHUB_TOKEN }}
    @@ .github/workflows/l10n.yml (new)
     +          ```
     +          ${{ env.WARNING_MSG }}
     +          ```
    -+    - name: Report and quit
    ++    - name: Final report
     +      run: |
     +        if test "${{ steps.check-commits.outputs.has_error_msg }}" = "yes"
     +        then

  parent reply	other threads:[~2021-08-23 14:28 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             ` [PATCH v4 0/1] " Jiang Xin
2021-09-09  9:09               ` [PATCH v5 " 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 ` Jiang Xin [this message]
2021-08-23 14:28 ` [PATCH v2 " 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20210823142821.26658-1-worldhello.net@gmail.com \
    --to=worldhello.net@gmail.com \
    --cc=DJm00n@mail.ru \
    --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=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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).