|
| 1 | +name: 'Build' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + # Runner configuration |
| 7 | + runner: |
| 8 | + type: string |
| 9 | + required: true |
| 10 | + |
| 11 | + # Build configuration |
| 12 | + cxx: |
| 13 | + type: string |
| 14 | + required: false |
| 15 | + default: '' |
| 16 | + cxxflags: |
| 17 | + type: string |
| 18 | + required: false |
| 19 | + default: '' |
| 20 | + shared: |
| 21 | + type: string |
| 22 | + required: false |
| 23 | + default: 'OFF' |
| 24 | + simdutf: |
| 25 | + type: string |
| 26 | + required: false |
| 27 | + default: 'OFF' |
| 28 | + build_type: |
| 29 | + type: string |
| 30 | + required: false |
| 31 | + default: '' |
| 32 | + |
| 33 | + # CMake options |
| 34 | + cmake_args: |
| 35 | + type: string |
| 36 | + required: false |
| 37 | + default: '' |
| 38 | + testing: |
| 39 | + type: string |
| 40 | + required: false |
| 41 | + default: 'ON' |
| 42 | + benchmarks: |
| 43 | + type: string |
| 44 | + required: false |
| 45 | + default: 'OFF' |
| 46 | + |
| 47 | + # Windows-specific |
| 48 | + arch: |
| 49 | + type: string |
| 50 | + required: false |
| 51 | + default: '' |
| 52 | + toolset: |
| 53 | + type: string |
| 54 | + required: false |
| 55 | + default: '' |
| 56 | + |
| 57 | + # Post-build actions |
| 58 | + run_tests: |
| 59 | + type: boolean |
| 60 | + required: false |
| 61 | + default: true |
| 62 | + run_benchmarks: |
| 63 | + type: boolean |
| 64 | + required: false |
| 65 | + default: false |
| 66 | + run_install: |
| 67 | + type: boolean |
| 68 | + required: false |
| 69 | + default: false |
| 70 | + |
| 71 | + # Cross-compilation |
| 72 | + toolchain_file: |
| 73 | + type: string |
| 74 | + required: false |
| 75 | + default: '' |
| 76 | + qemu_cpu: |
| 77 | + type: string |
| 78 | + required: false |
| 79 | + default: '' |
| 80 | + qemu_ld_prefix: |
| 81 | + type: string |
| 82 | + required: false |
| 83 | + default: '' |
| 84 | + setup_script: |
| 85 | + type: string |
| 86 | + required: false |
| 87 | + default: '' |
| 88 | + |
| 89 | + # run-on-arch-action (for s390x, etc.) |
| 90 | + use_run_on_arch: |
| 91 | + type: boolean |
| 92 | + required: false |
| 93 | + default: false |
| 94 | + run_on_arch_arch: |
| 95 | + type: string |
| 96 | + required: false |
| 97 | + default: '' |
| 98 | + run_on_arch_distro: |
| 99 | + type: string |
| 100 | + required: false |
| 101 | + default: '' |
| 102 | + run_on_arch_install: |
| 103 | + type: string |
| 104 | + required: false |
| 105 | + default: '' |
| 106 | + run_on_arch_run: |
| 107 | + type: string |
| 108 | + required: false |
| 109 | + default: '' |
| 110 | + |
| 111 | +permissions: |
| 112 | + contents: read |
| 113 | + |
| 114 | +jobs: |
| 115 | + build: |
| 116 | + runs-on: ${{ inputs.runner }} |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 119 | + |
| 120 | + - name: Setup Runner |
| 121 | + if: ${{ !inputs.use_run_on_arch }} |
| 122 | + uses: ./.github/actions/setup-runner |
| 123 | + |
| 124 | + - name: Setup environment |
| 125 | + if: ${{ !inputs.use_run_on_arch && inputs.setup_script != '' }} |
| 126 | + shell: bash |
| 127 | + run: ${{ inputs.setup_script }} |
| 128 | + |
| 129 | + - name: Configure |
| 130 | + if: ${{ !inputs.use_run_on_arch }} |
| 131 | + shell: bash |
| 132 | + run: | |
| 133 | + CMAKE_ARGS="-G Ninja -B build" |
| 134 | + CMAKE_ARGS="$CMAKE_ARGS -DADA_TESTING=${{ inputs.testing }}" |
| 135 | + CMAKE_ARGS="$CMAKE_ARGS -DADA_BENCHMARKS=${{ inputs.benchmarks }}" |
| 136 | + CMAKE_ARGS="$CMAKE_ARGS -DBUILD_SHARED_LIBS=${{ inputs.shared }}" |
| 137 | + CMAKE_ARGS="$CMAKE_ARGS -DADA_USE_SIMDUTF=${{ inputs.simdutf }}" |
| 138 | + if [ -n "${{ inputs.build_type }}" ]; then |
| 139 | + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=${{ inputs.build_type }}" |
| 140 | + fi |
| 141 | + if [ -n "${{ inputs.toolchain_file }}" ]; then |
| 142 | + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${{ inputs.toolchain_file }}" |
| 143 | + fi |
| 144 | + if [ -n "${{ inputs.cmake_args }}" ]; then |
| 145 | + CMAKE_ARGS="$CMAKE_ARGS ${{ inputs.cmake_args }}" |
| 146 | + fi |
| 147 | + if [ -n "${{ inputs.qemu_ld_prefix }}" ]; then |
| 148 | + export QEMU_LD_PREFIX="${{ inputs.qemu_ld_prefix }}" |
| 149 | + fi |
| 150 | + if [ -n "${{ inputs.qemu_cpu }}" ]; then |
| 151 | + export QEMU_CPU="${{ inputs.qemu_cpu }}" |
| 152 | + fi |
| 153 | + echo "Running: cmake $CMAKE_ARGS" |
| 154 | + cmake $CMAKE_ARGS |
| 155 | + env: |
| 156 | + CXX: ${{ inputs.cxx }} |
| 157 | + CXXFLAGS: ${{ inputs.cxxflags }} |
| 158 | + |
| 159 | + - name: Build |
| 160 | + if: ${{ !inputs.use_run_on_arch }} |
| 161 | + run: cmake --build build -j=4 |
| 162 | + |
| 163 | + - name: Test |
| 164 | + if: ${{ !inputs.use_run_on_arch && inputs.run_tests }} |
| 165 | + shell: bash |
| 166 | + run: | |
| 167 | + if [ -n "${{ inputs.qemu_ld_prefix }}" ]; then |
| 168 | + export QEMU_LD_PREFIX="${{ inputs.qemu_ld_prefix }}" |
| 169 | + fi |
| 170 | + if [ -n "${{ inputs.qemu_cpu }}" ]; then |
| 171 | + export QEMU_CPU="${{ inputs.qemu_cpu }}" |
| 172 | + fi |
| 173 | + ctest --output-on-failure --test-dir build |
| 174 | +
|
| 175 | + - name: Run benchmarks |
| 176 | + if: ${{ !inputs.use_run_on_arch && inputs.run_benchmarks }} |
| 177 | + shell: bash |
| 178 | + run: cd build && benchmarks/bench |
| 179 | + |
| 180 | + - name: Install and test |
| 181 | + if: ${{ !inputs.use_run_on_arch && inputs.run_install }} |
| 182 | + shell: bash |
| 183 | + run: | |
| 184 | + cmake --install build |
| 185 | + cmake -DCMAKE_INSTALL_PREFIX:PATH=../../destination -S tests/installation -B build_install_test |
| 186 | + cmake --build build_install_test |
| 187 | + ./build_install_test/main |
| 188 | +
|
| 189 | + # run-on-arch path (for s390x and similar architectures) |
| 190 | + - uses: uraimo/run-on-arch-action@d94c13912ea685de38fccc1109385b83fd79427d # v3.0.1 |
| 191 | + if: ${{ inputs.use_run_on_arch }} |
| 192 | + name: Build and Test |
| 193 | + with: |
| 194 | + arch: ${{ inputs.run_on_arch_arch }} |
| 195 | + distro: ${{ inputs.run_on_arch_distro }} |
| 196 | + githubToken: ${{ github.token }} |
| 197 | + install: ${{ inputs.run_on_arch_install }} |
| 198 | + run: ${{ inputs.run_on_arch_run }} |
0 commit comments