diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 000000000000..cffeced2e501 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,34 @@ +name: setup +description: "Setup Java" +inputs: + java-version: + description: "Java version to setup" + default: 17 + cache: + description: "Cache Maven repo" + default: true + +runs: + using: composite + steps: + - name: Fetch base ref to find merge-base for GIB + shell: bash + run: .github/bin/git-fetch-base-ref.sh + - uses: actions/setup-java@v3 + if: ${{ inputs.java-version != '' }} + with: + distribution: 'zulu' + java-version: ${{ inputs.java-version }} + - name: Cache local Maven repo + id: cache + if: ${{ inputs.cache }} + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Configure Problem Matchers + if: ${{ inputs.java-version != '' }} + shell: bash + run: echo "::add-matcher::.github/problem-matcher.json" diff --git a/.github/actions/upload/action.yml b/.github/actions/upload/action.yml new file mode 100644 index 000000000000..a99bb90b3363 --- /dev/null +++ b/.github/actions/upload/action.yml @@ -0,0 +1,31 @@ +name: upload +description: "Upload test results" +inputs: + name-suffix: + default: ${{ github.job }} + test-report-retention-days: + default: 5 + +runs: + using: composite + steps: + - name: Upload test results + uses: actions/upload-artifact@v3 + # Upload all test reports only on failure, because the artifacts are large + if: failure() + with: + name: result ${{ inputs.name-suffix }} + path: | + **/target/surefire-reports + **/target/checkstyle-* + - name: Upload test report + uses: actions/upload-artifact@v3 + # Always upload the test report for the annotate.yml workflow, + # but only the single XML file to keep the artifact small + if: always() + with: + # Name prefix is checked in the `Annotate checks` workflow + name: test report ${{ inputs.name-suffix }} + path: | + **/surefire-reports/TEST-*.xml + retention-days: ${{ inputs.test-report-retention-days }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5568c292649e..4de9ec61f3aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,20 +54,9 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # checkout all commits, as the build result depends on `git describe` equivalent - - uses: actions/setup-java@v3 + - uses: ./.github/actions/setup with: - distribution: 'zulu' java-version: ${{ matrix.java-version }} - - name: Cache local Maven repo - id: cache - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Configure Problem Matchers - run: echo "::add-matcher::.github/problem-matcher.json" - name: Download all Trino dependencies to make sure cache is complete run: | $RETRY $MAVEN dependency:go-offline @@ -99,20 +88,7 @@ jobs: with: fetch-depth: 0 # checkout all commits to be able to determine merge base ref: ${{ github.event.pull_request.head.sha }} # checkout PR HEAD commit instead of merge commit - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - - name: Cache local Maven repo - id: cache - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Fetch base ref to find merge-base for GIB - run: .github/bin/git-fetch-base-ref.sh + - uses: ./.github/actions/setup - name: Check Commits uses: trinodb/github-actions/block-commits@c2991972560c5219d9ae5fb68c0c9d687ffcdd10 with: @@ -146,22 +122,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB - - name: Fetch base ref to find merge-base for GIB - run: .github/bin/git-fetch-base-ref.sh - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - - name: Cache local Maven repo - id: cache - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Configure Problem Matchers - run: echo "::add-matcher::.github/problem-matcher.json" + - uses: ./.github/actions/setup - name: Maven Package run: | export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}" @@ -196,22 +157,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # checkout tags so version in Manifest is set properly - - name: Fetch base ref to find merge-base for GIB - run: .github/bin/git-fetch-base-ref.sh - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - - name: Cache local Maven repo - id: cache - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Configure Problem Matchers - run: echo "::add-matcher::.github/problem-matcher.json" + - uses: ./.github/actions/setup - name: Maven Install run: | export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}" @@ -227,26 +173,9 @@ jobs: if [ ! -f gib-impacted.log ] || grep -q testing/trino-test-jdbc-compatibility-old-server gib-impacted.log; then $MAVEN test ${MAVEN_TEST} -pl :trino-test-jdbc-compatibility-old-server fi - - name: Upload test results - uses: actions/upload-artifact@v3 - # Upload all test reports only on failure, because the artifacts are large - if: failure() - with: - name: result ${{ github.job }} - path: | - **/target/surefire-reports - **/target/checkstyle-* - - name: Upload test report - uses: actions/upload-artifact@v3 - # Always upload the test report for the annotate.yml workflow, - # but only the single XML file to keep the artifact small - if: always() + - uses: ./.github/actions/upload with: - # Name prefix is checked in the `Annotate checks` workflow - name: test report ${{ github.job }} - path: | - **/surefire-reports/TEST-*.xml - retention-days: ${{ env.TEST_REPORT_RETENTION_DAYS }} + test-report-retention-days: ${{ env.TEST_REPORT_RETENTION_DAYS }} - name: Clean local Maven repo # Avoid creating a cache entry because this job doesn't download all dependencies if: steps.cache.outputs.cache-hit != 'true' @@ -265,22 +194,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB - - name: Fetch base ref to find merge-base for GIB - run: .github/bin/git-fetch-base-ref.sh - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - - name: Cache local Maven repo - id: cache - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Configure Problem Matchers - run: echo "::add-matcher::.github/problem-matcher.json" + - uses: ./.github/actions/setup - name: Install Hive Module run: | export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}" @@ -364,26 +278,10 @@ jobs: run: | source plugin/trino-hive-hadoop2/conf/hive-tests-${{ matrix.config }}.sh && plugin/trino-hive-hadoop2/bin/run_hive_alluxio_tests.sh - - name: Upload test results - uses: actions/upload-artifact@v3 - # Upload all test reports only on failure, because the artifacts are large - if: failure() + - uses: ./.github/actions/upload with: - name: result ${{ github.job }} - path: | - **/target/surefire-reports - **/target/checkstyle-* - - name: Upload test report - uses: actions/upload-artifact@v3 - # Always upload the test report for the annotate.yml workflow, - # but only the single XML file to keep the artifact small - if: always() - with: - # Name prefix is checked in the `Annotate checks` workflow - name: test report ${{ github.job }} (${{ matrix.config }}) - path: | - **/surefire-reports/TEST-*.xml - retention-days: ${{ env.TEST_REPORT_RETENTION_DAYS }} + name-suffix: ${{ github.job }} (${{ matrix.config }}) + test-report-retention-days: ${{ env.TEST_REPORT_RETENTION_DAYS }} - name: Clean local Maven repo # Avoid creating a cache entry because this job doesn't download all dependencies if: steps.cache.outputs.cache-hit != 'true' @@ -396,22 +294,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB - - name: Fetch base ref to find merge-base for GIB - run: .github/bin/git-fetch-base-ref.sh - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - - name: Cache local Maven repo - id: cache - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Configure Problem Matchers - run: echo "::add-matcher::.github/problem-matcher.json" + - uses: ./.github/actions/setup - name: Maven Install run: | export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}" @@ -448,26 +331,9 @@ jobs: !:trino-sqlserver, !:trino-test-jdbc-compatibility-old-server, !:trino-tests' - - name: Upload test results - uses: actions/upload-artifact@v3 - # Upload all test reports only on failure, because the artifacts are large - if: failure() + - uses: ./.github/actions/upload with: - name: result ${{ github.job }} - path: | - **/target/surefire-reports - **/target/checkstyle-* - - name: Upload test report - uses: actions/upload-artifact@v3 - # Always upload the test report for the annotate.yml workflow, - # but only the single XML file to keep the artifact small - if: always() - with: - # Name prefix is checked in the `Annotate checks` workflow - name: test report ${{ github.job }} - path: | - **/surefire-reports/TEST-*.xml - retention-days: ${{ env.TEST_REPORT_RETENTION_DAYS }} + test-report-retention-days: ${{ env.TEST_REPORT_RETENTION_DAYS }} - name: Clean local Maven repo # Avoid creating a cache entry because this job doesn't download all dependencies if: steps.cache.outputs.cache-hit != 'true' @@ -481,12 +347,9 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB - - name: Fetch base ref to find merge-base for GIB - run: .github/bin/git-fetch-base-ref.sh - - uses: actions/setup-java@v3 + - uses: ./.github/actions/setup with: - distribution: 'zulu' - java-version: 17 + cache: false - name: Maven validate run: | export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}" @@ -553,22 +416,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB - - name: Fetch base ref to find merge-base for GIB - run: .github/bin/git-fetch-base-ref.sh - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - - name: Cache local Maven repo - id: cache - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Configure Problem Matchers - run: echo "::add-matcher::.github/problem-matcher.json" + - uses: ./.github/actions/setup - name: Cleanup node # This is required as a virtual environment update 20210219.1 left too little space for MemSQL to work if: matrix.modules == 'plugin/trino-singlestore' @@ -653,26 +501,10 @@ jobs: # ", :, <, >, |, *, ?, \, / are not allowed in artifact names, replace it with an underscore name=$(echo -n "${{ matrix.modules }}" | sed -e 's/[":<>|\*\?\\\/]/_/g') echo "ARTIFACT_NAME=$name" >> $GITHUB_ENV - - name: Upload test results - uses: actions/upload-artifact@v3 - # Upload all test reports only on failure, because the artifacts are large - if: failure() - with: - name: result ${{ env.ARTIFACT_NAME }} - path: | - **/target/surefire-reports - **/target/checkstyle-* - - name: Upload test report - uses: actions/upload-artifact@v3 - # Always upload the test report for the annotate.yml workflow, - # but only the single XML file to keep the artifact small - if: always() + - uses: ./.github/actions/upload with: - # Name prefix is checked in the `Annotate checks` workflow - name: test report ${{ github.job }} (${{ env.ARTIFACT_NAME }}) - path: | - **/surefire-reports/TEST-*.xml - retention-days: ${{ env.TEST_REPORT_RETENTION_DAYS }} + name-suffix: ${{ env.ARTIFACT_NAME }} + test-report-retention-days: ${{ env.TEST_REPORT_RETENTION_DAYS }} - name: Clean local Maven repo # Avoid creating a cache entry because this job doesn't download all dependencies if: steps.cache.outputs.cache-hit != 'true' @@ -687,8 +519,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB - - name: Fetch base ref to find merge-base for GIB - run: .github/bin/git-fetch-base-ref.sh + - uses: ./.github/actions/setup - uses: dorny/paths-filter@v2 id: filter with: @@ -701,18 +532,6 @@ jobs: # it relies on the Provisio plugin to find the right artifacts - 'core/trino-server/**' - '.github/**' - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - - name: Cache local Maven repo - id: cache - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - name: Maven Install run: | export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}" @@ -927,10 +746,9 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # checkout all commits, as the build result depends on `git describe` equivalent - - uses: actions/setup-java@v3 + - uses: ./.github/actions/setup with: - distribution: 'zulu' - java-version: 17 + cache: false - name: Product tests artifact uses: actions/download-artifact@v3 with: