abstractdog commented on code in PR #6953:
URL: https://github.com/apache/hive/pull/6953#discussion_r4551548234


##########
.github/workflows/precommit-image.yml:
##########
@@ -0,0 +1,85 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Builds the precommit image (dev-support/docker/precommit) and smoke tests 
it. On master it
+# publishes the image as apache/hive-ci-runner, the image the Jenkinsfile runs 
in.
+name: Precommit image
+
+on:
+  pull_request:
+    paths:
+      - 'dev-support/docker/precommit/**'
+      - '.github/workflows/precommit-image.yml'
+  push:
+    branches:
+      - master
+    paths:
+      - 'dev-support/docker/precommit/**'
+      - '.github/workflows/precommit-image.yml'
+  workflow_dispatch:
+    inputs:
+      tag:
+        description: 'Tag to publish; use a custom one (e.g. HIVE-12345) to 
try an image with the IMAGE parameter of the precommit job'
+        required: true
+        default: 'latest'
+
+permissions:
+  contents: read
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    env:
+      IMAGE: ${{ github.repository_owner }}/hive-ci-runner:${{ 
github.event.inputs.tag || 'latest' }}
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v6
+        with:
+          persist-credentials: false
+
+      - name: Set up QEMU
+        uses: 
docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
+
+      - name: Set up Docker Buildx
+        uses: 
docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
+
+      - name: Build the image
+        uses: 
docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
+        with:
+          context: ./dev-support/docker/precommit/
+          load: true
+          tags: hive-precommit:test
+
+      - name: Smoke test the image
+        run: |
+          docker images hive-precommit:test
+          dev-support/docker/precommit/smoke-test.sh hive-precommit:test
+
+      - name: Login to Docker Hub
+        if: github.event_name != 'pull_request' && github.repository == 
'apache/hive'

Review Comment:
   I'd keep the `github.repository == 'apache/hive'` guard on login and 
publish: publishing only makes sense for `apache/hive-ci-runner`, and a fork 
has neither the `DOCKERHUB_*` secrets nor push rights to it. A fork still 
builds the image on its own PRs and manual runs, and with the job-level 
condition I just added, a push to a fork's master (i.e. syncing the fork) 
doesn't run the workflow at all. A contributor who wants to try an image 
doesn't need the workflow: they push it to their own namespace with `docker 
buildx build --push` and run precommit with `IMAGE=...` (README, step 3).
   
   Regarding how I tested: I was able to push the feature branch to the origin, 
so I can do it, I'll let you know as the docker namespace is already there: 
https://hub.docker.com/r/apache/hive-ci-runner



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