-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e326a6
commit d7f8ed1
Showing
2 changed files
with
304 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,304 @@ | ||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
packages: write | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
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 }} | ||
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: Generate build matrix | ||
id: build-matrix | ||
run: ' | ||
echo ''matrix={ | ||
"os":[ | ||
{"name":"ubuntu", "vmaj":"20", "vmin":"04"}, | ||
{"name":"ubuntu", "vmaj":"22", "vmin":"04"}, | ||
{"name":"sles", "vmaj":"15", "vmin":"2"}, | ||
{"name":"sles", "vmaj":"15", "vmin":"3"}, | ||
{"name":"sles", "vmaj":"15", "vmin":"4"}, | ||
{"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"} | ||
] | ||
}'' | tee -a ${GITHUB_OUTPUT} | sed "s/matrix\=\(.*\)/\1/" | jq .' | ||
- name: Generate image build matrix | ||
id: image-matrix | ||
run: | | ||
echo 'matrix={"os":'$(echo '${{ steps.build-matrix.outputs.matrix }}' | jq -c .os)'}' | | ||
tee -a ${GITHUB_OUTPUT} | sed "s/matrix\=\(.*\)/\1/" | jq . | ||
image: | ||
runs-on: ${{ matrix.os.name == 'windows' && 'windows-latest' || 'ubuntu-latest' }} | ||
needs: [config] | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJSON(needs.config.outputs.image-matrix) }} | ||
env: | ||
OS_STRING: >- | ||
${{ 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 '${{ inputs.registry-user }}' \ | ||
--password-stdin \ | ||
ghcr.io | ||
- name: Setup buildkit builder | ||
if: env.DOCKER_BUILDKIT == '1' | ||
id: buildx-builder | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Get Dockerfile checksum | ||
id: checksum | ||
run: echo checksum=${{ hashFiles(format('.github/docker/{0}.Dockerfile', matrix.os.name)) }} >> ${GITHUB_OUTPUT} | ||
- name: Cache saved image | ||
id: cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./${{ env.OS_STRING }}.* | ||
key: ${{ steps.checksum.outputs.checksum }} | ||
- name: Build image | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
docker info | ||
docker \ | ||
${{ env.DOCKER_BUILDKIT == '0' && 'build' || 'buildx build' }} \ | ||
${{ 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 | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: docker save ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }} -o ./${{ env.OS_STRING }}.tar | ||
- name: Save image ID | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
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 }}.* | ||
|
||
|
||
# Use https://lvc.github.io/abi-compliance-checker/ to compare builds | ||
# of pull requests against master. Compares checkouts of github.base_ref and | ||
# github.head_ref. | ||
check-abi: | ||
needs: [config] | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request' | ||
steps: | ||
- name: Checkout base | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.base_ref }} | ||
clean: true | ||
path: base | ||
- name: Checkout head | ||
uses: actions/checkout@v3 | ||
with: | ||
clean: true | ||
path: head | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Build debug base | ||
run: | | ||
mkdir base/build | ||
cd base/build | ||
cmake -DCMAKE_BUILD_TYPE=Debug .. | ||
make -j$(nproc) | ||
- name: Build debug head | ||
run: | | ||
mkdir head/build | ||
cd head/build | ||
cmake -DCMAKE_BUILD_TYPE=Debug .. | ||
make -j$(nproc) | ||
- name: Download and setup abi-dumper | ||
run: | | ||
wget https://github.com/lvc/abi-dumper/archive/refs/tags/1.2.tar.gz -O abi-dumper.tar.gz | ||
tar -xzf abi-dumper.tar.gz | ||
cp abi-dumper-*/abi-dumper.pl . | ||
chmod +x abi-dumper.pl | ||
- name: Generate dump for base | ||
run: | | ||
./abi-dumper.pl \ | ||
./base/build/lib/libze_loader.so \ | ||
-lver $(cat ./base/build/VERSION) \ | ||
-public-headers ./base/include \ | ||
-o ./base.dump | ||
EOF | ||
- name: Generate dump for head | ||
run: | | ||
./abi-dumper.pl \ | ||
./head/build/lib/libze_loader.so \ | ||
-lver $(cat ./head/build/VERSION) \ | ||
-public-headers ./head/include \ | ||
-o ./head.dump | ||
- name: Download and setup abi-compliance-checker | ||
run: | | ||
wget https://github.com/lvc/abi-compliance-checker/tarball/master -O abi-compliance-checker.tar.gz | ||
tar -xzf abi-compliance-checker.tar.gz | ||
chmod +x lvc-abi-compliance-checker-*/abi-compliance-checker.pl | ||
- name: Compare dumps | ||
run: | | ||
lvc-abi-compliance-checker-*/abi-compliance-checker.pl \ | ||
-l libze_loader \ | ||
-old base.dump \ | ||
-new head.dump \ | ||
-report-path report.html | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: abi-report | ||
path: report.html | ||
|
||
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: | ||
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} <<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: Download image | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ steps.const.outputs.os-string }} | ||
- name: Load image | ||
run: docker load -i ./${{ env.OS_STRING }}.tar | ||
- name: Get image ID | ||
id: image-id | ||
run: echo "id=$(cat ./${{ env.OS_STRING }}.id)" >> ${GITHUB_OUTPUT} | ||
- name: Build | ||
id: build | ||
run: | | ||
mkdir build | ||
docker run \ | ||
--rm \ | ||
--interactive \ | ||
-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 \ | ||
${{ steps.image-id.outputs.id }} \ | ||
bash -e -x <<-EOF | ||
cmake \ | ||
${{ matrix.os.name != 'windows' && ' \ | ||
-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 }} ${{ matrix.os.name == 'windows' && '--config Release' || '' }} | ||
ccache --show-stats | ||
EOF |
This file was deleted.
Oops, something went wrong.