Skip to content

Commit 94e7eeb

Browse files
committed
Bump infra beman-submodule to latest
This applies the separation of beman-tidy out of the infra repository and should fix any failing beman-submodule consistency checks in CI. Also update pre-commit and apply changes for compatibility with latest infra.
1 parent bee0506 commit 94e7eeb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+303
-2650
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v5.0.0
5+
rev: v6.0.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
@@ -13,14 +13,14 @@ repos:
1313
# This brings in a portable version of clang-format.
1414
# See also: https://github.com/ssciwr/clang-format-wheel
1515
- repo: https://github.com/pre-commit/mirrors-clang-format
16-
rev: v20.1.7
16+
rev: v21.1.2
1717
hooks:
1818
- id: clang-format
1919
types_or: [c++, c]
2020

2121
# CMake linting and formatting
2222
- repo: https://github.com/BlankSpruce/gersemi
23-
rev: 0.15.1
23+
rev: 0.22.3
2424
hooks:
2525
- id: gersemi
2626
name: CMake linting
@@ -34,7 +34,7 @@ repos:
3434
# - id: markdownlint
3535

3636
- repo: https://github.com/codespell-project/codespell
37-
rev: v2.3.0
37+
rev: v2.4.1
3838
hooks:
3939
- id: codespell
4040

infra/.beman_submodule

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[beman_submodule]
22
remote=https://github.com/bemanproject/infra.git
3-
commit_hash=78de7eb4ff54bd12c9abb790107edc86bcda07d8
3+
commit_hash=bb58b2a1cc894d58a55bf745be78f5d27029e245

infra/.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @ednolan @neatudarius @rishyak @wusatosi
1+
* @ednolan @neatudarius @rishyak @wusatosi @JeffGarland

infra/.github/workflows/beman-tidy.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
3+
name: 'Beman issue creation workflow'
4+
on:
5+
workflow_call:
6+
workflow_dispatch:
7+
jobs:
8+
create-issue:
9+
runs-on: ubuntu-latest
10+
steps:
11+
# See https://github.com/cli/cli/issues/5075
12+
- uses: actions/checkout@v4
13+
- name: Create issue
14+
run: |
15+
issue_num=$(gh issue list -s open -S "[SCHEDULED-BUILD] infra repo CI job failure" -L 1 --json number | jq 'if length == 0 then -1 else .[0].number end')
16+
body="**CI job failure Report**
17+
- **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z')
18+
- **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
19+
- **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
20+
The scheduled job triggered by cron has failed.
21+
Please investigate the logs and recent changes associated with this commit or rerun the workflow if you believe this is an error."
22+
if [[ $issue_num -eq -1 ]]; then
23+
gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] infra repo CI job failure" --body "$body" --assignee ${{ github.actor }}
24+
else
25+
gh issue comment --repo ${{ github.repository }} $issue_num --body "$body"
26+
fi
27+
env:
28+
GH_TOKEN: ${{ github.token }}

infra/.pre-commit-config.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
77
- id: check-yaml
88
- id: check-added-large-files
99

1010
- repo: https://github.com/codespell-project/codespell
11-
rev: v2.3.0
11+
rev: v2.4.1
1212
hooks:
1313
- id: codespell
1414

1515
# CMake linting and formatting
1616
- repo: https://github.com/BlankSpruce/gersemi
17-
rev: 0.15.1
17+
rev: 0.22.3
1818
hooks:
1919
- id: gersemi
2020
name: CMake linting
21+
exclude: ^.*/tests/.*/data/ # Exclude test data directories
2122

2223
# Python linting and formatting
2324
# config file: ruff.toml (not currently present but add if needed)
2425
# https://docs.astral.sh/ruff/configuration/
2526
- repo: https://github.com/astral-sh/ruff-pre-commit
26-
rev: v0.12.1
27+
rev: v0.13.2
2728
hooks:
2829
- id: ruff-check
2930
files: ^tools/beman-tidy/

infra/LICENSE

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/
@@ -216,15 +217,3 @@ conflicts with the conditions of the GPLv2, you may retroactively and
216217
prospectively choose to deem waived or otherwise exclude such Section(s) of
217218
the License, but only in their entirety and only with respect to the Combined
218219
Software.
219-
220-
==============================================================================
221-
Software from third parties included in the Beman Project:
222-
==============================================================================
223-
The Beman Project contains third party software which is under different license
224-
terms. All such code will be identified clearly using at least one of two
225-
mechanisms:
226-
1) It will be in a separate directory tree with its own `LICENSE.txt` or
227-
`LICENSE` file at the top containing the specific license and restrictions
228-
which apply to that software, or
229-
2) It will contain specific license and restriction terms at the top of every
230-
file.

infra/README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,54 @@
22

33
<!-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -->
44

5-
This repository contains the infrastructure for The Beman Project. This is NOT a library repository, so it does not
6-
respect the usual structure of a Beman library repository nor The Beman Standard!
5+
This repository contains the infrastructure for The Beman Project. This is NOT a library repository,
6+
so it does not respect the usual structure of a Beman library repository nor The Beman Standard!
77

88
## Description
99

10+
* `cmake/`: CMake modules and toolchain files used by Beman libraries.
1011
* `containers/`: Containers used for CI builds and tests in the Beman org.
1112
* `tools/`: Tools used to manage the infrastructure and the codebase (e.g., linting, formatting, etc.).
13+
14+
## Usage
15+
16+
This repository is intended to be used as a beman-submodule in other Beman repositories. See
17+
[the Beman Submodule documentation](./tools/beman-submodule/README.md) for details.
18+
19+
20+
### CMake Modules
21+
22+
23+
#### `beman_install_library`
24+
25+
The CMake modules in this repository are intended to be used by Beman libraries. Use the
26+
`beman_add_install_library_config()` function to install your library, along with header
27+
files, any metadata files, and a CMake config file for `find_package()` support.
28+
29+
```cmake
30+
add_library(beman.something)
31+
add_library(beman::something ALIAS beman.something)
32+
33+
# ... configure your target as needed ...
34+
35+
find_package(beman-install-library REQUIRED)
36+
beman_install_library(beman.something)
37+
```
38+
39+
Note that the target must be created before calling `beman_install_library()`. The module
40+
also assumes that the target is named using the `beman.something` convention, and it
41+
uses that assumption to derive the names to match other Beman standards and conventions.
42+
If your target does not follow that convention, raise an issue or pull request to add
43+
more configurability to the module.
44+
45+
The module will configure the target to install:
46+
47+
* The library target itself
48+
* Any public headers associated with the target
49+
* CMake files for `find_package(beman.something)` support
50+
51+
Some options for the project and target will also be supported:
52+
53+
* `BEMAN_INSTALL_CONFIG_FILE_PACKAGES` - a list of package names (e.g., `beman.something`) for which to install the config file
54+
(default: all packages)
55+
* `<BEMAN_NAME>_INSTALL_CONFIG_FILE_PACKAGE` - a per-project option to enable/disable config file installation (default: `ON` if the project is top-level, `OFF` otherwise). For instance for `beman.something`, the option would be `BEMAN_SOMETHING_INSTALL_CONFIG_FILE_PACKAGE`.

infra/cmake/appleclang-toolchain.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}")
3939

4040
set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}")
4141
set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}")
42+
43+
# Add this dir to the module path so that `find_package(beman-install-library)` works
44+
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}")
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
include_guard(GLOBAL)
3+
4+
# This file defines the function `beman_install_library` which is used to
5+
# install a library target and its headers, along with optional CMake
6+
# configuration files.
7+
#
8+
# The function is designed to be reusable across different Beman libraries.
9+
10+
function(beman_install_library name)
11+
# Usage
12+
# -----
13+
#
14+
# beman_install_library(NAME)
15+
#
16+
# Brief
17+
# -----
18+
#
19+
# This function installs the specified library target and its headers.
20+
# It also handles the installation of the CMake configuration files if needed.
21+
#
22+
# CMake variables
23+
# ---------------
24+
#
25+
# Note that configuration of the installation is generally controlled by CMake
26+
# cache variables so that they can be controlled by the user or tool running the
27+
# `cmake` command. Neither `CMakeLists.txt` nor `*.cmake` files should set these
28+
# variables directly.
29+
#
30+
# - BEMAN_INSTALL_CONFIG_FILE_PACKAGES:
31+
# List of packages that require config file installation.
32+
# If the package name is in this list, it will install the config file.
33+
#
34+
# - <PREFIX>_INSTALL_CONFIG_FILE_PACKAGE:
35+
# Boolean to control config file installation for the specific library.
36+
# The prefix `<PREFIX>` is the uppercased name of the library with dots
37+
# replaced by underscores.
38+
#
39+
if(NOT TARGET "${name}")
40+
message(FATAL_ERROR "Target '${name}' does not exist.")
41+
endif()
42+
43+
if(NOT ARGN STREQUAL "")
44+
message(
45+
FATAL_ERROR
46+
"beman_install_library does not accept extra arguments: ${ARGN}"
47+
)
48+
endif()
49+
50+
# Given foo.bar, the component name is bar
51+
string(REPLACE "." ";" name_parts "${name}")
52+
# fail if the name doesn't look like foo.bar
53+
list(LENGTH name_parts name_parts_length)
54+
if(NOT name_parts_length EQUAL 2)
55+
message(
56+
FATAL_ERROR
57+
"beman_install_library expects a name of the form 'beman.<name>', got '${name}'"
58+
)
59+
endif()
60+
61+
set(target_name "${name}")
62+
set(install_component_name "${name}")
63+
set(export_name "${name}")
64+
set(package_name "${name}")
65+
list(GET name_parts -1 component_name)
66+
67+
install(
68+
TARGETS "${target_name}"
69+
COMPONENT "${install_component_name}"
70+
EXPORT "${export_name}"
71+
FILE_SET HEADERS
72+
)
73+
74+
set_target_properties(
75+
"${target_name}"
76+
PROPERTIES EXPORT_NAME "${component_name}"
77+
)
78+
79+
include(GNUInstallDirs)
80+
81+
# Determine the prefix for project-specific variables
82+
string(TOUPPER "${name}" project_prefix)
83+
string(REPLACE "." "_" project_prefix "${project_prefix}")
84+
85+
option(
86+
${project_prefix}_INSTALL_CONFIG_FILE_PACKAGE
87+
"Enable building examples. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }."
88+
${PROJECT_IS_TOP_LEVEL}
89+
)
90+
91+
# By default, install the config package
92+
set(install_config_package ON)
93+
94+
# Turn OFF installation of config package by default if,
95+
# in order of precedence:
96+
# 1. The specific package variable is set to OFF
97+
# 2. The package name is not in the list of packages to install config files
98+
if(DEFINED BEMAN_INSTALL_CONFIG_FILE_PACKAGES)
99+
if(
100+
NOT "${install_component_name}"
101+
IN_LIST
102+
BEMAN_INSTALL_CONFIG_FILE_PACKAGES
103+
)
104+
set(install_config_package OFF)
105+
endif()
106+
endif()
107+
if(DEFINED ${project_prefix}_INSTALL_CONFIG_FILE_PACKAGE)
108+
set(install_config_package
109+
${${project_prefix}_INSTALL_CONFIG_FILE_PACKAGE}
110+
)
111+
endif()
112+
113+
if(install_config_package)
114+
message(
115+
DEBUG
116+
"beman-install-library: Installing a config package for '${name}'"
117+
)
118+
119+
include(CMakePackageConfigHelpers)
120+
121+
find_file(
122+
config_file_template
123+
NAMES "${package_name}-config.cmake.in"
124+
PATHS "${CMAKE_CURRENT_SOURCE_DIR}"
125+
NO_DEFAULT_PATH
126+
NO_CACHE
127+
REQUIRED
128+
)
129+
set(config_package_file
130+
"${CMAKE_CURRENT_BINARY_DIR}/${package_name}-config.cmake"
131+
)
132+
set(package_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${package_name}")
133+
configure_package_config_file(
134+
"${config_file_template}"
135+
"${config_package_file}"
136+
INSTALL_DESTINATION "${package_install_dir}"
137+
PATH_VARS PROJECT_NAME PROJECT_VERSION
138+
)
139+
140+
set(config_version_file
141+
"${CMAKE_CURRENT_BINARY_DIR}/${package_name}-config-version.cmake"
142+
)
143+
write_basic_package_version_file(
144+
"${config_version_file}"
145+
VERSION "${PROJECT_VERSION}"
146+
COMPATIBILITY ExactVersion
147+
)
148+
149+
install(
150+
FILES "${config_package_file}" "${config_version_file}"
151+
DESTINATION "${package_install_dir}"
152+
COMPONENT "${install_component_name}"
153+
)
154+
155+
set(config_targets_file "${package_name}-targets.cmake")
156+
install(
157+
EXPORT "${export_name}"
158+
DESTINATION "${package_install_dir}"
159+
NAMESPACE beman::
160+
FILE "${config_targets_file}"
161+
COMPONENT "${install_component_name}"
162+
)
163+
else()
164+
message(
165+
DEBUG
166+
"beman-install-library: Not installing a config package for '${name}'"
167+
)
168+
endif()
169+
endfunction()

0 commit comments

Comments
 (0)