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


##########
.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
+
+      - 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: "Download build artifacts from compile job"
+        uses: actions/download-artifact@v3
+        with:
+          name: build-artifacts-${{ 
needs.compile.outputs.stringified-workflow-name }}-${{ github.run_number }}
+          path: ${{ env.FLINK_ARTIFACT_DIR }}
+
+      - name: "Unpack build artifact"
+        working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+        run: |
+          ./tools/azure-pipelines/unpack_build_artifact.sh
+
+      - name: "Test"
+        working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+        run: |
+          ${{ inputs.environment }} ./tools/ci/compile_ci.sh || exit $?
+
+  test:
+    name: "Test (module: ${{ matrix.module }})"
+    needs: compile
+    runs-on: ubuntu-latest
+    container:
+      image: chesnay/flink-ci:java_8_11_17_21_maven_386
+      options: --init
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - module: core
+            stringified-module-name: core
+          - module: python
+            stringified-module-name: python
+          - module: table
+            stringified-module-name: table
+          - module: connect
+            stringified-module-name: connect
+          - module: tests
+            stringified-module-name: tests
+          - module: misc
+            stringified-module-name: misc
+
+    steps:
+      - name: "Flink Checkout"
+        uses: actions/checkout@v3
+        with:
+          ref: ${{ inputs.branch }}
+          persist-credentials: false
+
+      - 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: "Set coredump pattern"
+        working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+        run: sudo sysctl -w kernel.core_pattern=core.%p
+
+      - name: "Download build artifacts from compile job"
+        uses: actions/download-artifact@v3
+        with:
+          name: build-artifacts-${{ 
needs.compile.outputs.stringified-workflow-name }}-${{ github.run_number }}
+          path: ${{ env.FLINK_ARTIFACT_DIR }}
+
+      - name: "Unpack build artifact"
+        working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+        run: |
+          ./tools/azure-pipelines/unpack_build_artifact.sh
+
+      - name: "Try loading Docker images from Cache"
+        id: docker-cache
+        uses: actions/cache@v3
+        with:
+          path: ${{ env.DOCKER_IMAGES_CACHE_FOLDER }}
+          key: ${{ matrix.module }}-docker-${{ runner.os }}-${{ 
hashFiles('**/cache_docker_images.sh', 
'**/flink-test-utils-parent/**/DockerImageVersions.java') }}
+          restore-keys: ${{ matrix.module }}-docker-${{ runner.os }}
+
+      - name: "Load Docker images if not present in cache, yet"
+        if: ${{ !cancelled() && !steps.docker-cache.cache.hit }}
+        working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+        run: ./tools/azure-pipelines/cache_docker_images.sh load
+
+      - name: "Test - ${{ matrix.module }}"
+        id: test-run
+        working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+        env:
+          IT_CASE_S3_BUCKET: ${{ secrets.s3_bucket }}
+          IT_CASE_S3_ACCESS_KEY: ${{ secrets.s3_access_key }}
+          IT_CASE_S3_SECRET_KEY: ${{ secrets.s3_secret_key }}
+        timeout-minutes: 240
+        run: |
+          ${{ inputs.environment }} PROFILE="$PROFILE -Pgithub-actions" 
./tools/azure-pipelines/uploading_watchdog.sh \
+              -a ${{ github.job }} \
+              -d ${{ env.FLINK_ARTIFACT_DIR }} \
+              -t 480 \
+              ./tools/ci/test_controller.sh ${{ matrix.module }}
+
+      - name: "Post-process build artifacts"
+        working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+        run: find ${{ steps.test-run.outputs.debug-files-output-dir }} -type f 
-exec rename 's/[:<>|*?]/-/' {} \;
+
+      - name: "Upload build artifacts"
+        uses: actions/upload-artifact@v3
+        if: ${{ failure() && steps.test-run.outputs.debug-files-output-dir }} 
!= ''
+        with:
+          name: logs-test-${{ needs.compile.outputs.stringified-workflow-name 
}}-${{ github.run_number }}-${{ matrix.stringified-module-name }}-${{ 
steps.test-run.outputs.debug-files-name }}
+          path: ${{ steps.test-run.outputs.debug-files-output-dir }}
+
+      - name: "Save Docker images to cache"
+        working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }}
+        if: ${{ !cancelled() && (failure() || !steps.docker-cache.cache.hit) }}
+        run: ./tools/azure-pipelines/cache_docker_images.sh save
+
+  e2e-prereq-check:
+    name: "Check: Code modified"
+    needs: compile
+    runs-on: ubuntu-latest
+    container:
+      image: chesnay/flink-ci:java_8_11_17_21_maven_386
+      options: --init
+    outputs:
+      skip-e2e: ${{ steps.docs-only-pr-check.skip-e2e }}
+    steps:
+      - name: "Flink Checkout"
+        uses: actions/checkout@v3
+        with:
+          ref: ${{ inputs.branch }}
+          persist-credentials: false
+
+      # Skip e2e test execution if this is a documentation only pull request 
(master / release builds will still be checked regularly)
+      - name: "Check if it's a docs-only PR (i.e. e2e tests can be skipped)"
+        id: docs-only-pr-check
+        run: |
+          source ./tools/azure-pipelines/build_properties.sh
+          if is_docs_only_pullrequest; then
+            echo "This is a documentation-only change. Skipping e2e execution."
+            echo "skip-e2e=true" >> $GITHUB_OUTPUT
+          else
+            echo "This is a regular CI build. Continuing ..."
+          fi
+        shell: bash
+
+  e2e:

Review Comment:
   Btw. just because you haven't resolved that item here: I added a comment to 
the configuration stating the reasoning. My understanding was that we don't 
want to/can't use containers for e2e tests because of the Docker-in-Docker 
issue. That's why I kept it like that. :thinking: 



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