diff --git a/.github/actions/cmake-config/action.yml b/.github/actions/cmake-config/action.yml new file mode 100644 index 0000000000..2ddb93a653 --- /dev/null +++ b/.github/actions/cmake-config/action.yml @@ -0,0 +1,18 @@ +name: 'Configure CMake' +description: 'Configure the CMake project' +author: 'Rafael Mudafort https://github.com/rafmudaf' + +inputs: + build-type: + description: 'Set the CMake build type: Release (-O3); RelWithDebInfo (-O2 -g); Debug (-g)' + default: 'Release' + additional-flags: + description: 'Additional flags to pass directly to the CMake command' + default: '' + +runs: + using: 'composite' + steps: + - run: cmake .. -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} ${{ inputs.additional-flags }} + working-directory: "/openfast/build" + shell: bash diff --git a/.github/actions/compile-and-test/Dockerfile b/.github/actions/compile-and-test/Dockerfile deleted file mode 100644 index 8a6084bb6c..0000000000 --- a/.github/actions/compile-and-test/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright 2016 National Renewable Energy Laboratory -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -FROM rafmudaf/openfast-ubuntu:dev - -# Move into the openfast directory -WORKDIR /openfast - -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/compile-and-test/action.yml b/.github/actions/compile-and-test/action.yml deleted file mode 100644 index 572382f438..0000000000 --- a/.github/actions/compile-and-test/action.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: 'Compile and test' -description: 'Compile OpenFAST and run the tests' -author: 'NREL' -# inputs: -# build-type: -# description: 'Set the CMake build type: Release (-O3); RelWithDebInfo (-O2 -g); Debug (-g)' -# default: 'Release' -runs: - using: 'docker' - image: 'Dockerfile' diff --git a/.github/actions/compile-and-test/entrypoint.sh b/.github/actions/compile-and-test/entrypoint.sh deleted file mode 100755 index 21be246f9b..0000000000 --- a/.github/actions/compile-and-test/entrypoint.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -verbosecommand() { echo ">>> $1" && eval $1 && echo "<<<"; } - -# Configure Bash to exit if any command returns an error -set -e - -verbosecommand "cd /openfast" - -repo="OpenFAST" -echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}" -if [[ "${GITHUB_EVENT_NAME}" != "pull_request" ]]; then - repo=${GITHUB_ACTOR} -fi -# Create a branch "CI" at the current commit from the GH Actor's fork. -verbosecommand "git fetch https://github.com/${repo}/openfast ${GITHUB_REF}:CI" -verbosecommand "git checkout CI" -verbosecommand "git submodule update" - -# Display the current git info -echo "*** git-status from openfast:" -verbosecommand "git status" - -echo "*** git-log from openfast:" -verbosecommand "git log -1" - -verbosecommand "cd /openfast/reg_tests/r-test" -echo "*** git-status from r-test:" -verbosecommand "git status" - -echo "*** git-log from r-test:" -verbosecommand "git log -1" - -verbosecommand "cd /openfast" - -# Display the differences between this commit and `dev` -echo "*** git-diff from ${GITHUB_REF} to dev:" -verbosecommand "git diff dev --numstat" - -# Move into the "build" directory, remove the old reg tests, and compile -verbosecommand "cd /openfast/build" -verbosecommand "rm -rf reg_tests" -verbosecommand "cmake .." -verbosecommand "make -j4 install" - -# Run the tests - -# NWTC Library tests -verbosecommand "ctest -VV -R nwtc_library_utest" - -# BeamDyn-specific tests -verbosecommand "ctest -VV -j7 -R bd_" -verbosecommand "ctest -VV -R beamdyn_utest" - -# OLAF free vortex wake tests -ctest -VV -R fvw_utest - -# OpenFAST linearization tests -# Dont run these in parallel, copying the case files can fail in a race condition -# Exclude the Ideal_Beam test cases -# - They fail consistently in the Docker container when run on GitHub, -# but pass everywhere else including running the same Docker image locally -verbosecommand "ctest -VV -L linear -E Ideal" - -# Subset of OpenFAST regression tests; do not run -## - 9, 16 because they're very sensitive -## - 19, 20 because theyre too long -## - 17, 22, 23 because we dont know why they fail :( -verbosecommand "ctest -VV -j8 -I 1,1,1,2,3,4,5,6,7,8,10,11,12,13,14,15,18,21,24,25,26,27,28,29" diff --git a/.github/actions/compile/action.yml b/.github/actions/compile/action.yml new file mode 100644 index 0000000000..243026586c --- /dev/null +++ b/.github/actions/compile/action.yml @@ -0,0 +1,15 @@ +name: 'Compile OpenFAST' +description: 'Compile part or all of OpenFAST' +author: 'Rafael Mudafort https://github.com/rafmudaf' + +inputs: + build-target: + description: 'Which targets to compile' + default: 'install' + +runs: + using: 'composite' + steps: + - run: make -j4 ${{ inputs.build-target }} + working-directory: "/openfast/build" + shell: bash diff --git a/.github/actions/git-update/action.yml b/.github/actions/git-update/action.yml new file mode 100644 index 0000000000..c2f1484a62 --- /dev/null +++ b/.github/actions/git-update/action.yml @@ -0,0 +1,22 @@ +name: 'Update the existin OpenFAST project in the Docker image' +description: 'Workaround to avoid recompiling every component since the Docker image has the latest "dev" branch precompiled.' +author: 'Rafael Mudafort https://github.com/rafmudaf' + +inputs: + repository: + description: 'The GitHub repository that is taking action.' + required: true + ref: + description: 'The branch or tag ref that triggered the action.' + required: true + +runs: + using: 'composite' + steps: + - run: | + git config --global user.email "openfast@github_actions.ci" + git config --global user.name "OpenFAST Continuous Integration" + git pull --no-verify https://github.com/${{ inputs.repository }} ${{ inputs.ref }} + git submodule update + working-directory: "/openfast/" + shell: bash diff --git a/.github/actions/tests-gluecode-openfast/action.yml b/.github/actions/tests-gluecode-openfast/action.yml new file mode 100644 index 0000000000..5b83dc96c4 --- /dev/null +++ b/.github/actions/tests-gluecode-openfast/action.yml @@ -0,0 +1,21 @@ +name: 'OpenFAST glue code tests' +description: 'Run tests focused on the OpenFAST glue code' +author: 'Rafael Mudafort https://github.com/rafmudaf' +runs: + using: 'composite' + steps: + - run: | + ctest -VV -L linear -E Ideal + ctest -VV -j8 -I 1,1,1,2,3,4,5,6,7,8,10,11,12,13,14,15,17,18,21,22,23,24,25,26,27,28,29 + working-directory: "/openfast/build" + shell: bash + +# OpenFAST linearization tests +# Dont run these in parallel, copying the case files can fail in a race condition +# Exclude the Ideal_Beam test cases +# - They fail consistently in the Docker container when run on GitHub, +# but pass everywhere else including running the same Docker image locally + +# Subset of OpenFAST regression tests; do not run +# - 9, 16 because they're very sensitive +# - 19, 20 because they're too long diff --git a/.github/actions/tests-module-aerodyn/action.yml b/.github/actions/tests-module-aerodyn/action.yml new file mode 100644 index 0000000000..7b2e332f56 --- /dev/null +++ b/.github/actions/tests-module-aerodyn/action.yml @@ -0,0 +1,9 @@ +name: 'AeroDyn module tests' +description: 'Run tests specific to the AeroDyn module' +author: 'Rafael Mudafort https://github.com/rafmudaf' +runs: + using: "composite" + steps: + - run: ctest -VV -R fvw_utest + working-directory: "/openfast/build" + shell: bash diff --git a/.github/actions/tests-module-beamdyn/action.yml b/.github/actions/tests-module-beamdyn/action.yml new file mode 100644 index 0000000000..bc5d6165fa --- /dev/null +++ b/.github/actions/tests-module-beamdyn/action.yml @@ -0,0 +1,11 @@ +name: 'BeamDyn module tests' +description: 'Run tests specific to the BeamDyn module' +author: 'Rafael Mudafort https://github.com/rafmudaf' +runs: + using: "composite" + steps: + - run: | + ctest -VV -j7 -R bd_ + ctest -VV -R beamdyn_utest + working-directory: "/openfast/build" + shell: bash diff --git a/.github/actions/tests-module-hydrodyn/action.yml b/.github/actions/tests-module-hydrodyn/action.yml new file mode 100644 index 0000000000..5675671746 --- /dev/null +++ b/.github/actions/tests-module-hydrodyn/action.yml @@ -0,0 +1,9 @@ +name: 'HydroDyn module tests' +description: 'Run tests specific to the HydroDyn module' +author: 'Rafael Mudafort https://github.com/rafmudaf' +runs: + using: "composite" + steps: + - run: ctest -VV -j7 -hd_ + working-directory: "/openfast/build" + shell: bash diff --git a/.github/actions/tests-module-nwtclibrary/action.yml b/.github/actions/tests-module-nwtclibrary/action.yml new file mode 100644 index 0000000000..e26b0d99dc --- /dev/null +++ b/.github/actions/tests-module-nwtclibrary/action.yml @@ -0,0 +1,9 @@ +name: 'NWTC Library module tests' +description: 'Run tests specific to the NWTC Library module' +author: 'Rafael Mudafort https://github.com/rafmudaf' +runs: + using: "composite" + steps: + - run: ctest -VV -R nwtc_library_utest + working-directory: "/openfast/build" + shell: bash diff --git a/.github/workflows/automated-dev-tests.yml b/.github/workflows/automated-dev-tests.yml new file mode 100644 index 0000000000..0faf3c0e10 --- /dev/null +++ b/.github/workflows/automated-dev-tests.yml @@ -0,0 +1,79 @@ + +name: 'Development Pipeline' + +on: + push: + + pull_request: + types: [opened, labeled] #, assigned] + +# runs-on: ${{ matrix.os }} +# strategy: +# matrix: +# os: [macOS-10.14, ubuntu-18.04] + +jobs: + build-and-test: + + # Do not run if: + # - Branch name contains "docs/" + if: "!contains(github.ref, 'docs/')" + + runs-on: ubuntu-latest + container: + image: rafmudaf/openfast-ubuntu:dev + steps: + - name: Checkout + uses: actions/checkout@main + with: + submodules: recursive + - name: Git Update + uses: ./.github/actions/git-update + with: + repository: $GITHUB_REPOSITORY + ref: $GITHUB_REF + + - name: Configure CMake + uses: ./.github/actions/cmake-config + with: + build-type: RelWithDebInfo + additional-flags: -DBUILD_TESTING=ON -DCTEST_PLOT_ERRORS=ON + + - name: Compile Unit Tests + uses: ./.github/actions/compile + with: + build-target: 'unit_tests' + - name: Compile Drivers + uses: ./.github/actions/compile + with: + build-target: 'beamdyn_driver hydrodyn_driver' + - name: Compile OpenFAST + # if: contains(github.event.head_commit.message, 'Action - Test All') || contains(github.event.pull_request.labels.*.name, 'Action - Test All') + uses: ./.github/actions/compile + with: + build-target: 'install' + + - name: 'Run NWTC Library tests' + uses: ./.github/actions/tests-module-nwtclibrary + - name: 'Run AeroDyn tests' + uses: ./.github/actions/tests-module-aerodyn + - name: 'Run BeamDyn tests' + uses: ./.github/actions/tests-module-beamdyn + - name: 'Run OpenFAST tests' + # if: contains(github.event.head_commit.message, 'Action - Test All') || contains(github.event.pull_request.labels.*.name, 'Action - Test All') + uses: ./.github/actions/tests-gluecode-openfast + + - name: 'If failure, post test files' + uses: actions/upload-artifact@v2 + if: failure() + with: + name: test-results + path: | + build/reg_tests/modules + build/reg_tests/glue-codes/openfast + !build/reg_tests/glue-codes/openfast/5MW_Baseline + !build/reg_tests/glue-codes/openfast/AOC + !build/reg_tests/glue-codes/openfast/AWT27 + !build/reg_tests/glue-codes/openfast/SWRT + !build/reg_tests/glue-codes/openfast/UAE_VI + !build/reg_tests/glue-codes/openfast/WP_Baseline diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml deleted file mode 100644 index edd35ff242..0000000000 --- a/.github/workflows/continuous-integration-workflow.yml +++ /dev/null @@ -1,22 +0,0 @@ - -name: OpenFAST Build and Test - -on: [push, pull_request] - -# runs-on: ${{ matrix.os }} -# strategy: -# matrix: -# os: [macOS-10.14, ubuntu-18.04] -# runs-on: docker://rafmudaf/openfast-ubuntu:alpha - -jobs: - build-and-test: - runs-on: ubuntu-latest - name: OpenFAST tests on Ubuntu - steps: - - name: Checkout - uses: actions/checkout@main - with: - submodules: recursive - - name: Build and test step - uses: ./.github/actions/compile-and-test diff --git a/reg_tests/CMakeLists.txt b/reg_tests/CMakeLists.txt index 6272de3e4c..c8250272c8 100644 --- a/reg_tests/CMakeLists.txt +++ b/reg_tests/CMakeLists.txt @@ -76,3 +76,26 @@ endforeach() # add the tests include(${CMAKE_CURRENT_LIST_DIR}/CTestList.cmake) + +set(src "${CMAKE_CURRENT_LIST_DIR}/r-test/glue-codes/openfast/5MW_Baseline/ServoData") +set(dest "${CTEST_BINARY_DIR}/glue-codes/openfast/5MW_Baseline/ServoData/") +add_custom_command( + OUTPUT "${dest}/DISCON.dll" + DEPENDS DISCON + COMMAND "${CMAKE_COMMAND}" -E copy "${src}/DISCON/build/DISCON.dll" "${dest}" +) +add_custom_command( + OUTPUT "${dest}/DISCON_ITIBarge.dll" + DEPENDS DISCON_ITIBarge + COMMAND "${CMAKE_COMMAND}" -E copy "${src}/DISCON_ITI/build/DISCON_ITIBarge.dll" "${dest}" + ) +add_custom_command( + OUTPUT "${dest}/DISCON_OC3Hywind.dll" + DEPENDS DISCON_OC3Hywind + COMMAND "${CMAKE_COMMAND}" -E copy "${src}/DISCON_OC3/build/DISCON_OC3Hywind.dll" "${dest}" +) + +add_custom_target( + regression_tests + DEPENDS openfast "${dest}/DISCON.dll" "${dest}/DISCON_ITIBarge.dll" "${dest}/DISCON_OC3Hywind.dll" +) diff --git a/share/docker/openfast_dev/Dockerfile b/share/docker/openfast_dev/Dockerfile index eea9ec75da..5042c7bbbd 100644 --- a/share/docker/openfast_dev/Dockerfile +++ b/share/docker/openfast_dev/Dockerfile @@ -14,32 +14,16 @@ # limitations under the License. # -FROM rafmudaf/openfast-ubuntu:dev +FROM rafmudaf/openfast-ubuntu:v2.3.0 # Move into the openfast directory and update WORKDIR /openfast -RUN git fetch -RUN git pull -RUN git submodule update +RUN git fetch && \ + git checkout -b dev origin/dev && \ + git submodule update # Move into the "build" directory, remove the old reg tests, and compile WORKDIR /openfast/build -RUN rm -rf reg_tests -RUN cmake .. -RUN make -j4 install - -# Run the tests - -# BeamDyn-specific tests -RUN ctest -VV -j7 -R bd_ -RUN ctest -VV -R beamdyn_utest - -# OpenFAST linearization tests -# Dont run these in parallel, copying the case files can fail in a race condition -RUN ctest -VV -L linear - -# Subset of OpenFAST regression tests; do not run -## - 9, 16 because they're very sensitive -## - 19, 20 because theyre too long -## - 17, 22, 23 becuase we dont know why they fail :( -RUN ctest -VV -j8 -I 1,1,1,2,3,4,5,6,7,8,10,11,12,13,14,15,18,21,24,25,27,28,29 +RUN rm -rf reg_tests && \ + cmake .. && \ + make -j4 install diff --git a/share/docker/openfast_ubuntu/Dockerfile b/share/docker/openfast_ubuntu/Dockerfile index 447b38bbfe..8470e56230 100644 --- a/share/docker/openfast_ubuntu/Dockerfile +++ b/share/docker/openfast_ubuntu/Dockerfile @@ -22,14 +22,18 @@ FROM ubuntu:bionic # RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y # apt-get install gfortran-8 -RUN apt update -qq -RUN apt install -y software-properties-common build-essential -RUN apt install -y python3-pip -RUN apt install -y cmake cmake-curses-gui -RUN apt install -y gcc gfortran make -RUN apt install -y libblas-dev liblapack-dev -RUN apt install -y git -RUN apt install -y nano +ENV DEBIAN_FRONTEND=noninteractive TZ=America/Denver + +RUN apt update -qq && \ + apt install -y software-properties-common build-essential && \ + add-apt-repository ppa:git-core/ppa -y && \ + apt install -y python3-pip && \ + apt install -y cmake cmake-curses-gui && \ + apt install -y gcc gfortran make && \ + apt install -y libblas-dev liblapack-dev && \ + apt install -y git && \ + apt install -y nano + RUN pip3 install numpy # Configure the environment @@ -38,7 +42,6 @@ ENV FC=/usr/bin/gfortran # Clone the project RUN git clone --recursive https://github.com/openfast/openfast.git openfast WORKDIR /openfast -RUN git checkout -b dev origin/dev # Build the project RUN mkdir build @@ -47,5 +50,5 @@ WORKDIR /openfast/build # NOTE: building with optimizations on (RELEASE or RELWITHDEBINFO), the virtual machine # will require about 6GB of memoery. Otherwise, the gfortran compiler will exit with an # "internal error" -RUN cmake .. -DBUILD_TESTING=ON -DDOUBLE_PRECISION=ON -DCMAKE_BUILD_TYPE=DEBUG +RUN cmake .. -DBUILD_TESTING=ON -DDOUBLE_PRECISION=ON -DCMAKE_BUILD_TYPE=RELWITHDEBINFO RUN make -j4 install diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 4caee9fa32..6303fc19c4 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -72,3 +72,8 @@ endif() add_subdirectory("beamdyn") add_subdirectory("nwtc-library") add_subdirectory("aerodyn") + +add_custom_target( + unit_tests + DEPENDS beamdyn_utest nwtc_library_utest fvw_utest +) \ No newline at end of file