Yikun commented on code in PR #37005:
URL: https://github.com/apache/spark/pull/37005#discussion_r916427024


##########
.github/workflows/build_and_test.yml:
##########
@@ -251,13 +251,73 @@ jobs:
         name: unit-tests-log-${{ matrix.modules }}-${{ matrix.comment }}-${{ 
matrix.java }}-${{ matrix.hadoop }}-${{ matrix.hive }}
         path: "**/target/unit-tests.log"
 
-  pyspark:
+  infra-image:
     needs: precondition
-    if: fromJson(needs.precondition.outputs.required).pyspark == 'true'
+    # Currently, only enable docker build from cache for `master` branch jobs
+    if: fromJson(needs.precondition.outputs.required).pyspark == 'true' && ${{ 
inputs.branch }} == 'master'
+    runs-on: ubuntu-latest
+    outputs:
+      image_url: ${{ steps.infra-image-outputs.outputs.image_url }}
+    steps:
+      - name: Generate image name and url
+        id: infra-image-outputs
+        run: |
+          # Convert to lowercase to meet docker repo name requirement
+          REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' 
'[:lower:]')
+          IMG_NAME="apache-spark-ci-image:${{ inputs.branch }}-${{ 
github.run_id }}"
+          IMG_URL="ghcr.io/$REPO_OWNER/$IMG_NAME"
+          echo ::set-output name=image_url::$IMG_URL
+      - name: Login to GitHub Container Registry
+        uses: docker/login-action@v2
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}

Review Comment:
   Case 1: The developer push a commit: ==> OK (CI passed!)
   - github.actor: `yikun`
   - generate and use image like `yikun/apache-spark-ci-image:master-xxx`
   
   Case 2: The apache/spark merge a commit in master: ==> should OK 
(**committer need has right to push apache package**)
   - ${{ github.actor }}: such `HyukjinKwon` (who merge the commit)
   - ${{ github.repository_owner }}: `apache`
   - generate and use image like `apache/apache-spark-ci-image:master-xxx`
   - we can't use ${{ github.actor }} `HyukjinKwon`, [no 
rights](https://github.com/spark-arm/docker-cache/runs/7245907037?check_suite_focus=true#step:8:135)
 to push apache image
   - local test 
[here](https://github.com/spark-arm/docker-cache/runs/7245965814?check_suite_focus=true#step:8:136)
   
   Case 3: The scheduler jobs for master job:  ==> should OK (**committer need 
has right to push apache package**)
   - ${{ github.actor }}: such `HyukjinKwon` ([The latest user who create the 
schedule trigger will be the actor for the schedule 
workflow](https://github.community/t/who-will-be-the-github-actor-when-a-workflow-runs-on-a-schedule/17369))
   - ${{ github.repository_owner }}: `apache`
   - generate and use image like `apache/apache-spark-ci-image:master-xxx`
   
   Case 4: The scheduler jobs for branches job  ==> OK
   - Use branches image cache directly 
(`dongjoon/apache-spark-github-action-image:20220207`, future is 
`spark/apache-spark-github-action-image-cache:branches-*`)
   
   Case 5: The developer push a commit in branches: ==> OK
   Case 6: The apache/spark merge a commit in branches: ==> OK
   - use branches workflow, no change by this pr
   - When cut branches, will same as case 1 & case 2
   
   



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to