Nightly code check workflow #34
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: Nightly code check workflow | |
on: | |
workflow_dispatch: | |
inputs: | |
send-slack-message: | |
description: 'whether to send a message to #daq-release-notifications on completion' | |
default: 'no' | |
schedule: | |
- cron: "30 10 * * *" | |
jobs: | |
make_nightly_tag: | |
name: create nightly tag | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.create_nightly_tag.outputs.nightly_tag }} | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- id: create_nightly_tag | |
run: | | |
date_tag=$(date +%y%m%d) | |
echo "nightly_tag=NFD_DEV_${date_tag}_A9" >> "$GITHUB_OUTPUT" | |
cat "$GITHUB_OUTPUT" | |
run_unittests: | |
name: Run unit tests | |
runs-on: daq | |
needs: make_nightly_tag | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout daq-release | |
uses: actions/checkout@v4 | |
with: | |
path: daq-release-unittests | |
- name: Create build area | |
run: | | |
source /cvmfs/dunedaq.opensciencegrid.org/setup_dunedaq.sh | |
setup_dbt v8.7.2 | |
dbt-create -n ${{ needs.make_nightly_tag.outputs.tag }} | |
cd ${{ needs.make_nightly_tag.outputs.tag }} | |
source env.sh | |
cd ../daq-release-unittests/scripts | |
./checkout-daq-package.py -i ../configs/coredaq/coredaq-develop/release.yaml -a -o ${DBT_AREA_ROOT}/sourcecode | |
./checkout-daq-package.py -i ../configs/fddaq/fddaq-develop/release.yaml -a -o ${DBT_AREA_ROOT}/sourcecode | |
#./checkout-daq-package.py -p hdf5libs -b develop -i ../configs/coredaq/coredaq-develop/release.yaml -o ${DBT_AREA_ROOT}/sourcecode | |
#./checkout-daq-package.py -p flxlibs -b develop -i ../configs/fddaq/fddaq-develop/release.yaml -o ${DBT_AREA_ROOT}/sourcecode | |
echo "DBT_AREA_ROOT=$DBT_AREA_ROOT" >> "$GITHUB_ENV" | |
- name: Run unit tests | |
run: | | |
cd $DBT_AREA_ROOT/ | |
source env.sh | |
dbt-workarea-env | |
spack load dbe | |
dbt-build --unittest | |
echo "# Unit Test Report" > $GITHUB_STEP_SUMMARY | |
#TODO Make this a script in daq-release | |
log_summary_file=$(ls $DBT_AREA_ROOT/log/unit_tests_*/*_summary.log) | |
table_header_line="| Test | Status| \n| --- | --- |\n" | |
previous_package="" | |
markdown_content="" | |
while IFS= read -r line; do | |
# Strip out bash color formatting | |
cleaned_line=$(echo "$line" | sed -E 's/\x1B\[[0-9;]*[a-zA-Z]//g') | |
# Depending on whether the package has tests or not, the package name will be | |
# in different positions | |
if [[ "$cleaned_line" == *"No unit tests"* ]]; then | |
this_package=$(echo "$cleaned_line" | cut -d ' ' -f 9) | |
else | |
this_package=$(echo "$cleaned_line" | cut -d '/' -f 2) | |
fi | |
test_name=$(echo "$line" | cut -d '/' -f 4 | cut -d '.' -f 1) | |
if [[ "$this_package" != "$previous_package" ]]; then | |
markdown_content+="## $this_package \n" | |
markdown_content+="$table_header_line" | |
previous_package=$this_package | |
fi | |
if [[ "$(echo "$line" | grep -o SUCCESS)" == "SUCCESS" ]]; then | |
markdown_content+="| $test_name | :white_check_mark: Passed |\n" | |
elif [[ "$(echo "$line" | grep -o FAILURE)" == "FAILURE" ]]; then | |
markdown_content+="| $test_name | :x: Failed |\n" | |
else | |
markdown_content+="\n:construction: Unit tests have not been written for $this_package\n" | |
fi | |
done < "$log_summary_file" | |
echo -e "$markdown_content" >> $GITHUB_STEP_SUMMARY | |
- name: Run clang formatting | |
run: | | |
cd $DBT_AREA_ROOT | |
source env.sh | |
cd sourcecode | |
dbt-clang-format.sh . --view-differences-only --markdown-summary | |
cat clang_format_summary_table.md >> $GITHUB_STEP_SUMMARY | |
send_slack_message: | |
if: (github.event_name != 'workflow_dispatch' && failure()) || (github.event_name == 'workflow_dispatch' && github.event.inputs.send-slack-message == 'yes') | |
needs: run_unittests | |
uses: ./.github/workflows/slack-notification.yml | |
with: | |
workflow_success: ${{ needs.run_unittests.result == 'success' }} | |
secrets: | |
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} | |
cleanup_test_area: | |
runs-on: daq | |
if: always() | |
needs: [make_nightly_tag, run_unittests] | |
steps: | |
- name: Remove test directory | |
run: | | |
rm -rf daq-release-unittests | |
rm -rf daq-buildtools-markdown-feature | |
rm -rf ${{ needs.make_nightly_tag.outputs.tag }} |