diff --git a/.github/actions/run_mvn/action.yml b/.github/actions/run_mvn/action.yml new file mode 100644 index 00000000000000..822a159c018ed2 --- /dev/null +++ b/.github/actions/run_mvn/action.yml @@ -0,0 +1,39 @@ +# 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. +# +--- +name: "Runs Maven Command" +description: "Sets the Java version within Flink' CI Docker container" +inputs: + working-directory: + description: "The directory under which the Maven command should be executed." + default: "${{ github.workspace }}" + maven-parameters: + description: "Any parameters of the Maven command." + default: "" + env: + description: "Any environment-specifics that are meant to be available in the context of the call." + default: "" +runs: + using: "composite" + steps: + - name: "Runs Maven Command" + working-directory: "${{ inputs.working-directory }}" + shell: bash + run: | + source "./tools/ci/maven-utils.sh" + ${{ inputs.env }} run_mvn ${{ inputs.maven-parameters }} diff --git a/.github/workflows/template.flink-ci.yml b/.github/workflows/template.flink-ci.yml index 490653d447778c..8f4abb7c690fe1 100644 --- a/.github/workflows/template.flink-ci.yml +++ b/.github/workflows/template.flink-ci.yml @@ -116,9 +116,11 @@ jobs: target-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }} - name: "Compile Flink" - working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }} - run: | - ${{ inputs.environment }} run_mvn test-compile -Dflink.markBundledAsOptional=false -Dfast + uses: "./.github/actions/run_mvn" + with: + working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }} + maven-parameter: "test-compile -Dflink.markBundledAsOptional=false -Dfast" + env: "${{ inputs.environment }}" - name: "Collect build artifacts" working-directory: ${{ env.CONTAINER_LOCAL_WORKING_DIR }} @@ -365,9 +367,6 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-maven- - - name: "Loads Maven environment" - run: source ./tools/ci/maven-utils.sh - - name: "Download build artifacts from compile job" uses: actions/download-artifact@v3 with: @@ -410,7 +409,10 @@ jobs: run: ./tools/azure-pipelines/cache_docker_images.sh load - name: "Build Flink" - run: ${{ inputs.environment }} run_mvn install -DskipTests -Dfast $PROFILE -Pskip-webui-build + uses: "./.github/actions/run_mvn" + with: + maven-parameter: "install -DskipTests -Dfast $PROFILE -Pskip-webui-build" + env: "${{ inputs.environment }}" - name: "Run E2E Tests" id: test-run diff --git a/.github/workflows/template.pre-compile-checks.yml b/.github/workflows/template.pre-compile-checks.yml index f9cecb631bf445..467cb0061b4ca4 100644 --- a/.github/workflows/template.pre-compile-checks.yml +++ b/.github/workflows/template.pre-compile-checks.yml @@ -69,14 +69,22 @@ jobs: - name: "Loads Maven environment" run: source ./tools/ci/maven-utils.sh - - name: "Codestyle" - run: | - run_mvn checkstyle:check spotless:check -T1C + - name: "Checkstyle" + uses: "./.github/actions/run_mvn" + with: + maven-parameter: "checkstyle:check -T1C" + + - name: "Spotless" + if: (success() || failure()) + uses: "./.github/actions/run_mvn" + with: + maven-parameter: "spotless:check -T1C" - name: "License Headers" if: (success() || failure()) - run: | - run_mvn org.apache.rat:apache-rat-plugin:check -N + uses: "./.github/actions/run_mvn" + with: + maven-parameter: "org.apache.rat:apache-rat-plugin:check -N" docs-404-check: name: "Docs 404 Check"