Skip to content

Commit 222da8e

Browse files
committed
Add workflows for static builds
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent b53eff8 commit 222da8e

File tree

2 files changed

+208
-0
lines changed

2 files changed

+208
-0
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
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
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
push:
3+
branches: [ master ]
4+
pull_request:
5+
branches: [ master ]
6+
workflow_dispatch:
7+
8+
permissions: read-all
9+
10+
jobs:
11+
build-linux:
12+
if: github.repository_owner == 'oneapi-src'
13+
runs-on: [ubuntu-latest]
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: hendrikmuhs/ccache-action@v1
17+
- name: Build Loader on Latest Ubuntu
18+
run: |
19+
mkdir build
20+
cd build
21+
cmake \
22+
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
23+
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
24+
-D CMAKE_BUILD_TYPE=Release \
25+
-D BUILD_L0_LOADER_TESTS=1 \
26+
..
27+
make -j$(nproc)
28+
- env:
29+
ZE_ENABLE_LOADER_DEBUG_TRACE: '1'
30+
ZEL_LIBRARY_PATH: '${{ github.workspace }}/build/lib'
31+
working-directory: build
32+
run: ctest -V
33+
34+
build-windows:
35+
if: github.repository_owner == 'oneapi-src'
36+
runs-on: [windows-latest]
37+
steps:
38+
- uses: actions/checkout@v3
39+
- name: Build Loader on Latest Windows
40+
run: |
41+
mkdir build
42+
cd build
43+
cmake -D BUILD_L0_LOADER_TESTS=1 -D BUILD_STATIC=1 ..
44+
cmake --build . --config Release
45+
- env:
46+
ZE_ENABLE_LOADER_DEBUG_TRACE: '1'
47+
ZEL_LIBRARY_PATH: '${{ github.workspace }}/build/bin/Release'
48+
working-directory: build
49+
run: ctest -C Release -V

0 commit comments

Comments
 (0)