XComp commented on code in PR #23970:
URL: https://github.com/apache/flink/pull/23970#discussion_r1447181164


##########
.github/workflows/template.flink-ci.yml:
##########
@@ -0,0 +1,438 @@
+# 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.
+
+# Workflow template for triggering the Flink's test suite.
+
+name: "Apache Flink Test Workflow Template"
+
+on:
+  workflow_call:
+    inputs:
+      workflow-caller-id:
+        description: "The calling job's ID that can be used for build artifact 
names (that need to be different between different jobs of the same workflow)."
+        default: ""
+        type: string
+      environment:
+        description: "Defines environment variables for downstream scripts."
+        required: true
+        type: string
+      jdk_version:
+        description: "The Java version to use."
+        default: 8
+        type: number
+      branch:
+        description: "The branch the test suite should run on."
+        default: "master"
+        type: string
+    secrets:
+      s3_bucket:
+        required: false
+      s3_access_key:
+        required: false
+      s3_secret_key:
+        required: false
+
+permissions: read-all
+
+# Running logic within a container comes with challenges around file 
permissions (e.g. when trying
+# to generate the hash for a certain set of files; see 
https://github.com/actions/cache/issues/753):
+#
+# The code is cloned into the runner's workspace /home/runner/work/ but 
outside the container.
+# The runner's workspace folder is then mounted to /__w within the container. 
Files that were generated
+# as part of the checkout will have the runner's user as the owner. Any files 
that are generated during
+# the workflow execution will have the container's user as the owner (i.e. 
root). That can cause issues
+# with actions that need to access the files of the checkout.
+#
+# We can work around this issue by copying the source code to a separate 
location (i.e. the container
+# user's home folder). It's important to notice that any file that is subject 
to caching should still
+# live in the mounted folder to ensure accessibility by the cache action.
+env:
+  MOUNTED_WORKING_DIR: /__w/flink/flink
+  CONTAINER_LOCAL_WORKING_DIR: /root/flink
+  # The following two variables are used by the utility scripts for creating
+  # and unpacking the build artifacts.
+  FLINK_ARTIFACT_DIR: /root/artifact-directory
+  FLINK_ARTIFACT_FILENAME: flink_artifacts.tar.gz
+
+  MAVEN_REPO_FOLDER: /root/.m2/repository
+  MAVEN_ARGS: -Dmaven.repo.local=/root/.m2/repository
+  # required by tools/azure-pipelines/cache_docker_images.sh
+  DOCKER_IMAGES_CACHE_FOLDER: /root/.docker-cache
+
+jobs:
+  compile:
+    name: "Compile"
+    runs-on: ubuntu-latest
+    container:
+      image: chesnay/flink-ci:java_8_11_17_21_maven_386
+      options: --init
+    timeout-minutes: 240
+    outputs:
+      stringified-workflow-name: ${{ 
steps.workflow-prep-step.outputs.stringified-workflow-name }}
+    steps:
+      - name: "Flink Checkout"
+        uses: actions/checkout@v3
+        with:
+          ref: ${{ inputs.branch }}
+          persist-credentials: false
+
+      - name: "Stringify workflow name"
+        id: workflow-prep-step
+        run: |
+          stringified_workflow_name=$(echo "${{ github.workflow }}-${{ 
inputs.workflow-caller-id }}" | tr -C '[:alnum:]._' '-' |  tr '[:upper:]' 
'[:lower:]' | sed -e 's/--*/-/g' -e 's/^-*//g' -e 's/-*$//g')
+          echo "stringified-workflow-name=${stringified_workflow_name}" >> 
$GITHUB_OUTPUT
+
+      - name: "Set JDK version to Java ${{ inputs.jdk_version }}"
+        uses: "./.github/actions/set_java_in_container"
+        with:
+          jdk_version: ${{ inputs.jdk_version }}
+
+      - name: "Setup Maven package cache"
+        uses: actions/cache@v3
+        with:
+          path: ${{ env.MAVEN_REPO_FOLDER }}
+          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+          restore-keys: ${{ runner.os }}-maven-
+
+      - name: "Moves relevant checkout content to container-local working 
directory"
+        uses: "./.github/actions/move_checkout"
+        with:
+          source_directory: ${{ env.MOUNTED_WORKING_DIR }}
+          target_directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+
+      - name: "Compile Flink"
+        uses: "./.github/actions/run_mvn"
+        with:
+          working_directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+          maven-parameters: "test-compile -Dflink.markBundledAsOptional=false 
-Dfast"
+          env: "${{ inputs.environment }}"
+
+      - name: "Collect build artifacts"
+        working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+        run: |
+          ./tools/azure-pipelines/create_build_artifact.sh
+
+      - name: "Upload artifacts to make them available in downstream jobs"
+        uses: actions/upload-artifact@v3
+        with:
+          name: build-artifacts-${{ 
steps.workflow-prep-step.outputs.stringified-workflow-name }}-${{ 
github.run_number }}
+          path: ${{ env.FLINK_ARTIFACT_DIR }}/${{ env.FLINK_ARTIFACT_FILENAME 
}}
+          if-no-files-found: error
+          # use minimum here because we only need these artifacts to speed up 
the build
+          retention-days: 1
+
+  packaging:
+    name: "Test packaging/licensing"
+    needs: compile
+    runs-on: ubuntu-latest
+    container:
+      image: chesnay/flink-ci:java_8_11_17_21_maven_386
+      options: --init
+
+    steps:
+      - name: "Flink Checkout"
+        uses: actions/checkout@v3
+        with:
+          ref: ${{ inputs.branch }}
+          persist-credentials: false

Review Comment:
   I was wondering the same. But decided against it because the lines of code 
would not reduce much. Only the `persist-credentials` line would be removed. I 
thought that this wouldn't be worth an extra artifact.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to