Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add basic github workflows #120

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2023-2024 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 1
141 changes: 141 additions & 0 deletions .github/workflows/cdl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Copyright (c) 2021-2024 Valve Corporation
# Copyright (c) 2021-2024 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: CDL (Build/Tests)

# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
# github.head_ref is only defined on pull_request
# Fallback to the run ID, which is guaranteed to be both unique and defined for the run.
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
push:
pull_request:
branches:
- main

env:
CMAKE_GENERATOR: Ninja

permissions:
contents: read

jobs:
code-format:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: clang-format version
run: clang-format --version
- name: Execute Source Code Format Checking Script
run: python3 scripts/check_code_format.py --fetch-main --target-refspec=FETCH_HEAD

# Ensure we can build on an older Ubuntu distro with an older version of CMake.
linux_back_compat:
needs: check_cdl
runs-on: ubuntu-22.04
name: "Ubuntu Backcompat"
steps:
- uses: actions/checkout@v4
- name: Test Minimum CMake Version
uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.17.2
- uses: hendrikmuhs/[email protected]
with:
key: linux_back_compat
- run: sudo apt-get -qq update && sudo apt-get install -y libwayland-dev xorg-dev
- run: cmake -S . -B build/ -D UPDATE_DEPS=ON -D CMAKE_BUILD_TYPE=Debug
env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
# Linker warnings as errors
LDFLAGS: -Wl,--fatal-warnings
- run: cmake --build build
- run: cmake --install build --prefix /tmp

linux:
needs: check_cdl
runs-on: ubuntu-24.04
name: "linux (${{matrix.sanitize}} sanitizer, ${{matrix.config}})"
strategy:
fail-fast: false
matrix:
sanitize: [ none, address, thread ]
config: [debug, release]
steps:
- uses: actions/checkout@v4
- uses: lukka/get-cmake@latest
- uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.config }}-${{ matrix.sanitize }}
- run: sudo apt-get -qq update && sudo apt-get install -y libwayland-dev xorg-dev
# This is to combat a bug when using 6.6 linux kernels with thread/address sanitizer
# https://github.com/google/sanitizers/issues/1716
- run: sudo sysctl vm.mmap_rnd_bits=28
- run: python scripts/tests.py --build --config ${{ matrix.config }} --sanitize ${{ matrix.sanitize }}
env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
- name: Test
run: python scripts/tests.py --test

windows:
needs: check_cdl
runs-on: windows-2022
strategy:
matrix:
arch: [ amd64, amd64_x86 ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Cache known_good.json installations
id: cache-deps
uses: actions/cache@v4
with:
path: |
build-ci/external/glslang/build/install
build-ci/external/googletest/build/install
build-ci/external/yaml-cpp/build/install
build-ci/external/SPIRV-Headers/build/install
build-ci/external/Vulkan-Headers/build/install
build-ci/external/Vulkan-Utility-Libraries/build/install
key: windows-dependencies-${{ matrix.arch }}-${{ hashfiles('scripts/known_good.json') }}
- name: Build
run: python3 scripts/tests.py --build --config debug --cmake='-DUPDATE_DEPS_SKIP_EXISTING_INSTALL=ON'

check_cdl:
needs: code-format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: python3 -m pip install pyparsing
- run: scripts/update_deps.py --dir ext --no-build
- run: scripts/generate_source.py --verify ext/Vulkan-Headers/registry/ ext/SPIRV-Headers/include/spirv/unified1/
147 changes: 147 additions & 0 deletions scripts/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/usr/bin/env python3
# Copyright (c) 2020-2024 Valve Corporation
# Copyright (c) 2020-2024 LunarG, Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import subprocess
import sys
import os
import argparse
import common_ci

# Where all artifacts will ultimately be placed under
CI_BUILD_DIR = common_ci.RepoRelative('build-ci')
# Where all dependencies will be installed under
CI_EXTERNAL_DIR = f'{CI_BUILD_DIR}/external'

# Prepare the layer for testing
def BuildCDL(config, cmake_args, build_tests, sanitize):
print("Log CMake version")
cmake_ver_cmd = 'cmake --version'
common_ci.RunShellCmd(cmake_ver_cmd)

SRC_DIR = common_ci.PROJECT_SRC_DIR
BUILD_DIR = f'{CI_BUILD_DIR}/cdl'



print("Configure CDL")
cmake_cmd = f'cmake -S {SRC_DIR} -B {BUILD_DIR}'
cmake_cmd += f' -D CMAKE_BUILD_TYPE={config}'
cmake_cmd += f' -D BUILD_TESTS={build_tests}'
cmake_cmd += f' -D UPDATE_DEPS=ON -D UPDATE_DEPS_DIR={CI_EXTERNAL_DIR}'

if cmake_args:
cmake_cmd += f' {cmake_args}'


if sanitize == 'none':
cmake_cmd += ' -D BUILD_WERROR=ON'
else:
os.environ['CFLAGS'] = f'-fsanitize={sanitize}'
os.environ['CXXFLAGS'] = f'-fsanitize={sanitize}'
os.environ['LDFLAGS'] = f'-fsanitize={sanitize}'
cmake_cmd += ' -D BUILD_WERROR=OFF'
print('env', os.environ)
print('cmake_cmd', cmake_cmd)
common_ci.RunShellCmd(cmake_cmd)

print("Build CDL")
build_cmd = f'cmake --build {BUILD_DIR}'
common_ci.RunShellCmd(build_cmd)


#
# Module Entrypoint
def Build(args):
config = args.configuration
sanitize = args.sanitize

# Since this script uses Ninja to build Windows users need to be in a developer command prompt.
if common_ci.IsWindows():
# This environment variable is arbitrary. I just picked one set by the developer command prompt.
if "VSCMD_ARG_TGT_ARCH" not in os.environ:
print("This script must be invoked in a developer command prompt!")
sys.exit(1)

try:
BuildCDL(config = config, cmake_args = args.cmake, build_tests = "ON", sanitize = sanitize)

except subprocess.CalledProcessError as proc_error:
print('Command "%s" failed with return code %s' % (' '.join(proc_error.cmd), proc_error.returncode))
sys.exit(proc_error.returncode)
except Exception as unknown_error:
print('An unknown error occured: %s', unknown_error)
sys.exit(1)

sys.exit(0)

#
# Run the Layer Validation Tests
def RunTests(args):
print("Run Tests using Mock ICD")

lvt_env = dict(os.environ)
lvt_cmd = os.path.join(CI_BUILD_DIR, 'cdl', 'tests', 'cdl_tests')

common_ci.RunShellCmd(lvt_cmd, env=lvt_env)

def Test(args):
try:
RunTests(args)

except subprocess.CalledProcessError as proc_error:
print('Command "%s" failed with return code %s' % (' '.join(proc_error.cmd), proc_error.returncode))
sys.exit(proc_error.returncode)
except Exception as unknown_error:
print('An unknown error occured: %s', unknown_error)
sys.exit(1)

sys.exit(0)

if __name__ == '__main__':
configs = ('release', 'debug')
default_config = configs[0]

sanitize_opts = ('none', 'address', 'thread')

parser = argparse.ArgumentParser()
parser.add_argument(
'-c', '--config', dest='configuration',
metavar='CONFIG', action='store',
choices=configs, default=default_config,
help='Build target configuration. Can be one of: {0}'.format(
', '.join(configs)))
parser.add_argument(
'-s', '--sanitize', dest='sanitize',
metavar='SANITIZE', action='store',
choices=sanitize_opts, default='none',
help='-fsanitize setting. Can be one of: {0}'.format(', '.join(sanitize_opts)))
parser.add_argument(
'--cmake', dest='cmake',
metavar='CMAKE', type=str,
default='', help='Additional args to pass to cmake')
parser.add_argument(
'--build', dest='build',
action='store_true', help='Build the layers')
parser.add_argument(
'--test', dest='test',
action='store_true', help='Tests the layers')

args = parser.parse_args()

if (args.build):
Build(args)
if (args.test):
Test(args)
5 changes: 4 additions & 1 deletion tests/framework/error_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ VkBool32 ErrorMonitor::CheckForDesiredMsg(const char *const msg_string) {
return result;
}

ErrorMonitor::Severity ErrorMonitor::GetMessageFlags() const { return message_flags_; }
ErrorMonitor::Severity ErrorMonitor::GetMessageFlags() const {
auto guard = Lock();
return message_flags_;
}

bool ErrorMonitor::AnyDesiredMsgFound() const { return message_found_; }

Expand Down
2 changes: 2 additions & 0 deletions tests/icd/test_icd_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ void Queue::TrackCheckpoint(uintptr_t checkpoint, VkPipelineStageFlagBits stage)
}

void Queue::GetCheckpointData(uint32_t *count, VkCheckpointDataNV *checkpoints) {
auto guard = Lock();
if (!checkpoints) {
*count = uint32_t(checkpoints_.size());
return;
Expand All @@ -244,6 +245,7 @@ void Queue::GetCheckpointData(uint32_t *count, VkCheckpointDataNV *checkpoints)
}

void Queue::GetCheckpointData2(uint32_t *count, VkCheckpointData2NV *checkpoints) {
auto guard = Lock();
if (!checkpoints) {
*count = uint32_t(checkpoints_.size());
return;
Expand Down