2023-02-01 06:31:29 -05:00
|
|
|
# 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
|
|
|
|
|
2023-05-22 02:14:34 -04:00
|
|
|
name: "Unit Tests shared workflow"
|
2023-02-01 06:31:29 -05:00
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
jdk:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
description: 'JDK version used to test Druid'
|
|
|
|
sql_compatibility:
|
|
|
|
required: false
|
|
|
|
type: boolean
|
|
|
|
default: true
|
|
|
|
description: 'For SQL compatibility'
|
|
|
|
module:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
description: 'Name of group of tests that are running'
|
|
|
|
maven_projects:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
description: 'Name of group of tests running (to display)'
|
2023-05-22 02:14:34 -04:00
|
|
|
outputs:
|
|
|
|
coverage_failure:
|
|
|
|
description: 'Indicates if test failed by coverage issues'
|
|
|
|
value: ${{ jobs.unit-tests.outputs.coverage_failure }}
|
2023-02-01 06:31:29 -05:00
|
|
|
|
|
|
|
env:
|
|
|
|
MVN: mvn -B
|
|
|
|
MAVEN_SKIP: -P skip-static-checks -Dweb.console.skip=true -Dmaven.javadoc.skip=true
|
|
|
|
MAVEN_SKIP_TESTS: -P skip-tests
|
2023-02-17 17:27:41 -05:00
|
|
|
MAVEN_OPTS: -Xmx3500m
|
2023-02-01 06:31:29 -05:00
|
|
|
FORCE_COLOR: 2
|
|
|
|
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
unit-tests:
|
|
|
|
name: ${{ inputs.module }} modules test
|
|
|
|
runs-on: ubuntu-latest
|
2023-05-22 02:14:34 -04:00
|
|
|
outputs:
|
|
|
|
coverage_failure: ${{ steps.set_outputs.outputs.coverage_failure }}
|
2023-02-01 06:31:29 -05:00
|
|
|
steps:
|
|
|
|
- name: checkout branch
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2023-10-06 15:45:07 -04:00
|
|
|
# skip the "cache: maven" step from setup-java. We explicitly use a
|
|
|
|
# different cache key since we cannot reuse it across commits.
|
|
|
|
- uses: actions/setup-java@v3
|
|
|
|
with:
|
|
|
|
distribution: 'zulu'
|
|
|
|
java-version: ${{ inputs.jdk }}
|
2023-02-01 06:31:29 -05:00
|
|
|
|
2023-10-06 15:45:07 -04:00
|
|
|
# the build step produces SNAPSHOT artifacts into the local maven repository,
|
|
|
|
# we include github.sha in the cache key to make it specific to that build/jdk
|
2023-02-01 06:31:29 -05:00
|
|
|
- name: Restore Maven repository
|
|
|
|
id: maven-restore
|
|
|
|
uses: actions/cache/restore@v3
|
|
|
|
with:
|
|
|
|
path: ~/.m2/repository
|
2023-02-03 18:49:17 -05:00
|
|
|
key: maven-${{ runner.os }}-${{ inputs.jdk }}-${{ github.sha }}
|
2023-02-01 06:31:29 -05:00
|
|
|
|
|
|
|
- name: setup node
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: 16.17.0
|
|
|
|
|
|
|
|
- name: setup variables
|
|
|
|
run: |
|
|
|
|
export base_ref=${{ github.base_ref }}
|
|
|
|
echo "GITHUB_BASE_REF=${base_ref}" >> $GITHUB_ENV
|
2023-02-15 05:37:49 -05:00
|
|
|
# If sql_compatibilty is true, we want to set default_value_for_null
|
|
|
|
# which enables compatibility mode
|
|
|
|
if (${{ inputs.sql_compatibility }} == true); then
|
|
|
|
echo "DRUID_USE_DEFAULT_VALUE_FOR_NULL=false" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "DRUID_USE_DEFAULT_VALUE_FOR_NULL=true" >> $GITHUB_ENV
|
|
|
|
fi
|
2023-02-01 06:31:29 -05:00
|
|
|
|
2023-07-12 20:50:38 -04:00
|
|
|
- name: test profiling
|
|
|
|
run: |
|
|
|
|
./.github/scripts/setup_test_profiling_env.sh ${{ inputs.jdk }} ${{ github.run_id }} \
|
|
|
|
${{ github.run_number }} ${{ github.run_attempt }} ${{ inputs.module }} >> $GITHUB_ENV
|
|
|
|
|
2023-02-01 06:31:29 -05:00
|
|
|
- name: fetch base branch for test coverage
|
|
|
|
if: ${{ github.base_ref != '' }}
|
|
|
|
run: |
|
|
|
|
# Add merge target branch to determine diff.
|
|
|
|
# This is not needed for build triggered by tags, since there will be no code diff.
|
|
|
|
git remote set-branches --add origin ${GITHUB_BASE_REF} && git fetch
|
|
|
|
|
|
|
|
- name: setup diff-test-coverage
|
|
|
|
run: npm install @connectis/diff-test-coverage@1.5.3
|
|
|
|
|
2023-02-10 11:57:45 -05:00
|
|
|
- name: Maven build
|
|
|
|
if: steps.maven-restore.outputs.cache-hit != 'true'
|
2023-05-22 02:14:34 -04:00
|
|
|
run: ./it.sh ci
|
2023-02-10 11:57:45 -05:00
|
|
|
|
2023-02-01 06:31:29 -05:00
|
|
|
- name: test & coverage
|
2023-05-22 02:14:34 -04:00
|
|
|
id: test_and_coverage
|
2023-02-01 06:31:29 -05:00
|
|
|
env:
|
|
|
|
MAVEN_PROJECTS: ${{ inputs.maven_projects }}
|
2023-05-22 02:14:34 -04:00
|
|
|
run: ./.github/scripts/unit_tests_script.sh
|
|
|
|
|
|
|
|
- name: set outputs on failure
|
|
|
|
id: set_outputs
|
|
|
|
if: ${{ failure() }}
|
|
|
|
run: echo "coverage_failure=${{ env.coverage_failure }}" >> "$GITHUB_OUTPUT"
|