Use PROJECT_*_DIR instead of CMAKE_*_DIR to support subproject builds #1165
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| push: | |
| branches: [ master,release_branch* ] | |
| pull_request: | |
| branches: [ master,release_branch* ] | |
| workflow_dispatch: | |
| permissions: read-all | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| config: | |
| if: github.repository_owner == 'oneapi-src' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| short-sha: ${{ steps.const.outputs.short-sha }} | |
| ref-slug: ${{ steps.const.outputs.ref-slug }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| clean: true | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Set constants | |
| id: const | |
| run: | | |
| cat >> ${GITHUB_OUTPUT} <<EOF | |
| short-sha=$(git rev-parse --short=7 ${GITHUB_SHA}) | |
| ref-slug=$(echo ${{ github.ref_name }} | tr '/_' '-') | |
| EOF | |
| - name: "Registry login: ghcr.io" | |
| # Uses built-in github.token (replaces hardcoded sys-lzdev PAT) and | |
| # github.actor as the username (any non-empty string works with token auth). | |
| run: | | |
| echo ${{ github.token }} | | |
| docker login -u ${{ github.actor }} --password-stdin ghcr.io | |
| - name: List available base images | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| for distro in ubuntu sles rhel; do | |
| echo "=== ${distro} ===" | |
| # GitHub Packages API - lists all versions with their tags | |
| curl -s \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "https://api.github.com/orgs/oneapi-src/packages/container/level-zero-linux-compute%2F${distro}/versions?per_page=100" \ | |
| | python3 -c "import sys,json; d=json.load(sys.stdin); print('\n'.join(sorted(t for v in d for t in v.get('metadata',{}).get('container',{}).get('tags',[]))) or '(no tags found)') if isinstance(d,list) else print('API error:',d.get('message','unknown'))" 2>/dev/null || echo "(query failed)" | |
| done | |
| build: | |
| # Notes on formatting: | |
| # | |
| # GitHub Actions expressions ${{ ... }} are used wherever possible so the | |
| # evaluation results are plainly visible in the web console. | |
| # | |
| # Note the mixed spaces and tabs in the heredocs, see the bash man page | |
| # entry for <<- in the Here Documents section. This allows generated code to | |
| # be indented for readability in the workflow output. | |
| if: github.repository_owner == 'oneapi-src' | |
| needs: [config] | |
| runs-on: ${{ matrix.os.name == 'windows' && 'windows-latest' || 'ubuntu-latest' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ | |
| {name: ubuntu, vmaj: 20, vmin: '04'}, | |
| {name: ubuntu, vmaj: 22, vmin: '04'}, | |
| {name: ubuntu, vmaj: 24, vmin: '04'}, | |
| {name: sles, vmaj: 15, vmin: 4}, | |
| {name: sles, vmaj: 15, vmin: 6}, | |
| {name: rhel, vmaj: 8, vmin: 6}, | |
| {name: windows} | |
| ] | |
| target: [install, package] | |
| arch: [''] | |
| include: [ | |
| {os: {name: ubuntu, vmaj: 20, vmin: '04'}, target: install, arch: arm64}, | |
| {os: {name: ubuntu, vmaj: 20, vmin: '04'}, target: package, arch: arm64} | |
| ] | |
| env: | |
| MSYS_NO_PATHCONV: 1 | |
| MOUNT_TARGET: ${{ matrix.os.name == 'windows' && 'C:/project' || '/project' }} | |
| # Ninja handles parallelism internally; -j not needed for Windows | |
| PARALLEL: ${{ ! (matrix.os.name == 'windows') && '-j' || '' }} | |
| ARCH_SUFFIX: ${{ matrix.arch != '' && format('_{0}', matrix.arch) || '' }} | |
| steps: | |
| - name: Set constants | |
| id: const | |
| env: | |
| OS_STRING: >- | |
| ${{ matrix.os.name == 'windows' && 'windows' || | |
| format('{0}-{1}.{2}', | |
| matrix.os.name, | |
| matrix.os.vmaj, | |
| matrix.os.vmin | |
| ) | |
| }} | |
| CCACHE_DIR: ${{ github.workspace }}/ccache | |
| run: | | |
| cat >> ${GITHUB_OUTPUT} <<EOF | |
| os-string=${OS_STRING} | |
| image-name=ghcr.io/${{ github.repository }}/${OS_STRING} | |
| ccache-dir=${CCACHE_DIR} | |
| EOF | |
| - uses: actions/checkout@v4 | |
| with: | |
| clean: true | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Create Ccache directory | |
| run: mkdir -p '${{ steps.const.outputs.ccache-dir }}' | |
| - name: Ccache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.const.outputs.ccache-dir }} | |
| key: ccache-${{ github.job }}-${{ steps.const.outputs.os-string }}${{ env.ARCH_SUFFIX }}-${{ matrix.target }}-${{ github.sha }} | |
| restore-keys: ccache-${{ github.job }}-${{ steps.const.outputs.os-string }}${{ env.ARCH_SUFFIX }}-${{ matrix.target }}- | |
| - name: Compute image name | |
| run: echo "DOCKER_IMAGE=localhost/${{ github.repository }}/${{ steps.const.outputs.os-string }}" >> ${GITHUB_ENV} | |
| - name: "Registry login: ghcr.io" | |
| if: matrix.os.name != 'windows' | |
| # Uses built-in github.token (replaces hardcoded sys-lzdev PAT) and | |
| # github.actor as the username (any non-empty string works with token auth). | |
| run: | | |
| echo ${{ github.token }} | | |
| docker login -u ${{ github.actor }} --password-stdin ghcr.io | |
| - name: Verify Docker configuration | |
| if: matrix.os.name != 'windows' | |
| run: | | |
| docker version | |
| docker info | |
| - name: Build image | |
| if: matrix.os.name != 'windows' | |
| run: | | |
| docker info | |
| docker build \ | |
| --platform linux/amd64 \ | |
| ${{ matrix.os.vmaj != '' && format(' \ | |
| --build-arg VMAJ={0} \ | |
| --build-arg VMIN={1} ', matrix.os.vmaj, matrix.os.vmin) || ' ' | |
| }}\ | |
| --pull \ | |
| --tag ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }} \ | |
| - < .github/docker/${{ matrix.os.name }}.Dockerfile | |
| - name: Setup Windows build environment | |
| if: matrix.os.name == 'windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Build (Windows) | |
| if: matrix.os.name == 'windows' | |
| run: | | |
| $ws = "${{ github.workspace }}".Replace('\', '/') | |
| mkdir build | |
| cd build | |
| cmake ` | |
| -G "Ninja" ` | |
| -D CMAKE_BUILD_TYPE=Release ` | |
| -D CMAKE_INSTALL_PREFIX="${{ matrix.target == 'install' && '../level-zero-install' || matrix.target == 'package' && 'C:/Program Files' || '' }}" ` | |
| -D CPACK_OUTPUT_FILE_PREFIX="$ws/level-zero-package" ` | |
| .. | |
| cmake --build . --target ${{ matrix.target }} | |
| shell: powershell | |
| - name: Build (Linux) | |
| if: matrix.os.name != 'windows' | |
| id: build | |
| run: | | |
| mkdir build | |
| # Container-based build for Linux | |
| docker run \ | |
| --rm \ | |
| --interactive \ | |
| --platform linux/amd64 \ | |
| -v '${{ github.workspace }}':${MOUNT_TARGET} \ | |
| -w ${MOUNT_TARGET}/build \ | |
| -e CCACHE_BASEDIR=${MOUNT_TARGET} \ | |
| -e CCACHE_DIR=${MOUNT_TARGET}/ccache \ | |
| -v '${{ steps.const.outputs.ccache-dir }}':${MOUNT_TARGET}/ccache \ | |
| ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }} \ | |
| bash -e -x <<-EOF | |
| cmake \ | |
| -G Ninja \ | |
| ${{ matrix.arch == 'arm64' && ' \ | |
| -D CMAKE_C_COMPILER=aarch64-linux-gnu-gcc \ | |
| -D CMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \ | |
| -D CMAKE_SYSTEM_PROCESSOR=aarch64 ' || ' ' | |
| }}\ | |
| -D CMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
| -D CMAKE_BUILD_TYPE=Release \ | |
| -D CMAKE_INSTALL_PREFIX=${{ matrix.target == 'install' && '../level-zero-install' || matrix.target == 'package' && '/usr' || '' }} \ | |
| -D CPACK_OUTPUT_FILE_PREFIX=${MOUNT_TARGET}/level-zero-package \ | |
| .. | |
| cmake --build . ${PARALLEL} --target ${{ matrix.target }} | |
| ccache --show-stats | |
| EOF | |
| - name: Test package install/uninstall (Linux) | |
| if: matrix.os.name != 'windows' && matrix.target == 'package' && matrix.arch == '' | |
| run: | | |
| docker run \ | |
| --rm \ | |
| --interactive \ | |
| --platform linux/amd64 \ | |
| -v '${{ github.workspace }}':${MOUNT_TARGET} \ | |
| -w ${MOUNT_TARGET} \ | |
| ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }} \ | |
| bash -e -x <<-EOF | |
| if [[ '${{ matrix.os.name }}' == 'ubuntu' ]]; then | |
| echo "=== Package contents ===" | |
| for pkg in ${MOUNT_TARGET}/level-zero-package/*.deb; do | |
| echo "--- \$pkg ---" | |
| dpkg -c "\$pkg" | |
| done | |
| echo "=== Installing libze .deb packages ===" | |
| dpkg -i ${MOUNT_TARGET}/level-zero-package/libze1_*.deb \ | |
| ${MOUNT_TARGET}/level-zero-package/libze-dev_*.deb | |
| echo "=== Installed libze packages ===" | |
| dpkg -l 'libze*' | |
| echo "=== Uninstalling libze packages ===" | |
| dpkg -r libze-dev libze1 | |
| elif [[ '${{ matrix.os.name }}' == 'sles' ]]; then | |
| echo "=== Package contents ===" | |
| for pkg in ${MOUNT_TARGET}/level-zero-package/*.rpm; do | |
| echo "--- \$pkg ---" | |
| rpm -qpl "\$pkg" | |
| done | |
| echo "=== Verifying filesystem package is installed (checks devel dir conflict) ===" | |
| rpm -q filesystem | |
| echo "=== Installing .rpm packages ===" | |
| rpm -ivh ${MOUNT_TARGET}/level-zero-package/*.rpm | |
| echo "=== Installed level-zero packages ===" | |
| rpm -qa 'level-zero*' | |
| echo "=== Uninstalling packages ===" | |
| rpm -e \$(rpm -qa 'level-zero*') | |
| elif [[ '${{ matrix.os.name }}' == 'rhel' ]]; then | |
| echo "=== Package contents ===" | |
| for pkg in ${MOUNT_TARGET}/level-zero-package/*.rpm; do | |
| echo "--- \$pkg ---" | |
| rpm -qpl "\$pkg" | |
| done | |
| echo "=== Installing .rpm packages ===" | |
| rpm -ivh ${MOUNT_TARGET}/level-zero-package/*.rpm | |
| echo "=== Installed level-zero packages ===" | |
| rpm -qa 'level-zero*' | |
| echo "=== Uninstalling packages ===" | |
| rpm -e \$(rpm -qa 'level-zero*') | |
| fi | |
| EOF |