From 3bc0e7856fe56a9240beccf6f1ed735e898583da Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Sat, 23 Nov 2019 17:50:22 -0800 Subject: [PATCH] [ci] Whitelist submodule dev branches to enable running submodule-commit checks on dev This works by checking the $CIRCLE_BRANCH env-var, which is set automatically by CircleCI. Annoyingly, this is set to the name of the source branch for a merge, rather than the target branch. The behavior of this check for each branch type is listed: if CIRCLE_BRANCH == "master": This CI run is the nightly CI run for the master branch. Make sure all submodules of the master branch point to master else if CIRCLE_BRANCH == "dev": This CI run is most likely somebody doing a dev->master merge. Make sure all submodules of the dev branch point to master else: This CI run is likely somebody merging a feature branch into dev. Allow submodule pointers of the dev branch to point to master OR dev --- .circleci/check-commit.sh | 74 ++++++++++++++++++++++++++++++--------- .circleci/config.yml | 2 ++ 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/.circleci/check-commit.sh b/.circleci/check-commit.sh index ad7be1859a..dbf2a718bf 100755 --- a/.circleci/check-commit.sh +++ b/.circleci/check-commit.sh @@ -23,55 +23,94 @@ status=$(git submodule status) all_names=() -search () { - for submodule in "${submodules[@]}" + +search_submodule() { + echo "Running check on submodule $submodule in $dir" + hash=$(echo "$status" | grep "$dir.*$submodule " | awk '{print$1}' | grep -o "[[:alnum:]]*") + for branch in "${branches[@]}" do - echo "Running check on submodule $submodule in $dir" - hash=$(echo "$status" | grep "$dir.*$submodule " | awk '{print$1}' | grep -o "[[:alnum:]]*") echo "Searching for $hash in origin/$branch of $submodule" (git -C $dir/$submodule branch -r --contains "$hash" | grep "origin/$branch") && true # needs init'ed submodules - all_names+=("$dir/$submodule $hash $?") + if [ $? -eq 0 ] + then + all_names+=("$dir/$submodule $hash 0") + return + fi done + all_names+=("$dir/$submodule $hash 1") + return } -submodules=("boom" "hwacha" "icenet" "rocket-chip" "sifive-blocks" "sifive-cache" "testchipip") -dir="generators" -branch="master" +search () { + for submodule in "${submodules[@]}" + do + search_submodule + done +} +submodules=("boom" "hwacha" "icenet" "sha3" "rocket-chip" "sifive-blocks" "sifive-cache" "testchipip") +dir="generators" +if [ "$CIRCLE_BRANCH" == "master" ] || [ "$CIRCLE_BRANCH" == "dev" ] +then + branches=("master") +else + branches=("master" "dev") +fi search submodules=("riscv-gnu-toolchain" "riscv-isa-sim" "riscv-pk" "riscv-tests") dir="toolchains/esp-tools" -branch="master" - +branches=("master") search submodules=("riscv-gnu-toolchain" "riscv-isa-sim" "riscv-pk" "riscv-tests" "riscv-gnu-toolchain-prebuilt") dir="toolchains/riscv-tools" -branch="master" - +branches=("master") search # riscv-openocd doesn't use its master branch submodules=("riscv-openocd") dir="toolchains/riscv-tools" -branch="riscv" +branches=("riscv") +search +submodules=("qemu") +dir="toolchains" +branches=("master") search -submodules=("barstools" "chisel3" "firrtl" "torture") -dir="tools" -branch="master" +submodules=("spec2017" "coremark") +dir="software" +branches=("master") +search +submodules=("axe" "barstools" "chisel3" "firrtl" "torture" "dsptools" "chisel-testers" "treadle" "firrtl-interpreter") +dir="tools" +if [ "$CIRCLE_BRANCH" == "master" ] || [ "$CIRCLE_BRANCH" == "dev" ] +then + branches=("master") +else + branches=("master" "dev") +fi search submodules=("firesim") dir="sims" -branch="master" +if [ "$CIRCLE_BRANCH" == "master" ] || [ "$CIRCLE_BRANCH" == "dev" ] +then + branches=("master") +else + branches=("master" "dev") +fi +search +submodules=("hammer") +dir="vlsi" +branches=("master") search + # turn off verbose printing to make this easier to read set +x @@ -90,3 +129,4 @@ do done echo "Done checking all submodules" + diff --git a/.circleci/config.yml b/.circleci/config.yml index d6d8097bef..95de63a4de 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -622,6 +622,8 @@ workflows: # Build verilator - install-verilator + - commit-on-master-check + # Build extra tests - build-extra-tests: requires: