Advance Wayland and KDE package bring-up
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Based on okular/hooks/pre-commit, credits go to Albert Astals Cid
|
||||
|
||||
clang_format_major_version=@KDE_CLANG_FORMAT_MAJOR_VERSION@
|
||||
if [[ ${clang_format_major_version:-1} -ge 14 ]]; then
|
||||
readonly output=$(git clang-format --staged --extensions 'cpp,h,hpp,c' -v --diff)
|
||||
else
|
||||
readonly output=$(git clang-format --extensions 'cpp,h,hpp,c' -v --diff)
|
||||
fi
|
||||
|
||||
if [[ ! -f .clang-format ]]; then
|
||||
if [[ @HAS_CLANG_FORMAT_COMMAND_INCLUDED@ = TRUE ]]; then
|
||||
echo "ERROR: no .clang-format file found in repository root, abort format"
|
||||
echo " run cmake for this repository to generate it"
|
||||
else
|
||||
echo "ERROR: no .clang-format file found in repository root, abort format"
|
||||
echo "Make sure the KDEClangFormat CMake module is included, which will copy the KDE .clang-format file during the CMake configuration."
|
||||
echo "Alternatively you can manually copy a .clang-format file to the repository root directory."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$output" == *"no modified files to format"* ]]; then exit 0; fi
|
||||
if [[ "$output" == *"clang-format did not modify any files"* ]]; then exit 0; fi
|
||||
|
||||
echo "ERROR: You have unformatted changes, please format your files. You can do this using the following commands:"
|
||||
if [[ ${clang_format_major_version:-1} -ge 14 ]]; then
|
||||
echo " git clang-format --staged --extensions 'cpp,h,hpp,c' # format the changed parts"
|
||||
echo " git clang-format --staged --extensions 'cpp,h,hpp,c' --diff # preview the changes done by the formatter"
|
||||
else
|
||||
echo " git clang-format --extensions 'cpp,h,hpp,c' --force # format the changed parts"
|
||||
echo " git clang-format --extensions 'cpp,h,hpp,c' --diff # preview the changes done by the formatter"
|
||||
fi
|
||||
exit 1
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"if": {
|
||||
"type": "object"
|
||||
},
|
||||
"then": {
|
||||
"allOf": [@SCHEMA_INCLUDES@]
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# Version in sysadmin/ci-utilities should be single source of truth
|
||||
SPDX-FileCopyrightText: 2023 Alexander Lohnau <alexander.lohnau@gmx.de>
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/python3
|
||||
# Version in sysadmin/ci-utilities should be single source of truth
|
||||
# SPDX-FileCopyrightText: 2023 Alexander Lohnau <alexander.lohnau@gmx.de>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import yaml
|
||||
import sys
|
||||
|
||||
def get_changed_files():
|
||||
result = subprocess.run(['git', 'diff', '--name-only', 'HEAD'], capture_output=True, text=True)
|
||||
return [file for file in result.stdout.splitlines() if file.endswith('.json')]
|
||||
|
||||
def get_all_files():
|
||||
files = []
|
||||
for root, dirs, filenames in os.walk('.'):
|
||||
for filename in filenames:
|
||||
if filename.endswith('.json'):
|
||||
files.append(os.path.join(root, filename))
|
||||
return files
|
||||
|
||||
def filter_excluded_json_files(files):
|
||||
config_file = '.kde-ci.yml'
|
||||
# Check if the file exists
|
||||
if os.path.exists(config_file):
|
||||
with open(config_file, 'r') as file:
|
||||
config = yaml.safe_load(file)
|
||||
else:
|
||||
print(f'{config_file} does not exist in current directory')
|
||||
config = {}
|
||||
# Extract excluded files, used for tests that intentionally have broken files
|
||||
excluded_files = ['compile_commands.json', 'ci-utilities']
|
||||
if 'Options' in config and 'json-validate-ignore' in config['Options']:
|
||||
excluded_files += config['Options']['json-validate-ignore']
|
||||
|
||||
# Find JSON files
|
||||
filtered_files = []
|
||||
for file_path in files:
|
||||
if not any(excluded_file in file_path for excluded_file in excluded_files):
|
||||
filtered_files.append(file_path)
|
||||
return filtered_files
|
||||
|
||||
is_kde_ci = "KDE_CI" in os.environ
|
||||
if is_kde_ci:
|
||||
files = get_all_files()
|
||||
else:
|
||||
files = get_changed_files()
|
||||
files = filter_excluded_json_files(files)
|
||||
if files:
|
||||
files_option = ' '.join(files)
|
||||
if len(sys.argv) > 1:
|
||||
schemafile = sys.argv[1]
|
||||
else:
|
||||
schemafile = os.path.join(os.path.dirname(__file__), 'resources', 'kpluginmetadata.schema.json')
|
||||
if is_kde_ci: # Only report files on CI, for pre-commit hook, we'd like to avoid verbose output in terminal sessions
|
||||
print(f"Validating {files_option} with {schemafile}")
|
||||
result = subprocess.run(['check-jsonschema', *files, '--schemafile', schemafile])
|
||||
# Fail the pipeline if command failed
|
||||
if result.returncode != 0:
|
||||
exit(1)
|
||||
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
${PRE_COMMIT_SCRIPTS}
|
||||
Reference in New Issue
Block a user