[20843] Detect flaky tests Github workflow #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Detect flakiness Ubuntu workflow | |
on: | |
schedule: | |
- cron: '0 1 * * *' | |
pull_request: | |
types: [opened, synchronize] | |
workflow_dispatch: | |
inputs: | |
label: | |
description: 'ID associated to the workflow' | |
required: false | |
type: string | |
colcon-args: | |
description: 'Extra arguments for colcon cli' | |
required: false | |
type: string | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
test-ci: | |
runs-on: 'ubuntu-22.04' | |
strategy: | |
fail-fast: false | |
matrix: | |
fastdds-branch: | |
- 'feature/detect_flaky_tests' | |
cmake-build-type: | |
- 'RelWithDebInfo' | |
steps: | |
- name: Sync eProsima/Fast-DDS repository | |
uses: eProsima/eProsima-CI/external/checkout@v0 | |
with: | |
path: src/fastdds | |
ref: ${{ matrix.fastdds-branch }} | |
- name: Get minimum supported version of CMake | |
uses: eProsima/eProsima-CI/external/get-cmake@v0 | |
with: | |
cmakeVersion: '3.22.6' | |
- name: Install apt dependencies | |
uses: eProsima/eProsima-CI/ubuntu/install_apt_packages@v0 | |
with: | |
packages: libasio-dev libtinyxml2-dev libssl-dev | |
update: false | |
upgrade: false | |
- name: Install colcon | |
uses: eProsima/eProsima-CI/ubuntu/install_colcon@v0 | |
- name: Install Python dependencies | |
run: | | |
pip install pytest pytest-json-report requests vcstool lxml junitparser pandas numpy seaborn | |
- name: Setup CCache | |
uses: eProsima/eProsima-CI/external/setup-ccache-action@v0 | |
- name: Fetch Fast DDS dependencies | |
uses: eProsima/eProsima-CI/multiplatform/vcs_import@v0 | |
with: | |
vcs_repos_file: ${{ github.workspace }}/src/fastdds/fastdds.repos | |
destination_workspace: src | |
skip_existing: 'true' | |
- name: Fetch googletest | |
uses: eProsima/eProsima-CI/multiplatform/vcs_import@v0 | |
with: | |
vcs_repos_file: ${{ github.workspace }}/src/fastdds/.github/workflows/config/ci.repos | |
destination_workspace: src | |
skip_existing: 'true' | |
- name: Colcon build | |
continue-on-error: false | |
uses: eProsima/eProsima-CI/multiplatform/colcon_build@v0 | |
with: | |
colcon_meta_file: ${{ github.workspace }}/src/fastdds/.github/workflows/config/ci.meta | |
colcon_build_args: ${{ inputs.colcon-args }} | |
cmake_args: -DSECURITY=ON | |
cmake_args_default: -DCMAKE_CXX_FLAGS="-Werror -Wall -Wextra -Wpedantic -Wunused-value -Woverloaded-virtual" | |
cmake_build_type: ${{ matrix.cmake-build-type }} | |
workspace: ${{ github.workspace }} | |
- name: Set current date as env variable | |
id: date | |
run: | | |
echo "TODAY=$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_ENV | |
echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV | |
- name: Colcon test | |
run: | | |
cd ${{ github.workspace }} | |
test_results_file="${{ github.workspace }}/test_results-$TODAY.xml" | |
colcon test --packages-select=fastdds --event-handlers=console_direct+ --ctest-args --timeout=300 --label-exclude="xfail" | |
# Translate CTest XML reports to jUnit | |
if [ ! -f ${test_results_file} ] | |
then | |
echo "::group::Translating test report to jUnit specific format" | |
python3 ${{ github.workspace }}/src/fastdds/.github/resources/ctest2junit.py \ | |
--build-dir ${{ github.workspace }}/build/fastdds \ | |
--xslt ${{ github.workspace }}/src/fastdds/.github/resources/ctest-to-junit-reducted.xsl \ | |
--output-junit ${test_results_file} \ | |
--timestamp "$NOW" | |
echo "::endgroup::" | |
fi | |
- name: Download previous test results with plugin | |
if: always() | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: nightly-ubuntu-detect-flaky.yml | |
name: test-results-all | |
workflow_conclusion: completed | |
check_artifacts: true | |
search_artifacts: true | |
- name: Flaky test analysis on [window-size] runs history | |
id: flaky_analysis | |
run: | | |
# CHANGE --window-size TO THE DESIRED NUMBER OF RUNS | |
python ${{ github.workspace }}/src/fastdds/.github/resources/check_flakes.py --junit-files=. --grouping-option=runs --window-size=30 --window-count=1 --output-file=$GITHUB_STEP_SUMMARY | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: test-results-all | |
path: | | |
*.xml |