diff --git a/.github/workflows/test_daq_buildtools.yml b/.github/workflows/test_daq_buildtools.yml index 19cee00..8e977f8 100644 --- a/.github/workflows/test_daq_buildtools.yml +++ b/.github/workflows/test_daq_buildtools.yml @@ -1,26 +1,31 @@ name: Test daq-buildtools +permissions: + contents: read + on: pull_request: - branches: develop + branches: + - develop + - johnfreeman/test_daq_buildtools_workflow types: [opened, reopened, synchronize] jobs: test_daq_buildtools: name: Test daq-buildtools runs-on: ubuntu-latest + container: + image: ghcr.io/dune-daq/nightly-release-alma9:development_v5 defaults: run: shell: bash + steps: - id: checkout_daq_buildtools uses: actions/checkout@v6 with: path: daq-buildtools-test - - - uses: cvmfs-contrib/github-action-cvmfs@v5 - with: - cvmfs_repositories: 'dunedaq.opensciencegrid.org' + persist-credentials: false - name: Run test_daq-buildtools script run: | @@ -28,4 +33,5 @@ jobs: source env.sh cd scripts ./test_daq-buildtools.sh --dbt-branch ${{ github.head_ref }} - \ No newline at end of file + + diff --git a/bin/dbt-build b/bin/dbt-build index e0c561e..9f11f9f 100755 --- a/bin/dbt-build +++ b/bin/dbt-build @@ -1,8 +1,12 @@ #!/usr/bin/env python3 + import os import sys +print("Intentionally crashing dbt-build out") +sys.exit(1) + if "DBT_ROOT" in os.environ: DBT_ROOT=os.environ["DBT_ROOT"] else: diff --git a/docs/README.md b/docs/README.md index 36af55e..c068afc 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,5 @@ +_JCF, Feb-25-2026: if you can read this line, please contact me_ + # DUNE DAQ Buildtools _This document was last edited May-28-2025_ diff --git a/scripts/test_daq-buildtools.sh b/scripts/test_daq-buildtools.sh new file mode 100755 index 0000000..4a982d9 --- /dev/null +++ b/scripts/test_daq-buildtools.sh @@ -0,0 +1,141 @@ +#!/bin/bash + +usage() { + local prog=$(basename "$0") + cat << EOF +Usage: $prog [OPTIONS] + +Test functionality of daq-buildtools commands. + +Optional arguments: + --release Release in which to test daq-buildtools commands. [default: last_fddaq] + --dbt-branch Branch of daq-buildtools to run tests from. [default: develop] + --repo Name of a single repo to checkout for tests. [default: ipm] + +Example: + ./${prog} --release fddaq-v5.5.0-a9 --dbt-branch user/new_feature --repo hdf5libs +EOF +} + +start_dir="$PWD" + +cleanup() { + echo "Triggering cleanup" + cd "$start_dir" + rm -rf "$dbt_tmpdir" + rm -rf "$release_tmpdir" + echo "Done" +} +trap cleanup EXIT SIGINT SIGTERM + +release="last_fddaq" +repo="ipm" +dbt_branch="develop" + +while [[ $# -gt 0 ]]; do + case "$1" in + -h|--help|-?) + usage + exit 1 + ;; + --release) + release="$2" + shift 2 + ;; + --repo) + repo="$2" + shift 2 + ;; + --dbt-branch) + dbt_branch="$2" + shift 2 + ;; + *) + echo "ERROR: Unknown argument: $1" + exit 1 + ;; + esac +done + +extra_args=() +if [[ "$release" == *"FD_"* || "$release" == "last_fddaq" ]]; then + extra_args=(-n) +elif [[ "$release" == *"rc"* ]]; then + extra_args=(-b candidate) +fi + +echo -e "Running daq-buildtools commands using:\n" +echo -e "\tRelease name: $release" +echo -e "\tdbt branch: $dbt_branch" +echo -e "\trepo: $repo\n" + +. /cvmfs/dunedaq.opensciencegrid.org/setup_dunedaq.sh || exit 1 +setup_dbt latest_v5 || exit 2 + +if [[ -n "dbt_branch" ]]; then + dbt_tmpdir=$(mktemp -d) + mkdir -p "$dbt_tmpdir" && cd "$dbt_tmpdir" + git clone https://github.com/DUNE-DAQ/daq-buildtools.git -b "$dbt_branch" + source daq-buildtools/env.sh +fi + +release_tmpdir=$(mktemp -d) +mkdir -p "$release_tmpdir" && cd "$release_tmpdir" + +echo "*********************************TEST dbt-setup-release *******************************" +# Check that dbt-setup-release works without altering the environment, thus the (...) +(dbt-setup-release "${extra_args[@]}" "$release"; echo $? > $release_tmpdir/dbt-setup-release_result.txt) + +test -e $release_tmpdir/dbt-setup-release_result.txt || exit 3 +test $( cat $release_tmpdir/dbt-setup-release_result.txt ) == 0 || exit 4 +rm -f dbt-setup-release_result.txt + +echo "*********************************TEST dbt-create ***************************************" +dbt-create -s ${extra_args[@]} $release || exit 5 +cd $(ls) # Only thing in the directory will be the work area +cd sourcecode +git clone https://github.com/DUNE-DAQ/$repo || exit 6 +cd .. +. env.sh || exit 7 + +echo "**********************************TEST dbt-build ****************************************" +dbt-build || exit 8 + +echo "******************************TEST dbt-build --unittest *********************************" +dbt-build --unittest || exit 9 + +if spack find --loaded llvm >/dev/null 2>&1; then + echo "******************************TEST dbt-build --lint *************************************" + dbt-build --lint || exit 10 + + echo "******************************TEST dbt-clang-format.sh *************************************" + cd $DBT_AREA_ROOT/sourcecode + dbt-clang-format.sh $repo --view-differences-only || exit 11 + cd .. +else + echo "WARNING: Skipping dbt-build --lint and dbt-clang-format.sh since llvm is not loaded" +fi + +if spack find --loaded lcov >/dev/null 2>&1; then + echo "*********************************TEST dbt-lcov.sh****************************************" + dbt-lcov.sh || exit 12 +else + echo "WARNING: Skipping dbt-lcov.sh since lcov is not loaded" +fi + +# Test building against a sourcecode directory outside of the work area +echo "***********************TEST dbt-build with external sourcecode **************************" +mv sourcecode $release_tmpdir +ln -s $release_tmpdir/sourcecode +dbt-build --clean || exit 13 + +echo "*****************************TEST dbt-build --codegen **********************************" +dbt-build --codegen || exit 14 + + +echo "********************TEST local workarea Spack package installation **********************" +spack install py-wesanderson || exit 15 + +echo "Testing completed successfully." + +exit 0