damccorm commented on code in PR #27852:
URL: https://github.com/apache/beam/pull/27852#discussion_r1285957106


##########
.github/workflows/README.md:
##########
@@ -19,13 +19,71 @@
 
 On top of normal Actions workflow steps, all new CI workflows (excluding 
release workflows or other workflow automation) should have the following:
 
-1) A set of specific triggers
-2) An explicit checkout step
-3) A set of GitHub token permissions
-4) Concurrency Groups
-5) Comment Triggering Support
+1) Name and phrase set via matrix for re-run to work (See below)
+2) A set of specific triggers
+3) An explicit checkout step
+4) A set of GitHub token permissions
+5) Concurrency Groups
+6) Comment Triggering Support
 
 Each of these is described in more detail below.
+## Name and Phrase
+Due to specifics on how the comment triggered rerun is handled it is required 
that all jobs have name and phrase set via matrix elements. See the following 
example:
+```
+jobs:
+  beam_job_name:
+    name: ${{ matrix.job_name }} (${{ matrix.job_phrase }})
+    strategy:
+      matrix:
+        job_name: [beam_job_name]
+        job_phrase: [Run Job Phrase]
+    if: |
+      github.event_name == 'push' ||
+      github.event_name == 'pull_request_target' ||
+      github.event_name == 'schedule' ||
+      github.event_name == 'workflow_dispatch' ||
+      github.event.comment.body == 'Run Job Phrase'
+    steps:
+      - uses: actions/checkout@v3
+      - name: Setup repository
+        uses: ./.github/actions/setup-action
+        with:
+          comment_phrase: ${{ matrix.job_phrase }}
+          github_token: ${{ secrets.GITHUB_TOKEN }}
+          github_job: ${{ matrix.job_name }} (${{ matrix.job_phrase }})
+
+```
+And in case when the workflow already utilizes matrix do the following:
+```
+jobs:
+  beam_job_with_matrix:
+    name: ${{ matrix.job_name }} (${{ matrix.job_phrase }} ${{ 
matrix.python_version }})
+    runs-on: [self-hosted, ubuntu-20.04, main]
+    timeout-minutes: 30
+    strategy:
+      fail-fast: false
+      matrix:
+        job_name: ["beam_job_with_matrix"]
+        job_phrase: ["Run Job With Matrix"]
+        python_version: ['3.8','3.9','3.10','3.11']
+    if: |
+      github.event_name == 'push' || 
+      github.event_name == 'pull_request_target' || 
+      github.event_name == 'schedule' ||
+      (github.event.comment.body == 'Run Job With Matrix 3.8' || 
+      github.event.comment.body == 'Job With Matrix 3.9' ||

Review Comment:
   I was suggesting early exiting the whole flow from setup-action
   
   > We could implement gh run cancel but it would be really hard because the 
parrallel instances launched. In normal usage 3/4 (python example) instances 
would have to detect if the mismatch is because someone put "Run xxxx 3.8" or 
"Run xxxx".
   
   I don't think we need to make this distinction. If the job in question is 
Python 3.8, we can still early exit on anything other than `Run 
Python_Precommit 3.8`, its ok if typos don't trigger the job correctly. We 
could even allow triggering all jobs together with `Run Python_Precommit` 
pretty easily
   
   So the step in setup-action would be something like:
   
   ```
   if: github.event.comment.body != '${{ inputs.comment_phrase }}' and 
github.event.comment.body != '${{ inputs.comment_phrase }} ${{ inputs.version 
}}' # version would now need to be passed in
   run: |
         echo 'comment does not match this jobs trigger phrase ${{ 
inputs.comment_phrase }} ${{ inputs.version }}'
         gh run cancel ${{ inputs.github_current_run_id }}
         gh run watch ${{ inputs.github_current_run_id }}
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to