|
| 1 | +name: Reusable SYCL Linux build and test workflow |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - '.github/workflows/sycl_linux_build_and_test.yml' |
| 7 | + workflow_call: |
| 8 | + inputs: |
| 9 | + cc: |
| 10 | + type: string |
| 11 | + required: false |
| 12 | + default: "gcc" |
| 13 | + cxx: |
| 14 | + type: string |
| 15 | + required: false |
| 16 | + default: "g++" |
| 17 | + build_image: |
| 18 | + type: string |
| 19 | + required: false |
| 20 | + default: "ghcr.io/intel/llvm/ubuntu2004_base:latest" |
| 21 | + build_runs_on: |
| 22 | + type: string |
| 23 | + required: false |
| 24 | + default: "ubuntu-latest" |
| 25 | + build_github_cache: |
| 26 | + type: boolean |
| 27 | + required: false |
| 28 | + default: false |
| 29 | + build_cache_root: |
| 30 | + type: string |
| 31 | + required: true |
| 32 | + build_cache_suffix: |
| 33 | + type: string |
| 34 | + required: false |
| 35 | + default: "default" |
| 36 | + build_cache_size: |
| 37 | + type: string |
| 38 | + required: false |
| 39 | + default: 2G |
| 40 | + build_configure_extra_args: |
| 41 | + type: string |
| 42 | + required: false |
| 43 | + default: "" |
| 44 | + build_artifact_suffix: |
| 45 | + type: string |
| 46 | + required: true |
| 47 | + build_upload_artifact: |
| 48 | + type: boolean |
| 49 | + required: false |
| 50 | + default: false |
| 51 | + |
| 52 | +jobs: |
| 53 | + configure: |
| 54 | + name: Pre-build configuration |
| 55 | + runs-on: ubuntu-latest |
| 56 | + outputs: |
| 57 | + params: ${{ steps.input-parameters.outputs.params }} |
| 58 | + steps: |
| 59 | + - id: input-parameters |
| 60 | + env: |
| 61 | + INPUTS: ${{ toJSON(inputs) }} |
| 62 | + run: | |
| 63 | + if [[ "$GITHUB_EVENT_NAME" != "workflow_call" ]]; then |
| 64 | + INPUTS="{ |
| 65 | + \"cc\":\"gcc\", |
| 66 | + \"cxx\":\"g++\", |
| 67 | + \"build_runs_on\":\"sycl-precommit-linux\", |
| 68 | + \"build_image\":\"ghcr.io/intel/llvm/ubuntu2004_base:latest\", |
| 69 | + \"build_github_cache\":\"false\", |
| 70 | + \"build_cache_root\":\"/__w/\", |
| 71 | + \"build_cache_suffix\":\"default\", |
| 72 | + \"build_cache_size\":\"2G\", |
| 73 | + \"build_configure_extra_args\":\"\", |
| 74 | + \"build_artifact_suffix\":\"default\", |
| 75 | + \"build_upload_artifact\":\"false\" |
| 76 | + }" |
| 77 | + fi |
| 78 | + INPUTS="${INPUTS//'%'/'%25'}" |
| 79 | + INPUTS="${INPUTS//$'\n'/'%0A'}" |
| 80 | + INPUTS="${INPUTS//$'\r'/'%0D'}" |
| 81 | + echo "::set-output name=params::$INPUTS" |
| 82 | + echo "$INPUTS" |
| 83 | + build: |
| 84 | + name: Build SYCL toolchain |
| 85 | + needs: configure |
| 86 | + runs-on: ${{ fromJSON(needs.configure.outputs.params).build_runs_on }} |
| 87 | + container: |
| 88 | + image: ${{ fromJSON(needs.configure.outputs.params).build_image }} |
| 89 | + options: -u 1001:1001 |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v2 |
| 92 | + with: |
| 93 | + path: src |
| 94 | + - name: Setup Cache |
| 95 | + uses: actions/cache@v2 |
| 96 | + if: ${{ steps.parameters.build_github_cache }} |
| 97 | + id: cache |
| 98 | + with: |
| 99 | + path: ${{ fromJSON(needs.configure.outputs.params).build_cache_root }}/build_cache_${{ fromJSON(needs.configure.outputs.params).build_cache_suffix }} |
| 100 | + key: sycl-build-${{ fromJSON(needs.configure.outputs.params).build_cache_suffix }}-${{ github.sha }} |
| 101 | + restore-keys: | |
| 102 | + sycl-build-${{ fromJSON(needs.configure.outputs.params).build_cache_suffix }}- |
| 103 | + - name: Configure |
| 104 | + env: |
| 105 | + CC: ${{ fromJSON(needs.configure.outputs.params).cc }} |
| 106 | + CXX: ${{ fromJSON(needs.configure.outputs.params).cxx }} |
| 107 | + CACHE_ROOT: ${{ fromJSON(needs.configure.outputs.params).build_cache_root }} |
| 108 | + CACHE_SUFFIX: ${{ fromJSON(needs.configure.outputs.params).build_cache_suffix }} |
| 109 | + CACHE_SIZE: ${{ fromJSON(needs.configure.outputs.params).build_cache_size }} |
| 110 | + ARGS: ${{ fromJSON(needs.configure.outputs.params).build_configure_extra_args }} |
| 111 | + run: | |
| 112 | + mkdir -p $CACHE_ROOT/build_cache_$CACHE_SUFFIX |
| 113 | + mkdir -p $GITHUB_WORKSPACE/build |
| 114 | + cd $GITHUB_WORKSPACE/build |
| 115 | + python3 $GITHUB_WORKSPACE/src/buildbot/configure.py -w $GITHUB_WORKSPACE \ |
| 116 | + -s $GITHUB_WORKSPACE/src -o $GITHUB_WORKSPACE/build -t Release \ |
| 117 | + --ci-defaults $ARGS --cmake-opt="-DLLVM_CCACHE_BUILD=ON" \ |
| 118 | + --cmake-opt="-DLLVM_CCACHE_DIR=$CACHE_ROOT/build_cache_$CACHE_SUFFIX" \ |
| 119 | + --cmake-opt="-DLLVM_CCACHE_MAXSIZE=$CACHE_SIZE" |
| 120 | + - name: Compile |
| 121 | + run: cmake --build $GITHUB_WORKSPACE/build |
| 122 | + # TODO allow to optionally disable in-tree checks |
| 123 | + - name: check-llvm |
| 124 | + if: always() |
| 125 | + run: | |
| 126 | + cmake --build $GITHUB_WORKSPACE/build --target check-llvm |
| 127 | + - name: check-clang |
| 128 | + if: always() |
| 129 | + run: | |
| 130 | + export XDG_CACHE_HOME=$GITHUB_WORKSPACE/os_cache |
| 131 | + cmake --build $GITHUB_WORKSPACE/build --target check-clang |
| 132 | + - name: check-sycl |
| 133 | + if: always() |
| 134 | + run: | |
| 135 | + cmake --build $GITHUB_WORKSPACE/build --target check-sycl |
| 136 | + - name: check-llvm-spirv |
| 137 | + if: always() |
| 138 | + run: | |
| 139 | + cmake --build $GITHUB_WORKSPACE/build --target check-llvm-spirv |
| 140 | + - name: check-xptifw |
| 141 | + if: always() |
| 142 | + run: | |
| 143 | + cmake --build $GITHUB_WORKSPACE/build --target check-xptifw |
| 144 | + - name: Install |
| 145 | + if: ${{ steps.parameters.build_upload_artifact }} |
| 146 | + run: cmake --build $GITHUB_WORKSPACE/build --target install |
| 147 | + - name: Pack |
| 148 | + if: ${{ steps.parameters.build_upload_artifact }} |
| 149 | + run: tar -czf llvm_sycl.tar.gz -C $GITHUB_WORKSPACE/build/install . |
| 150 | + - name: Upload artifacts |
| 151 | + uses: actions/upload-artifact@v1 |
| 152 | + if: ${{ steps.parameters.build_upload_artifact }} |
| 153 | + with: |
| 154 | + name: sycl_linux_${{ fromJSON(needs.configure.outputs.params).build_artifact_suffix }} |
| 155 | + path: llvm_sycl.tar.gz |
| 156 | + - name: Cleanup |
| 157 | + if: always() |
| 158 | + run: rm -rf $GITHUB_WORKSPACE/* |
| 159 | + |
0 commit comments