From 37fde25fe5eeb6a8af65229d3d19a2f823ec0efa Mon Sep 17 00:00:00 2001 From: Lisanna Dettwyler Date: Thu, 9 May 2024 18:44:48 +0000 Subject: [PATCH] Add new workflows build-multi.yml: Build environment specified with Dockerfiles build-quick.yml: Build natively on GitHub runners (renamed from ci-external.yml) --- .github/docker/windows.Dockerfile | 2 +- .github/workflows/build-multi.yml | 268 ++++++++++++++++++ .../{ci-external.yml => build-quick.yml} | 0 3 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-multi.yml rename .github/workflows/{ci-external.yml => build-quick.yml} (100%) diff --git a/.github/docker/windows.Dockerfile b/.github/docker/windows.Dockerfile index f1c2b4d3..bc62871f 100644 --- a/.github/docker/windows.Dockerfile +++ b/.github/docker/windows.Dockerfile @@ -1,6 +1,6 @@ # escape=` -ARG BASE_IMAGE=mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 +ARG BASE_IMAGE=mcr.microsoft.com/dotnet/framework/runtime:4.8 FROM ${BASE_IMAGE} SHELL ["powershell"] diff --git a/.github/workflows/build-multi.yml b/.github/workflows/build-multi.yml new file mode 100644 index 00000000..77bde826 --- /dev/null +++ b/.github/workflows/build-multi.yml @@ -0,0 +1,268 @@ +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + +permissions: read-all + +defaults: + run: + shell: bash + +env: + TEST_GROUPS_ARRAY: '["perf", "conformance", "negative", "layer", "stress"]' + +jobs: + config: + runs-on: ubuntu-latest + outputs: + short-sha: ${{ steps.const.outputs.short-sha }} + ref-slug: ${{ steps.const.outputs.ref-slug }} + build-matrix: ${{ steps.build-matrix.outputs.matrix }} + image-matrix: ${{ steps.image-matrix.outputs.matrix }} + groups: ${{ steps.const.outputs.groups }} + steps: + - uses: actions/checkout@v4 + with: + clean: true + ref: ${{ github.event.pull_request.head.sha }} + - name: Set constants + id: const + run: | + cat >> ${GITHUB_OUTPUT} <- + ${{ matrix.os.name == 'windows' && 'windows' || + format('{0}-{1}.{2}', + matrix.os.name, + matrix.os.vmaj, + matrix.os.vmin + ) + }} + DOCKER_BUILDKIT: ${{ matrix.os.name == 'windows' && '0' || '1' }} + steps: + - name: Compute image name + run: echo "DOCKER_IMAGE=localhost/${{ github.repository }}/${OS_STRING}" >> ${GITHUB_ENV} + - uses: actions/checkout@v4 + with: + clean: true + submodules: true + - name: "Registry login: ghcr.io" + run: | + echo ${{ secrets.GITHUB_TOKEN }} | + docker login -u sys-lzdev --password-stdin ghcr.io + - name: Setup buildkit builder + if: env.DOCKER_BUILDKIT == '1' + id: buildx-builder + uses: docker/setup-buildx-action@v3 + - name: Build image + run: | + docker info + docker \ + ${{ env.DOCKER_BUILDKIT == '0' && 'build' || 'buildx build --load' }} \ + ${{ runner.os == 'Windows' && ' \ + --memory 16G ' || ' ' + }}\ + ${{ 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: Save image + run: docker save ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }} -o ./${{ env.OS_STRING }}.tar + - name: Save image ID + run: echo "$(docker images --format '{{.ID}}' ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }})" > ./${{ env.OS_STRING }}.id + - name: Upload image + uses: actions/upload-artifact@v4 + with: + name: ${{ env.OS_STRING }} + path: ./${{ env.OS_STRING }}.* + + 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. + needs: [config, image] + runs-on: ${{ matrix.os.name == 'windows' && 'windows-latest' || 'ubuntu-latest' }} + # Always run build even if the image step failed, except if the job was cancelled + if: >- + always() && + ! cancelled() && + needs.config.result == 'success' + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.config.outputs.build-matrix) }} + env: + TEST_GROUPS: ${{ join(fromJSON(needs.config.outputs.groups), ' ') }} + MSYS_NO_PATHCONV: 1 + MOUNT_TARGET: ${{ matrix.os.name == 'windows' && 'C:/project' || '/project' }} + # -j breaks the Visual Studio configuration selection + 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} <> ${GITHUB_OUTPUT} + - name: Build loader + run: | + mkdir level-zero/build + docker run \ + --rm \ + --interactive \ + -v '${{ github.workspace }}':${MOUNT_TARGET} \ + -w ${MOUNT_TARGET}/level-zero/build \ + -e CCACHE_BASEDIR=${MOUNT_TARGET} \ + -e CCACHE_DIR=${MOUNT_TARGET}/ccache \ + -v '${{ steps.const.outputs.ccache-dir }}':${MOUNT_TARGET}/ccache \ + ${{ steps.image-id.outputs.id }} \ + bash -e -x <<-EOF + ccache --zero-stats + 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 \ + ${{ runner.os == 'Windows' && ' \ + -D USE_Z7=TRUE' + }} \ + -D CMAKE_INSTALL_PREFIX=${MOUNT_TARGET}/level-zero/install \ + .. + ninja -j $(nproc) install + ccache --show-stats + EOF + - name: Build + id: build + run: | + mkdir build + ${{ matrix.coverity-build && 'mkdir cov' || '' }} + docker run \ + --rm \ + --interactive \ + -v '${{ github.workspace }}':${MOUNT_TARGET} \ + -w ${MOUNT_TARGET}/build \ + -e CCACHE_BASEDIR=${MOUNT_TARGET} \ + -e CCACHE_DIR=${MOUNT_TARGET}/ccache \ + -e MSYS_NO_PATHCONV=1 \ + -v '${{ steps.const.outputs.ccache-dir }}':${MOUNT_TARGET}/ccache \ + ${{ matrix.coverity-build && format(' \ + -v {0}:{0} ', steps.coverity.outputs.install) || ' ' + }}\ + ${{ steps.image-id.outputs.id }} \ + bash -e -x <<-EOF + + ccache --zero-stats + + for group in ${TEST_GROUPS}; do + 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 \ + ${{ runner.os == 'Windows' && ' \ + -D USE_Z7=TRUE' || ' ' + }}\ + -D GROUP="/\${group}_tests" \ + -D CMAKE_PREFIX_PATH=${MOUNT_TARGET}/level-zero/install \ + -D REQUIRE_OPENCL_BENCHMARKS=yes \ + -D CMAKE_INSTALL_PREFIX=${MOUNT_TARGET}/level-zero-tests-\${group} \ + .. + + cmake --build . -j --target install + done + + ccache --show-stats + + EOF diff --git a/.github/workflows/ci-external.yml b/.github/workflows/build-quick.yml similarity index 100% rename from .github/workflows/ci-external.yml rename to .github/workflows/build-quick.yml