diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index 31d5ad682e2..e8e829ed6cb 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -121,3 +121,17 @@ jobs: chmod u=rw,og=rw $ff done done + + test-checksum: + # Skip if the commit message contains "ci skip" + if: "!contains(github.event.head_commit.message, 'ci skip')" + + runs-on: ubuntu-22.04 + + steps: + # Checks-out repository under $GITHUB_WORKSPACE, so job can access it + - name: Checkout code + uses: actions/checkout@v3 + + - name: Compute the checksum and check that it matches the value from the last commit + run: ./Resources/Scripts/travis/templates/checkandrun.sh --checksum --skip --diffhead diff --git a/Buildings/Resources/Scripts/travis/templates/checkandrun.sh b/Buildings/Resources/Scripts/travis/templates/checkandrun.sh index fbe1e256e20..132cc1f9f66 100755 --- a/Buildings/Resources/Scripts/travis/templates/checkandrun.sh +++ b/Buildings/Resources/Scripts/travis/templates/checkandrun.sh @@ -15,13 +15,17 @@ # - If all simulations succeed: overwrite stored checksum with new value, # otherwise do nothing. # -# To update the checksums and run simulations locally, execute: -# ./Resources/Scripts/travis/templates/checkandrun.sh --checksum --local [--tool SIMULATOR] +# To update the checksum and skip all simulations, execute: +# ./Resources/Scripts/travis/templates/checkandrun.sh --checksum --skip +# +# To update the checksum and check that it matches the value from the last commit, execute: +# ./Resources/Scripts/travis/templates/checkandrun.sh --checksum --skip --diffhead +# +# To update the checksums and run simulations, execute: +# ./Resources/Scripts/travis/templates/checkandrun.sh --checksum [--tool SIMULATOR] # -# To simply update the checksums locally and skip all simulations, execute: -# ./Resources/Scripts/travis/templates/checkandrun.sh --checksum --local --skip -LOCALRUN=false +DIFFHEAD=false SKIP=false USE_CHECKSUM=false SIMULATOR=Dymola @@ -33,8 +37,8 @@ CEND='\033[0m' while [[ "$1" != "" ]]; do case $1 in - --local ) - LOCALRUN=true + --diffhead ) + DIFFHEAD=true ;; --skip ) SKIP=true @@ -64,7 +68,7 @@ while [[ "$1" != "" ]]; do echo "Invalid option: $1" echo "Usage: checkandrun.sh --checksum [--local] [--skip] [--tool SIMULATOR] [--cover FRACTION_TEST_COVERAGE]" echo " --checksum triggers testing based on checksum verification (only method currently available, mandatory option)." - echo " --local is for local execution (use this option to update the checksums and run simulations)." + echo " --diffhead is to check that the current checksum matches the value from the last commit." echo " --skip disables all simulations (use this option to simply update the checksums locally)." echo " --tool allows specifying the Modelica tool to be used, defaulting to Dymola." echo " --cover allows specifying the fraction of test coverage, defaulting to 1." @@ -111,9 +115,8 @@ for type in "${!test_script[@]}"; do # Add checksum file to the index so that differences show up in git diff even if file was never added before. git add --intent-to-add "./Resources/Scripts/travis/templates/$type.checksum" - # Diff/HEAD: only for remote testing. - # (Locally, it is expected that there is some diff/HEAD, and we proceed directly to the next step: diff/master.) - if [ "$LOCALRUN" = false ]; then + # Diff/HEAD + if [ "$DIFFHEAD" = true ]; then diff_checksum="$(git diff --name-only HEAD | grep Resources/Scripts/travis/templates/$type.checksum)" if (( $? == 0 )); then printf "${CRED}Computed checksum does not match checksum on HEAD${CEND}: please commit updated checksum for Templates.%s.\n" $type