diff --git a/.github/workflows/build-and-test-macos.yml b/.github/workflows/build-and-test-macos.yml deleted file mode 100644 index 1d9cf0366..000000000 --- a/.github/workflows/build-and-test-macos.yml +++ /dev/null @@ -1,184 +0,0 @@ -name: Build and Test (macos) - -# Trigger the workflow on push or pull request -on: - push: - branches: - - master - pull_request: - types: [opened, reopened, synchronize, converted_to_draft, ready_for_review] - -jobs: - build: - strategy: - fail-fast: false - matrix: - host: [ - { - base: macos-12, - compiler: { cc: clang, cxx: clang++ }, - gcov: llvm-gcov, - python: ['3.8', '3.9', '3.10', '3.11', '3.12'], - vtk: '9.3.1' - }, - { - base: macos-13, - compiler: { cc: clang, cxx: clang++ }, - gcov: llvm-gcov, - python: ['3.8', '3.9', '3.10', '3.11', '3.12'], - vtk: '9.3.1' - }, - { - base: macos-14, - compiler: { cc: clang, cxx: clang++ }, - gcov: llvm-gcov, - python: ['3.8', '3.9', '3.10', '3.11', '3.12'], - vtk: '9.3.1' - } - ] - runs-on: ${{ matrix.host.base }} - name: vt-tv build and test (${{ matrix.host.base }}, ${{ matrix.host.compiler.cc }}, vtk-${{ matrix.host.vtk }}, py[${{ join(matrix.host.python, ', ') }}]) - env: - VTK_SRC_DIR: /opt/src/vtk - VTK_BUILD_DIR: /opt/build/vtk - CACHE_KEY: ${{ matrix.host.base }}-${{ matrix.host.compiler.cc }}-vtk-${{ matrix.host.vtk }} - VT_TV_BUILD_DIR: /opt/build/vt-tv - VT_TV_TESTS_ENABLED: "ON" - VT_TV_COVERAGE_ENABLED: ${{ matrix.host.compiler.gcov == '' && 'OFF' || 'ON' }} - VT_TV_OUTPUT_DIR: ${{ github.workspace }}/output - VT_TV_TESTS_OUTPUT_DIR: ${{ github.workspace }}/output/tests - VT_TV_ARTIFACTS_DIR: /tmp/artifacts - CONDA_PATH: /opt/conda - CC: ~ - CXX: ~ - GCOV: ~ - steps: - - uses: actions/checkout@v4 - - - name: Set folder permissions - run: | - sudo chown -R $(whoami) /opt - mkdir -p ${{ env.VTK_SRC_DIR }} ${{ env.VT_TV_BUILD_DIR }} - - - name: Set environment variables - run: | - echo "CC=$(which ${{ matrix.host.compiler.cc }})" >> $GITHUB_ENV - echo "CXX=$(which ${{ matrix.host.compiler.cxx }})" >> $GITHUB_ENV - echo "GCOV=$(which ${{ matrix.host.gcov }})" >> $GITHUB_ENV - - - name: Install dependencies - run: | - brew update && brew install coreutils lcov xquartz - - - name: Load cache (VTK, Miniconda3) - id: base-cache - uses: actions/cache@v4 - with: - path: | - ${{ env.VTK_SRC_DIR }} - ${{ env.VTK_BUILD_DIR }} - ${{ env.CONDA_PATH }} - ~/.zshrc - ~/.bash_profile - key: ${{ env.CACHE_KEY }} - save-always: true - - - name: Setup Conda - if: ${{steps.base-cache.outputs.cache-hit != 'true'}} - run: | - sudo CONDA_PATH=${{ env.CONDA_PATH }} bash ./ci/setup_conda.sh ${{ join(matrix.host.python) }} - - - name: Reload shell variables - run: | - if [ -f ~/.zshrc ]; then . ~/.zshrc; fi - if [ -f ~/.profile ]; then . ~/.profile; fi - if [ -f ~/.bashrc ]; then . ~/.bashrc; fi - which conda - conda --version - conda env list - - - name: Setup VTK ${{ matrix.host.vtk }} - if: ${{steps.base-cache.outputs.cache-hit != 'true'}} - run: | - VTK_DIR=${{ env.VTK_BUILD_DIR }} VTK_SRC_DIR=${{ env.VTK_SRC_DIR }} bash ./ci/setup_vtk.sh - - - name: Build - run: | - mkdir -p ${{ env.VT_TV_BUILD_DIR }} - - CC="${{ env.CC }}" \ - CXX="${{ env.CXX }}" \ - VTK_DIR="${{ env.VTK_BUILD_DIR }}" \ - VT_TV_BUILD_DIR="${{ env.VT_TV_BUILD_DIR }}" \ - VT_TV_CLEAN=OFF \ - VT_TV_TESTS_ENABLED=${{ env.VT_TV_TESTS_ENABLED }} \ - VT_TV_COVERAGE_ENABLED=${{ env.VT_TV_COVERAGE_ENABLED }} \ - GCOV="${{ env.GCOV }}" \ - VT_TV_PYTHON_BINDINGS_ENABLED=OFF \ - VT_TV_WERROR_ENABLED=ON \ - bash ./build.sh - - - name: Test - run: | - VTK_DIR=${{ env.VTK_BUILD_DIR }} \ - VT_TV_COVERAGE_ENABLED=${{ env.VT_TV_COVERAGE_ENABLED }} \ - VT_TV_OUTPUT_DIR="${{ env.VT_TV_OUTPUT_DIR }}" \ - bash ./ci/test.sh - - - name: Build Python package (${{ join(matrix.host.python, ', ') }}) - run: | - VTK_DIR=${{ env.VTK_BUILD_DIR }} bash ./ci/python_build.sh - - - name: Test Python bindings (${{ join(matrix.host.python) }}) - run: | - VTK_DIR=${{ env.VTK_BUILD_DIR }} bash ./ci/python_test.sh - - - name: Collect artifacts - run: | - mkdir -p ${{ env.VT_TV_ARTIFACTS_DIR }} - - # > go to output directory - pushd ${{ env.VT_TV_OUTPUT_DIR }} - - echo "> add junit test report artifact" - cp "junit-report.xml" ${{ env.VT_TV_ARTIFACTS_DIR }}/ || true - - if [[ "${{ env.VT_TV_COVERAGE_ENABLED }}" == "ON" ]]; then - echo "> add `coverage --list` file artifact" - lcov --list lcov_vt-tv_test_no_deps.info > ${{ env.VT_TV_ARTIFACTS_DIR }}/lcov-list-report.txt - - echo "> add total lines coverage file artifact (percentage of lines covered)" - # might be useful for generating later a badge in ci - LCOV_SUMMARY=$(lcov --summary lcov_vt-tv_test_no_deps.info) - LCOV_TOTAL_LINES_COV=$(echo $LCOV_SUMMARY | grep -E -o 'lines......: ([0-9.]+)*' | grep -o -E '[0-9]+.[0-9]+') - echo $LCOV_TOTAL_LINES_COV > lcov-lines-total.txt - cp lcov-lines-total.txt ${{ env.VT_TV_ARTIFACTS_DIR }}/ - fi - popd - - echo "> add tests output mesh files and png artifacts" - if [ -d "${{ env.VT_TV_TESTS_OUTPUT_DIR }}" ]; then - cp "${{ env.VT_TV_TESTS_OUTPUT_DIR }}/"*".vtp" ${{ env.VT_TV_ARTIFACTS_DIR }}/ || true - cp "${{ env.VT_TV_TESTS_OUTPUT_DIR }}/"*".png" ${{ env.VT_TV_ARTIFACTS_DIR }}/ || true - fi - - echo "> list of collected artifacts:" - pushd ${{ env.VT_TV_ARTIFACTS_DIR }} - find ${{ env.VT_TV_ARTIFACTS_DIR }} | while read line; do echo "- $line"; done - popd - - - name: Unit tests - if: ${{ env.VT_TV_TESTS_ENABLED == 'ON' }} - uses: phoenix-actions/test-reporting@v15 - with: - name: Tests report - path: ${{ env.VT_TV_ARTIFACTS_DIR }}/junit-report.xml - reporter: java-junit - output-to: step-summary - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - if: always() - with: - name: vt-tv-artifacts-${{ env.CACHE_KEY }} - path: ${{ env.VT_TV_ARTIFACTS_DIR }} diff --git a/.github/workflows/build-and-test-ubuntu.yml b/.github/workflows/build-and-test-ubuntu.yml deleted file mode 100644 index 8b2792cd5..000000000 --- a/.github/workflows/build-and-test-ubuntu.yml +++ /dev/null @@ -1,111 +0,0 @@ -name: Build and Test (ubuntu) - -# Trigger the workflow on push or pull request -on: - push: - branches: - - master - pull_request: - types: [opened, reopened, synchronize, converted_to_draft, ready_for_review] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - host: [ - { - base: ubuntu-22.04, - compiler: { cc: gcc-11 }, - python: ['3.8', '3.9', '3.10', '3.11', '3.12'], - vtk: '9.2.2', - image: ubuntu_22.04-gcc_11-vtk_9.2.2-py_3.all - }, - { - base: ubuntu-22.04, - compiler: { cc: clang-11 }, - python: ['3.8', '3.9', '3.10', '3.11', '3.12'], - vtk: '9.2.2', - image: ubuntu_22.04-clang_11-vtk_9.2.2-py_3.all - }, - { - base: ubuntu-22.04, - compiler: { cc: gcc-12 }, - python: ['3.8', '3.9', '3.10', '3.11', '3.12'], - vtk: '9.3.0', - image: ubuntu_22.04-gcc_12-vtk_9.3.0-py_3.all - }, - { - base: ubuntu-24.04, - compiler: { cc: gcc-13 }, - python: ['3.8', '3.9', '3.10', '3.11', '3.12'], - vtk: '9.3.1', - image: ubuntu_24.04-gcc_13-vtk_9.3.1-py_3.all - } - ] - env: - OUTPUT_DIR: '/tmp/artifacts' - VT_TV_TESTS_ENABLED: 'ON' - VT_TV_COVERAGE_ENABLED: ${{ matrix.host.image == 'ubuntu_22.04-gcc_12-vtk_9.3.0-py_3.all' && 'ON' || 'OFF' }} # Coverage only with main test image - DOCKER_REPOSITORY: lifflander1/vt - DOCKER_TAG: ~ - name: vt-tv build and test (${{ matrix.host.base }}, ${{ matrix.host.compiler.cc }}, vtk-${{ matrix.host.vtk }}, py[${{ join(matrix.host.python, ', ') }}]) - steps: - - uses: actions/checkout@v4 - - - name: CI Variables - id: vars - run: echo "DOCKER_TAG=$(echo ${{ github.ref }} | cut -d'/' -f3- | sed 's/[^a-z0-9_-]/__/gi')" >> $GITHUB_ENV - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Inspect Builder - run: | - echo "Name: ${{ steps.buildx.outputs.name }}" - echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "Status: ${{ steps.buildx.outputs.status }}" - echo "Flags: ${{ steps.buildx.outputs.flags }}" - echo "Platforms: ${{ steps.buildx.outputs.platforms }}" - echo "DOCKER_TAG: ${{ env.DOCKER_TAG }}" - - - name: Build the Docker Image; build and test vt-tv - id: docker_build - continue-on-error: false - uses: docker/build-push-action@v6 - with: - push: false - # tags: ${{ env.DOCKER_TAG }} - context: . - file: ./ci/docker/build-and-test-ubuntu.dockerfile - build-args: | - BASE_IMAGE=${{ env.DOCKER_REPOSITORY }}:${{ matrix.host.image }} - VT_TV_TESTS_ENABLED=${{ env.VT_TV_TESTS_ENABLED }} - VT_TV_COVERAGE_ENABLED=${{ env.VT_TV_COVERAGE_ENABLED }} - outputs: type=local,dest=${{ env.OUTPUT_DIR }} - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - if: always() - with: - name: vt-tv-Artifacts-${{ matrix.host.image }} - path: ${{ env.OUTPUT_DIR }} - - - name: Unit tests - if: ${{ env.VT_TV_TESTS_ENABLED == 'ON' }} - uses: phoenix-actions/test-reporting@v15 - with: - name: Tests report - path: ${{ env.OUTPUT_DIR }}/tmp/artifacts/junit-report.xml - reporter: java-junit - output-to: step-summary - - - name: Coverage summary - if: ${{ (success() || failure()) && env.VT_TV_COVERAGE_ENABLED == 'ON' }} - run: | - echo '## Coverage' >> $GITHUB_STEP_SUMMARY - echo '```shell' >> $GITHUB_STEP_SUMMARY - cat ${{ env.OUTPUT_DIR }}/tmp/artifacts/lcov-list-report.txt >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 000000000..64bcdf952 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,167 @@ +name: Build and Test + +# Trigger the workflow on push or pull request +on: + push: + branches: + - master + - develop + pull_request: + types: [opened, reopened, synchronize, converted_to_draft, ready_for_review] + +env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WF_REPO: DARMA-tasking/workflows + WF_BRANCH: master + +jobs: + get-matrix: + name: Get matrix + runs-on: ubuntu-latest + steps: + # Note: Filtering the test environments + # A jq query can be used to filter the matrix of test environments + # - All (default): `matrix=$(cat github.json | jq '.matrix')` + # - CLang only: `matrix=$(cat github.json | jq '.matrix | map(select(.label | contains("clang")))')` + # - gcc>=11: `matrix=$(cat github.json | jq '.matrix | map(select(.name | test("gcc-[1-9][1-9]+")))')` + # - gcc>=11|clang>=14 `matrix=$(cat github.json | jq '.matrix | map(select(.name | test("gcc-[1-9][1-9]+-|clang-[1-9][2-9]+")))')` + - name: Get matrix + id: get-matrix + run: | + wget https://raw.githubusercontent.com/${{ env.WF_REPO }}/refs/heads/${{ env.WF_BRANCH }}/ci/shared/matrix/github.json + matrix=$(cat github.json | jq '.matrix | map(select(.label | contains("vtk")))') + echo "runner=$(echo $matrix)" >> $GITHUB_OUTPUT + outputs: + matrix: ${{ steps.get-matrix.outputs.runner }} + + run: + name: Run ${{ matrix.runner.name }} + runs-on: ${{ matrix.runner.runs-on }} + needs: get-matrix + env: + TS_YEAR: ~ + TS_MONTH: ~ + TS_DAY: ~ + TS: ~ + BUILD_DIR: /opt/build/vt-tv + OUTPUT_DIR: /tmp/artifacts + CCACHE_DIR: /opt/build/vt-tv/ccache + COVERAGE_ENABLED: ${{ matrix.runner.name == 'wf-amd64-ubuntu-22.04-gcc-12-vtk-cpp' && 1 || 0 }} + JUNIT_REPORT_PATH: /tmp/artifacts/junit.xml + VT_TV_TESTS_ENABLED: 'ON' + strategy: + fail-fast: false + matrix: + runner: ${{ fromJson(needs.get-matrix.outputs.matrix ) }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Display configuration + run: | + echo "Environment=${{ matrix.runner.name }}" + echo "Runner=${{ matrix.runner.runs-on }}" + if [ "${{ matrix.runner.image }}" != "" ] + then + echo "> With Docker Image=${{ matrix.runner.image }}" + else + echo "> With Runner Setup=${{ matrix.runner.setup }}" + fi + - name: Set up dependencies + run: | + if [[ "${{ matrix.runner.image }}" == "" ]]; then + echo "::group::Setup in runner" + echo "Set setup permissions..." + sudo mkdir -p /opt + sudo chown $(whoami) /opt + wget -O setup.sh https://raw.githubusercontent.com/${{ env.WF_REPO }}/refs/heads/${{ env.WF_BRANCH }}/ci/shared/scripts/setup-${{ matrix.runner.setup }}.sh + chmod +x setup.sh + export WF_SETUP_ID=${{ matrix.runner.setup }} + ./setup.sh + echo "::endgroup::" + elif [ "${{ matrix.runner.image }}" != "" ]; then + echo "::group::Pull Docker image" + docker image pull ${{ matrix.runner.image }} + echo "::endgroup::" + fi + - name: Display System Information + run: | + CMD="uname -a" + if [[ "${{ matrix.runner.image }}" == "" ]] + then + echo "Runner System Information:" + $CMD + else + echo "Docker System Information:" + docker run ${{ matrix.runner.image }} $CMD + fi + - name: Build timestamp for caching + continue-on-error: true + run: | + echo "TS_YEAR=$(date -u +%Y)" >> $GITHUB_ENV + echo "TS_MONTH=$(date -u +%m)" >> $GITHUB_ENV + echo "TS_DAY=$(date -u +%d)" >> $GITHUB_ENV + echo "TS=$(date -u +%H%M%S)" >> $GITHUB_ENV + - name: Update cache + continue-on-error: true + uses: actions/cache@v3 + env: + cache_name: ${{ matrix.runner.name }} + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ runner.os }}-${{ env.cache_name }}-${{ env.TS_YEAR }}-${{ env.TS_MONTH }}-${{ env.TS_DAY }}-${{ env.TS }} + restore-keys: | + ${{ runner.os }}-${{ env.cache_name }}-${{ env.TS_YEAR }}-${{ env.TS_MONTH }}-${{ env.TS_DAY }}- + ${{ runner.os }}-${{ env.cache_name }}-${{ env.TS_YEAR }}-${{ env.TS_MONTH }}- + ${{ runner.os }}-${{ env.cache_name }}-${{ env.TS_YEAR }}- + ${{ runner.os }}-${{ env.cache_name }}- + - name: PR tests + run: | + WORKSPACE=${{ github.workspace }} + if [[ "${{ matrix.runner.image }}" != "" ]]; then + WORKSPACE=/workspace + fi + CMD=' + cd '${WORKSPACE}'; \ + ls -l; \ + chmod +x ./ci/build.sh; \ + chmod +x ./ci/test.sh; \ + \ + VT_TV_COVERAGE_ENABLED="${{ env.COVERAGE_ENABLED }}" \ + VTTV_TEST_REPORT="{{ env.JUNIT_REPORT_PATH }}" \ + ./ci/test.sh;' + echo "Running ${CMD}" + if [[ "${{ matrix.runner.image }}" == "" ]]; then + bash -c "export $(cat .env | sed '/^[[:blank:]]*#/d;s/#.*//' | xargs) && $CMD"; + else + docker run \ + --name build-and-test-vttv \ + -w $WORKSPACE \ + -v ${{ github.workspace }}:/workspace \ + -v ${{ env.BUILD_DIR }}:/opt/build/vt-tv \ + -v ${{ env.OUTPUT_DIR }}:/tmp/artifacts \ + -e CI="1" \ + -e https_proxy="" \ + -e http_proxy="" \ + ${{ matrix.runner.image }} \ + bash -c "$CMD" + exit $(docker container inspect --format '{{.State.ExitCode}}' build-and-test-vttv) + fi + if [ -f "$VTTV_TEST_REPORT" ]; then + echo "JUNIT_REPORT_PATH=${VTTV_TEST_REPORT}" >> "$GITHUB_OUTPUT" + fi + - name: Unit tests + if: (success() || failure()) && ${{ env.JUNIT_REPORT_PATH != '' }} + uses: phoenix-actions/test-reporting@v15 + with: + name: Tests report + path: ${{ env.JUNIT_REPORT_PATH }} + reporter: java-junit + output-to: step-summary + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: vttv-output-${{ matrix.runner.name }} + path: ${{ env.OUTPUT_DIR }} diff --git a/ci/build.sh b/ci/build.sh index e4d3c53c6..6a242dbbd 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -4,6 +4,9 @@ set -ex +CURRENT_DIR="$(dirname -- "$(realpath -- "$0")")" +PARENT_DIR="$(dirname "$CURRENT_DIR")" + # Calls build script with CI configuration # (Specific path, enable tests and coverage, warnings as errors) bash -c "VT_TV_BUILD_DIR=/opt/build/vt-tv \ @@ -11,6 +14,6 @@ bash -c "VT_TV_BUILD_DIR=/opt/build/vt-tv \ VT_TV_TESTS_ENABLED=ON \ VT_TV_COVERAGE_ENABLED=${VT_TV_COVERAGE_ENABLED:-OFF} \ VT_TV_WERROR_ENABLED=ON \ - /opt/src/vt-tv/build.sh" + ${PARENT_DIR}/build.sh" echo "VT-TV build success" diff --git a/ci/test.sh b/ci/test.sh index 23e626b0e..178e3846d 100644 --- a/ci/test.sh +++ b/ci/test.sh @@ -12,13 +12,20 @@ VT_TV_BUILD_DIR=${VT_TV_BUILD_DIR:-"/opt/build/vt-tv"} VT_TV_OUTPUT_DIR=${VT_TV_OUTPUT_DIR:-"$VT_TV_SRC_DIR/output"} VT_TV_TESTS_OUTPUT_DIR=${VT_TV_TESTS_OUTPUT_DIR:-"$VT_TV_OUTPUT_DIR/tests"} -VT_TV_TEST_CMD="VTK_DIR=/opt/build/vtk \ - VT_TV_BUILD=OFF \ +VT_TV_TEST_CMD="\ + pwd + echo ------------------------------ + echo $CURRENT_DIR + echo ------------------------------ + ls -ltra ci + chmod +x $CURRENT_DIR/build.sh + VTK_DIR=/opt/build/vtk \ + VT_TV_BUILD=ON \ VT_TV_BUILD_DIR=${VT_TV_BUILD_DIR} \ VT_TV_COVERAGE_ENABLED=${VT_TV_COVERAGE_ENABLED:-OFF} \ VT_TV_OUTPUT_DIR=$VT_TV_OUTPUT_DIR \ VT_TV_RUN_TESTS=ON \ - $VT_TV_SRC_DIR/build.sh" + $CURRENT_DIR/build.sh" # Run tests if [[ $(uname -a) != *"Darwin"* ]]; then