diff --git a/.github/actions/test-build-run/action.yml b/.github/actions/test-build-run/action.yml deleted file mode 100644 index 21222f380..000000000 --- a/.github/actions/test-build-run/action.yml +++ /dev/null @@ -1,247 +0,0 @@ -name: Build and Run Tests -description: Builds and runs all tests as one of { ansi, coverage, sanitize, warning }. - -inputs: - test_type: - description: 'One of { ansi, coverage, sanitize, warning }' - required: true - default: '' - preset: - description: 'CMake preset used to build patomic and googletest' - required: true - default: '' - architecture: - description: 'CPU architecture tests are run on, passed to QEMU' - required: true - default: '' - triple: - description: 'Platform triple to compile for, used to install correct compiler and sysroot' - required: true - default: '' - cmake_build_shared: - description: 'Determines value of BUILD_SHARED_LIBS for CMake, must be considered a boolean by CMake' - required: true - default: '' - patomic_path: - description: 'Source directory of patomic repository' - required: true - default: '' - -runs: - using: composite - steps: - - name: Check No Empty Inputs - shell: bash - run: | - # Check No Empty Inputs - - # checks input is not empty - check_input() { - input_name="${1}" - input_value="${2}" - if [[ -z "${input_value}" ]]; then - echo "Error: required input '${input_name}' is empty or was not specified." - exit 1 - fi - } - - # apply function to all inputs - check_input "test_type" "${{ inputs.test_type }}" - check_input "preset" "${{ inputs.preset }}" - check_input "architecture" "${{ inputs.architecture }}" - check_input "triple" "${{ inputs.triple }}" - check_input "cmake_build_shared" "${{ inputs.cmake_build_shared }}" - check_input "patomic_path" "${{ inputs.patomic_path }}" - - - name: Parse Input Values Into New Attributes - shell: bash - run: | - # Parse Input Values Into New Attributes - - # List of variables written to GITHUB_ENV: - # - ACTION_CMAKE_BUILD_TYPE - # - ACTION_OS - # - ACTION_COMPILER - # - ACTION_COMPILER_VERSION - # - ACTION_GCC_VERSION - # - ACTION_LLVM_VERSION - # - ACTION_BUILD_SHARED - # - ACTION_UNIQUE_CACHE_ID - # - ACTION_UNIQUE_FILE_NAME - # - ACTION_WORKING_DIR - - # cmake_build_type component - generate - if [[ "${{ inputs.test_type }}" == "ansi" ]]; then - cmake_build_type="Release" - elif [[ "${{ inputs.test_type }}" == "coverage" ]]; then - cmake_build_type="Debug" - elif [[ "${{ inputs.test_type }}" == "sanitize" ]]; then - cmake_build_type="Debug" - elif [[ "${{ inputs.test_type }}" == "warning" ]]; then - cmake_build_type="Release" - else - echo "Error: input 'test_type' has unknown value '${{ inputs.test_type }}'; must be one of 'ansi', 'coverage', 'sanitize', 'warning'." - exit 1 - fi - - # cmake_build_type component - save - echo "ACTION_CMAKE_BUILD_TYPE: ${cmake_build_type}" - echo "ACTION_CMAKE_BUILD_TYPE=${cmake_build_type}" >> $GITHUB_ENV - - # os component - generate - if [[ "${{ runner.os }}" == "Linux" ]]; then - os="ubuntu" - elif [[ "${{ runner.os }}" == "macOS" ]]; then - os="macos" - elif [[ "${{ runner.os }}" == "Windows" ]]; then - os="windows" - else - echo "Error: running on unknown OS '${{ runner.os }}'; does not match one of 'Linux', 'macOS', or 'Windows'." - exit 1 - fi - - # os component - save - echo "ACTION_OS: ${os}" - echo "ACTION_OS=${os}" >> $GITHUB_ENV - - # compiler component - generate - if [[ "${{ inputs.preset }}" == *"clang"* ]]; then - compiler="clang" - elif [[ "${{ inputs.preset }}" == *"gcc"* ]]; then - compiler="gcc" - elif [[ "${{ inputs.preset }}" == *"msvc"* ]]; then - compiler="msvc" - else - echo "Error: cannot determine known compiler from 'preset' value '${{ inputs.preset }}'; must contain one of 'clang', 'gcc', or 'msvc'." - exit 1 - fi - - # compiler component - save - echo "ACTION_COMPILER: ${compiler}" - echo "ACTION_COMPILER=${compiler}" >> $GITHUB_ENV - - # compiler version component - generate - gcc_version="ACTION_GCC_VERSION_not_set_on_native" - llvm_version="ACTION_LLVM_VERSION_not_set_on_native" - if [[ "${{ inputs.preset }}" == *"qemu"* ]]; then - gcc_version="11" - llvm_version="15" - if [[ "${compiler}" == "clang" ]]; then - compiler_version="${clang_version}" - elif [[ "${compiler}" == "gcc" ]]; then - compiler_version="${gcc_version}" - else - echo "Error: only 'clang' and 'gcc' compilers are valid when running with qemu preset." - exit 1 - fi - else - compiler_version="ACTION_COMPILER_VERSION_not_set_on_native" - fi - - # compiler version component - save - echo "ACTION_COMPILER_VERSION: ${compiler_version}" - echo "ACTION_COMPILER_VERSION=${compiler_version}" >> $GITHUB_ENV - - # individual compiler version component - generate, save - echo "ACTION_GCC_VERSION: ${gcc_version}" - echo "ACTION_GCC_VERSION=${gcc_version}" >> $GITHUB_ENV - echo "ACTION_LLVM_VERSION: ${llvm_version}" - echo "ACTION_LLVM_VERSION=${llvm_version}" >> $GITHUB_ENV - - # build_shared component - generate - true_values=("1" "on" "yes" "true" "y") - false_values=("0" "off" "no" "false" "n") - cmake_build_shared_lower=$(echo "${{ inputs.cmake_build_shared }}" | tr '[:upper:]' '[:lower:]') - if [[ " ${true_values[@]} " =~ " ${cmake_build_shared_lower} " ]]; then - build_shared="shared" - elif [[ "${false_values[@]} " =~ " ${cmake_build_shared_lower} " ]]; then - build_shared="static" - else - echo "Error: input 'cmake_build_shared' value is '${{ inputs.cmake_build_shared }}', must be one of: ${true_values[*]} ${false_values[*]} (case-insensitive)." - exit 1 - fi - - # build_shared component - save - echo "ACTION_BUILD_SHARED: ${build_shared}" - echo "ACTION_BUILD_SHARED=${build_shared}" >> $GITHUB_ENV - - # unique_cache_id component - generate, save - unique_cache_id="${{ inputs.triple }}-${os}-${compiler}-${build_shared}" - echo "ACTION_UNIQUE_CACHE_ID: ${unique_cache_id}" - echo "ACTION_UNIQUE_CACHE_ID=${unique_cache_id}" >> $GITHUB_ENV - - # unique_file_name component - generate, save - # this is separate because: - # - we don't want the whole triple in file names - # - we may need to change this if we support multiple ABIs - # - separate from cache-id so we can change it without affecting caches - unique_file_name="${{ inputs.architecture }}-${os}-${compiler}-${build_shared}" - echo "ACTION_UNIQUE_FILE_NAME: ${unique_file_name}" - echo "ACTION_UNIQUE_FILE_NAME=${unique_file_name}" >> $GITHUB_ENV - - # working_dir component - generate, save - working_dir="${{ runner.temp }}/${unique_cache_id}" - mkdir -p "${working_dir}" - echo "ACTION_WORKING_DIR: ${working_dir}" - echo "ACTION_WORKING_DIR=${working_dir}" >> $GITHUB_ENV - - - name: Install Cross-Compiling Toolchain - if: runner.os == 'Linux' && contains(inputs.preset, 'qemu') - shell: bash - run: | - # Install Cross-Compiling Toolchain - - sudo apt update - sudo apt install g++-${{ env.ACTION_GCC_VERSION }}-multilib - sudo apt install g++-${{ env.ACTION_GCC_VERSION }}-${{ inputs.triple }} - sudo apt install llvm-${{ env.ACTION_LLVM_VERSION }} - sudo apt install clang-${{ env.ACTION_LLVM_VERSION }} - sudo apt install qemu-user - - - name: Restore Cached Sysroot (with GoogleTest) - id: cache-sysroot - uses: actions/cache@v3 - with: - path: ${{ env.ACTION_WORKING_DIR }}/sysroot - key: action-test-build-run-${{ env.ACTION_UNIQUE_CACHE_ID }} - - - name: Set Up Sysroot - if: runner.os == 'Linux' && contains(inputs.preset, 'qemu') && steps.cache-sysroot.outputs.cache-hit != 'true' - shell: bash - # cannot use symlink or reference directory directly, will not work - run: | - # Set Up Sysroot - - cp -r /usr/${{ inputs.triple }}/ ${{ env.ACTION_WORKING_DIR }}/sysroot - - - name: Checkout GoogleTest - if: steps.cache-sysroot.outputs.cache-hit != 'true' - uses: actions/checkout@v4 - with: - repository: google/googletest - # paths passed to actions/checkout are prefixed with $GITHUB_WORKSPACE - path: googletest-action-temp-${{ env.ACTION_UNIQUE_CACHE_ID }} - - - name: Move GoogleTest to Working Directory - if: steps.cache-sysroot.outputs.cache-hit != 'true' - shell: bash - run: | - # Move GoogleTest to Working Directory - - cp -r ${{ github.workspace }}/googletest-action-temp-${{ env.ACTION_UNIQUE_CACHE_ID }}/ ${{ env.ACTION_WORKING_DIR }}/googletest - rm -rf ${{ github.workspace }}/googletest-action-temp-${{ env.ACTION_UNIQUE_CACHE_ID }} - - - name: Build and Install GoogleTest - if: steps.cache-sysroot.outputs.cache-hit != 'true' - shell: bash - run: | - # Build and Install GoogleTest - - cd ${{ env.ACTION_WORKING_DIR }}/googletest - cp -r ${{ github.workspace }}/${{ inputs.patomic_path }}/ci/ ./ - cp ${{github.workspace }}/${{ inputs.patomic_path }}/CMakePresets.json . - mkdir build - cd build - cmake --preset ${{ inputs.preset }} -DCMAKE_CXX_FLAGS="" -DBUILD_SHARED_LIBS=${{ inputs.cmake_build_shared }} -DCMAKE_BUILD_TYPE=${{ env.ACTION_CMAKE_BUILD_TYPE }} -Dgtest_force_shared_crt=ON -Dgtest_hide_internal_symbols=ON .. - cmake --build . --verbose - cmake --install . --prefix ${{ env.ACTION_WORKING_DIR }}/sysroot diff --git a/.github/workflows/reusable/test-warning.yml b/.github/workflows/reusable/test-warning.yml index d120c4767..414310e85 100644 --- a/.github/workflows/reusable/test-warning.yml +++ b/.github/workflows/reusable/test-warning.yml @@ -3,6 +3,11 @@ name: Run Tests with Warnings on: workflow_call: inputs: + os: + description: 'Used to set the runs-on attribute, must be one of macos, ubuntu, windows' + required: true + type: string + default: '' preset: description: 'CMake preset used to build patomic and googletest' required: true @@ -31,6 +36,7 @@ on: jobs: warning: + runs-on: ${{ inputs.os }}-latest steps: - name: Check No Empty Inputs shell: bash @@ -42,6 +48,8 @@ jobs: if [[ -z "${input_value}" ]]; then echo "Error: required input '${input_name}' is empty or was not specified." exit 1 + else + echo "${input_name}: ${input_value}" fi } diff --git a/.github/workflows/test-warning.yml b/.github/workflows/test-warning.yml deleted file mode 100644 index ec30685fb..000000000 --- a/.github/workflows/test-warning.yml +++ /dev/null @@ -1,364 +0,0 @@ -name: Run Tests With Warnings - -on: - pull_request: - branches: - - '**' - -jobs: - test-native: - runs-on: ${{ matrix.os }}-latest - env: - PATOMIC_CI_ID: ${{ matrix.architecture }}-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build-shared }} - strategy: - matrix: - # verbose labels make things easier to read in GitHub Actions - # platform gets converted to os, preset, compiler, architecture - platform: - - windows-gcc-x86_64 - - windows-msvc-x86_32 - - windows-msvc-x86_64 - - macos-clang-x86_64 - - linux-clang-x86_64 - - linux-gcc-x86_64 - # build-shared gets converted to cmake option - build-shared: - - static - - shared - # convert verbose labels to usable values (which don't appear in action name) - # also just other variables that we don't want appearing in action name - include: - # use Release for everything - - cmake-build-type: Release - # build-shared -> cmake-build-shared - - build-shared: static - cmake-build-shared: OFF - - build-shared: shared - cmake-build-shared: ON - # platform -> os, preset, compiler, architecture - - platform: windows-gcc-x86_64 - os: windows - preset: patomic-ci-native-unix-gcc-warning - compiler: gcc - architecture: x86_64 - - platform: windows-msvc-x86_32 - os: windows - preset: patomic-ci-native-windows-msvc-warning -A Win32 - compiler: msvc - architecture: x86_32 - - platform: windows-msvc-x86_64 - os: windows - preset: patomic-ci-native-windows-msvc-warning -A x64 - compiler: msvc - architecture: x86_64 - - platform: macos-clang-x86_64 - os: macos - preset: patomic-ci-native-unix-clang-warning - compiler: clang - architecture: x86_64 - - platform: linux-clang-x86_64 - os: ubuntu - preset: patomic-ci-native-unix-clang-warning - compiler: clang - architecture: x86_64 - - platform: linux-gcc-x86_64 - os: ubuntu - preset: patomic-ci-native-unix-gcc-warning - compiler: gcc - architecture: x86_64 - - steps: - - name: Checkout patomic - uses: actions/checkout@v4 - with: - path: patomic - - - name: Try Using Reusable workflow - uses: patomic/patomic/.github/workflows/reusable/test-warning.yml@feature/ghi-20-setup-pipeline-and-presets - with: - test_type: ansi - preset: ${{ matrix.preset }} - architecture: ${{ matrix.architecture }} - triple: ${{ matrix.platform }} - cmake_build_shared: ${{ matrix.cmake-build-shared }} - patomic_path: patomic - - - name: Restore Cached GoogleTest - id: cache-googletest - uses: actions/cache@v3 - with: - path: googletest/build/install - key: googletest-${{ env.PATOMIC_CI_ID }} - - - name: Checkout GoogleTest - if: steps.cache-googletest.outputs.cache-hit != 'true' - uses: actions/checkout@v4 - with: - repository: google/googletest - path: googletest - - - name: Build and Install GoogleTest - if: steps.cache-googletest.outputs.cache-hit != 'true' - run: | - cd googletest - cp ../patomic/CMakePresets.json . - mkdir build - cd build - cmake --preset ${{ matrix.preset }} -DCMAKE_CXX_FLAGS="" -DBUILD_SHARED_LIBS=${{ matrix.cmake-build-shared }} -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -Dgtest_force_shared_crt=ON -Dgtest_hide_internal_symbols=ON .. - cmake --build . --verbose --config ${{ matrix.cmake-build-type }} - cmake --install . --config ${{ matrix.cmake-build-type }} --prefix install - - - name: Build patomic - run: | - cd patomic - mkdir build - cd build - cmake --preset ${{ matrix.preset }} -DBUILD_SHARED_LIBS=${{ matrix.cmake-build-shared }} -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DGTest_ROOT:PATH="../../googletest/build/install/lib/cmake/GTest" .. - cmake --build . --verbose --config ${{ matrix.cmake-build-type }} - - - name: Test patomic - continue-on-error: true - run: | - cd patomic/build - ctest --verbose --output-junit Testing/Temporary/results.xml --build-config ${{ matrix.cmake-build-type }} . - - - name: Prepare Test Results - shell: bash - run: | - mkdir upload - python3 patomic/test/improve_ctest_xml.py --input patomic/build/Testing/Temporary/results.xml --triple ${{ env.PATOMIC_CI_ID }} --output upload/${{ env.PATOMIC_CI_ID }}.xml - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - with: - name: test-warning-results - path: upload/ - - test-qemu: - runs-on: ubuntu-latest - env: - PATOMIC_CI_ID: ${{ matrix.architecture }}-ubuntu-${{ matrix.compiler }}-${{ matrix.build-shared }} - PATOMIC_CI_XARCH: ${{ matrix.architecture }} - PATOMIC_CI_XTRIPLE: ${{ matrix.triple }} - # PATOMIC_CI_XCOMPILER is specified as a cache variable in the appropriate presets (since it's a constant) - PATOMIC_CI_XCOMPILER_VERSION: ${{ matrix.compiler-version }} - PATOMIC_CI_SYSROOT: ${{ matrix.sysroot }} - strategy: - matrix: - # architecture gets converted to triple - # short form here so that it doesn't take up the whole GitHub Action name - architecture: - - aarch64 - - alpha - - arm - - armhf - - hppa - # fixme: m68k is supported, but ICEs clang and segfaults qemu when built with gcc (GHI #25) - # - m68k - - mips - - mips64 - - mips64el - - mipsel - - ppc - - ppc64 - - ppc64le - - riscv64 - - s390x - # fixme: sh4 is supported (only for gcc), but segfaults qemu when built with gcc (GHI #25) - # - sh4 - - sparc64 - - x86_32 - compiler: - - clang - - gcc - # build-shared gets converted to cmake option - build-shared: - - static - - shared - # exclude architectures unsupported by certain compilers - exclude: - - architecture: alpha - compiler: clang - - architecture: hppa - compiler: clang - # fixme: x86_32 is supported, but not sure how to make it work with clang (GHI #25) - - architecture: x86_32 - compiler: clang - # fixme: riscv64 is supported, but gcc errors on a system header (GHI #25) - - architecture: riscv64 - compiler: gcc - - architecture: sh4 - compiler: clang - # fixme: sparc64 is supported, but segfaults qemu when built with gcc (GHI #25) - - architecture: sparc64 - compiler: gcc - # convert verbose labels to usable values (which don't appear in action name) - # also just other variables that we don't want appearing in action name - include: - # common local sysroot location for everything - # don't prefix with ${HOME} because not always expanded by actions - - sysroot: '~/sysroot' - # use Release for everything - - cmake-build-type: Release - # build-shared -> cmake-build-shared - - build-shared: static - cmake-build-shared: OFF - - build-shared: shared - cmake-build-shared: ON - # toolchain versions to use - - gcc-version: 10 - - llvm-version: 15 - # compiler -> preset, compiler-version - - compiler: clang - preset: patomic-ci-qemu-ubuntu-clang-warning - compiler-version: 15 - - compiler: gcc - preset: patomic-ci-qemu-ubuntu-gcc-warning - compiler-version: 10 - # architecture -> triple - - architecture: aarch64 - triple: aarch64-linux-gnu - - architecture: alpha - triple: alpha-linux-gnu - - architecture: arm - triple: arm-linux-gnueabi - - architecture: armhf - triple: arm-linux-gnueabihf - - architecture: hppa - triple: hppa-linux-gnu - # - architecture: m68k - # triple: m68k-linux-gnu - - architecture: mips - triple: mips-linux-gnu - - architecture: mips64 - triple: mips64-linux-gnuabi64 - - architecture: mips64el - triple: mips64el-linux-gnuabi64 - - architecture: mipsel - triple: mipsel-linux-gnu - - architecture: ppc - triple: powerpc-linux-gnu - - architecture: ppc64 - triple: powerpc64-linux-gnu - - architecture: ppc64le - triple: powerpc64le-linux-gnu - - architecture: riscv64 - triple: riscv64-linux-gnu - - architecture: s390x - triple: s390x-linux-gnu - # - architecture: sh4 - # triple: sh4-linux-gnu - - architecture: sparc64 - triple: sparc64-linux-gnu - - architecture: x86_32 - triple: i686-linux-gnu - - steps: - - name: Install Toolchains and Qemu - run: | - sudo apt update - sudo apt install g++-${{ matrix.gcc-version }}-multilib - sudo apt install g++-${{ matrix.gcc-version }}-${{ matrix.triple }} - sudo apt install llvm-${{ matrix.llvm-version }} - sudo apt install clang-${{ matrix.llvm-version }} - sudo apt install qemu-user - - # - name: Show what architectures clang-${{ matrix.llvm-version }} supports - # run: | - # clang-${{ matrix.llvm-version }} --print-targets - - # - name: Display what was Installed - # run: | - # sudo apt update - # sudo apt-cache dumpavail | sudo dpkg --merge-avail - - # sudo apt install apt-file - # sudo apt install tree - # sudo apt-file update - # sudo apt-file list g++-${{ matrix.gcc-version }}-multilib - # sudo apt-file list g++-${{ matrix.gcc-version }}-${{ matrix.triple }} - # tree /usr/${{ matrix.triple }} - # tree /usr/lib/gcc-cross/${{ matrix.triple }}/${{ matrix.gcc-version}} - - - name: Checkout patomic - uses: actions/checkout@v4 - with: - path: patomic - - - name: Restore Cached GoogleTest and Sysroot - id: cache-googletest - uses: actions/cache@v3 - with: - path: ${{ matrix.sysroot }} - # need both gcc and llvm version in case of building with clang but using gcc sysroot - key: googletest-${{ env.PATOMIC_CI_ID }}-${{ matrix.gcc-version }}-${{ matrix.llvm-version }} - - - name: Set Up Sysroot - if: steps.cache-googletest.outputs.cache-hit != 'true' - # cannot use symlink or reference directory directly, will not work - run: | - cp -r /usr/${{ matrix.triple }}/ ${{ matrix.sysroot }} - - - name: Checkout GoogleTest - if: steps.cache-googletest.outputs.cache-hit != 'true' - uses: actions/checkout@v4 - with: - repository: google/googletest - path: googletest - - - name: Build and Install GoogleTest - if: steps.cache-googletest.outputs.cache-hit != 'true' - run: | - cd googletest - cp -r ../patomic/ci/ ./ - cp ../patomic/CMakePresets.json . - mkdir build - cd build - cmake --preset ${{ matrix.preset }} -DCMAKE_CXX_FLAGS="" -DBUILD_SHARED_LIBS=${{ matrix.cmake-build-shared }} -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -Dgtest_force_shared_crt=ON -Dgtest_hide_internal_symbols=ON .. - cmake --build . --verbose - cmake --install . --prefix ${{ matrix.sysroot }} - - - name: Build patomic - run: | - cd patomic - mkdir build - cd build - cmake --preset ${{ matrix.preset }} -DBUILD_SHARED_LIBS=${{ matrix.cmake-build-shared }} -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DGTest_ROOT:PATH="${{ matrix.sysroot }}/lib/cmake/GTest" .. - cmake --build . --verbose - - - name: Test patomic - continue-on-error: true - run: | - cd patomic/build - ctest --verbose --output-junit Testing/Temporary/results.xml . - - - name: Prepare Test Results - run: | - mkdir upload - python3 patomic/test/improve_ctest_xml.py --input patomic/build/Testing/Temporary/results.xml --triple ${{ env.PATOMIC_CI_ID }} --output upload/${{ env.PATOMIC_CI_ID }}.xml - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - with: - name: test-warning-results - path: upload/ - - publish-results: - runs-on: ubuntu-latest - needs: - - test-native - - test-qemu - - steps: - - name: Download Test Result Artifacts - uses: actions/download-artifact@v3 - with: - name: test-warning-results - path: test-warning-results/ - - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - action_fail: true - action_fail_on_inconclusive: true - check_name: "Tests Results: Warning" - files: test-warning-results/**/*.xml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..ca9c453db --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,17 @@ +name: Run All Tests + +on: + pull_request: + branches: + - '**' + +jobs: + run-tests: + uses: doodspav/patomic/.github/workflows/reusable/test-warning.yml@feature/ghi-20-inner-stuff + with: + os: ubuntu + preset: some-preset + architecture: some-architecture + triple: some-triple + cmake_build_shared: ON + patomic_path: some-path