|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: [ master ] |
| 4 | + pull_request: |
| 5 | + branches: [ master ] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: read-all |
| 9 | + |
| 10 | +defaults: |
| 11 | + run: |
| 12 | + shell: bash |
| 13 | + |
| 14 | +jobs: |
| 15 | + config: |
| 16 | + if: github.repository_owner == 'oneapi-src' |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + short-sha: ${{ steps.const.outputs.short-sha }} |
| 20 | + ref-slug: ${{ steps.const.outputs.ref-slug }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + clean: true |
| 25 | + ref: ${{ github.event.pull_request.head.sha }} |
| 26 | + - name: Set constants |
| 27 | + id: const |
| 28 | + run: | |
| 29 | + cat >> ${GITHUB_OUTPUT} <<EOF |
| 30 | + short-sha=$(git rev-parse --short=7 ${GITHUB_SHA}) |
| 31 | + ref-slug=$(echo ${{ github.ref_name }} | tr '/_' '-') |
| 32 | + EOF |
| 33 | +
|
| 34 | + build: |
| 35 | + # Notes on formatting: |
| 36 | + # |
| 37 | + # GitHub Actions expressions ${{ ... }} are used wherever possible so the |
| 38 | + # evaluation results are plainly visible in the web console. |
| 39 | + # |
| 40 | + # Note the mixed spaces and tabs in the heredocs, see the bash man page |
| 41 | + # entry for <<- in the Here Documents section. This allows generated code to |
| 42 | + # be indented for readability in the workflow output. |
| 43 | + if: github.repository_owner == 'oneapi-src' |
| 44 | + needs: [config] |
| 45 | + runs-on: ${{ matrix.os.name == 'windows' && 'windows-latest' || 'ubuntu-latest' }} |
| 46 | + strategy: |
| 47 | + fail-fast: false |
| 48 | + matrix: |
| 49 | + os: [ |
| 50 | + {name: ubuntu, vmaj: 20, vmin: '04'}, |
| 51 | + {name: ubuntu, vmaj: 22, vmin: '04'}, |
| 52 | + {name: ubuntu, vmaj: 24, vmin: '04'}, |
| 53 | + {name: ubuntu, vmaj: 24, vmin: '10'}, |
| 54 | + {name: sles, vmaj: 15, vmin: 2}, |
| 55 | + {name: sles, vmaj: 15, vmin: 3}, |
| 56 | + {name: sles, vmaj: 15, vmin: 4}, |
| 57 | + {name: rhel, vmaj: 8, vmin: 6}, |
| 58 | + {name: windows} |
| 59 | + ] |
| 60 | + target: [install, package] |
| 61 | + arch: [''] |
| 62 | + include: [ |
| 63 | + {os: {name: ubuntu, vmaj: 20, vmin: '04'}, target: install, arch: arm64}, |
| 64 | + {os: {name: ubuntu, vmaj: 20, vmin: '04'}, target: package, arch: arm64} |
| 65 | + ] |
| 66 | + env: |
| 67 | + MSYS_NO_PATHCONV: 1 |
| 68 | + MOUNT_TARGET: ${{ matrix.os.name == 'windows' && 'C:/project' || '/project' }} |
| 69 | + # -j breaks the Visual Studio configuration selection |
| 70 | + PARALLEL: ${{ ! (matrix.os.name == 'windows') && '-j' || '' }} |
| 71 | + ARCH_SUFFIX: ${{ matrix.arch != '' && format('_{0}', matrix.arch) || '' }} |
| 72 | + steps: |
| 73 | + - name: Set constants |
| 74 | + id: const |
| 75 | + env: |
| 76 | + OS_STRING: >- |
| 77 | + ${{ matrix.os.name == 'windows' && 'windows' || |
| 78 | + format('{0}-{1}.{2}', |
| 79 | + matrix.os.name, |
| 80 | + matrix.os.vmaj, |
| 81 | + matrix.os.vmin |
| 82 | + ) |
| 83 | + }} |
| 84 | + CCACHE_DIR: ${{ github.workspace }}/ccache |
| 85 | + run: | |
| 86 | + cat >> ${GITHUB_OUTPUT} <<EOF |
| 87 | + os-string=${OS_STRING} |
| 88 | + image-name=ghcr.io/${{ github.repository }}/${OS_STRING} |
| 89 | + ccache-dir=${CCACHE_DIR} |
| 90 | + EOF |
| 91 | + - uses: actions/checkout@v4 |
| 92 | + with: |
| 93 | + clean: true |
| 94 | + fetch-depth: 0 |
| 95 | + ref: ${{ github.event.pull_request.head.sha }} |
| 96 | + - name: Create Ccache directory |
| 97 | + run: mkdir -p '${{ steps.const.outputs.ccache-dir }}' |
| 98 | + - name: Ccache |
| 99 | + uses: actions/cache@v4 |
| 100 | + with: |
| 101 | + path: ${{ steps.const.outputs.ccache-dir }} |
| 102 | + key: ccache-${{ github.job }}-${{ steps.const.outputs.os-string }}${{ env.ARCH_SUFFIX }}-${{ matrix.target }}-${{ github.sha }} |
| 103 | + restore-keys: ccache-${{ github.job }}-${{ steps.const.outputs.os-string }}${{ env.ARCH_SUFFIX }}-${{ matrix.target }}- |
| 104 | + - name: Compute image name |
| 105 | + run: echo "DOCKER_IMAGE=localhost/${{ github.repository }}/${{ steps.const.outputs.os-string }}" >> ${GITHUB_ENV} |
| 106 | + - name: "Registry login: ghcr.io" |
| 107 | + run: | |
| 108 | + echo ${{ secrets.GITHUB_TOKEN }} | |
| 109 | + docker login -u sys-lzdev --password-stdin ghcr.io |
| 110 | + - name: Build image |
| 111 | + run: | |
| 112 | + docker info |
| 113 | + docker build \ |
| 114 | + ${{ runner.os == 'Windows' && ' \ |
| 115 | + --memory 16G ' || ' ' |
| 116 | + }}\ |
| 117 | + ${{ matrix.os.vmaj != '' && format(' \ |
| 118 | + --build-arg VMAJ={0} \ |
| 119 | + --build-arg VMIN={1} ', matrix.os.vmaj, matrix.os.vmin) || ' ' |
| 120 | + }}\ |
| 121 | + --pull \ |
| 122 | + --tag ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }} \ |
| 123 | + - < .github/docker/${{ matrix.os.name }}.Dockerfile |
| 124 | + - name: Build |
| 125 | + id: build |
| 126 | + run: | |
| 127 | + mkdir build |
| 128 | + docker run \ |
| 129 | + --rm \ |
| 130 | + --interactive \ |
| 131 | + -v '${{ github.workspace }}':${MOUNT_TARGET} \ |
| 132 | + -w ${MOUNT_TARGET}/build \ |
| 133 | + -e CCACHE_BASEDIR=${MOUNT_TARGET} \ |
| 134 | + -e CCACHE_DIR=${MOUNT_TARGET}/ccache \ |
| 135 | + -v '${{ steps.const.outputs.ccache-dir }}':${MOUNT_TARGET}/ccache \ |
| 136 | + ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }} \ |
| 137 | + bash -e -x <<-EOF |
| 138 | +
|
| 139 | + cmake \ |
| 140 | + ${{ matrix.os.name != 'windows' && ' \ |
| 141 | + -G Ninja ' || ' ' |
| 142 | + }}\ |
| 143 | + ${{ matrix.arch == 'arm64' && ' \ |
| 144 | + -D CMAKE_C_COMPILER=aarch64-linux-gnu-gcc \ |
| 145 | + -D CMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \ |
| 146 | + -D CMAKE_SYSTEM_PROCESSOR=aarch64 ' || ' ' |
| 147 | + }}\ |
| 148 | + -D CMAKE_C_COMPILER_LAUNCHER=ccache \ |
| 149 | + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ |
| 150 | + -D CMAKE_BUILD_TYPE=Release \ |
| 151 | + -D CMAKE_INSTALL_PREFIX=${{ matrix.target == 'install' && '../level-zero-install' || matrix.target == 'package' && '/usr' || '' }} \ |
| 152 | + -D CPACK_OUTPUT_FILE_PREFIX=${MOUNT_TARGET}/level-zero-package \ |
| 153 | + .. |
| 154 | + |
| 155 | + cmake --build . ${PARALLEL} --target ${{ matrix.target }} ${{ matrix.os.name == 'windows' && '--config Release' || '' }} |
| 156 | + |
| 157 | + ccache --show-stats |
| 158 | + |
| 159 | + EOF |
0 commit comments