Skip to content

Commit 66160c7

Browse files
committed
upstream beman infra utilites
1 parent ec09767 commit 66160c7

20 files changed

+1919
-0
lines changed

infra/.beman_submodule

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[beman_submodule]
2+
remote=https://github.com/bemanproject/infra.git
3+
commit_hash=bb58b2a1cc894d58a55bf745be78f5d27029e245

infra/.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @ednolan @neatudarius @rishyak @wusatosi @JeffGarland
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
3+
name: beman-submodule tests
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
beman-submodule-script-ci:
14+
name: beman_module.py ci
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.13
24+
25+
- name: Install pytest
26+
run: |
27+
python3 -m pip install pytest
28+
29+
- name: Run pytest
30+
run: |
31+
cd tools/beman-submodule/
32+
pytest
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Lint Check (pre-commit)
2+
3+
on:
4+
# We have to use pull_request_target here as pull_request does not grant
5+
# enough permission for reviewdog
6+
pull_request_target:
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
pre-commit-push:
13+
name: Pre-Commit check on Push
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event_name == 'push' }}
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: 3.13
25+
26+
# We wish to run pre-commit on all files instead of the changes
27+
# only made in the push commit.
28+
#
29+
# So linting error persists when there's formatting problem.
30+
- uses: pre-commit/[email protected]
31+
32+
pre-commit-pr:
33+
name: Pre-Commit check on PR
34+
runs-on: ubuntu-latest
35+
if: ${{ github.event_name == 'pull_request_target' }}
36+
37+
permissions:
38+
contents: read
39+
checks: write
40+
issues: write
41+
pull-requests: write
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v4
46+
47+
# pull_request_target checkout the base of the repo
48+
# We need to checkout the actual pr to lint the changes.
49+
- name: Checkout pr
50+
run: gh pr checkout ${{ github.event.number }}
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Set up Python
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: 3.13
58+
59+
# we only lint on the changed file in PR.
60+
- name: Get Changed Files
61+
id: changed-files
62+
uses: tj-actions/changed-files@v45
63+
64+
# See:
65+
# https://github.com/tj-actions/changed-files?tab=readme-ov-file#using-local-git-directory-
66+
- uses: pre-commit/[email protected]
67+
id: run-pre-commit
68+
with:
69+
extra_args: --files ${{ steps.changed-files.outputs.all_changed_files }}
70+
71+
# Review dog posts the suggested change from pre-commit to the pr.
72+
- name: suggester / pre-commit
73+
uses: reviewdog/action-suggester@v1
74+
if: ${{ failure() && steps.run-pre-commit.conclusion == 'failure' }}
75+
with:
76+
tool_name: pre-commit
77+
level: warning
78+
reviewdog_flags: "-fail-level=error"
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/.gitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Compiled Object files
5+
*.slo
6+
*.lo
7+
*.o
8+
*.obj
9+
10+
# Precompiled Headers
11+
*.gch
12+
*.pch
13+
14+
# Compiled Dynamic libraries
15+
*.so
16+
*.dylib
17+
*.dll
18+
19+
# Fortran module files
20+
*.mod
21+
*.smod
22+
23+
# Compiled Static libraries
24+
*.lai
25+
*.la
26+
*.a
27+
*.lib
28+
29+
# Executables
30+
*.exe
31+
*.out
32+
*.app
33+
34+
# Python
35+
__pycache__/
36+
.pytest_cache/
37+
*.pyc
38+
*.pyo
39+
*.pyd
40+
*.pyw
41+
*.pyz
42+
*.pywz
43+
*.pyzw
44+
*.pyzwz
45+
*.delete_me
46+
47+
# MAC OS
48+
*.DS_Store
49+
50+
# Editor files
51+
.vscode/
52+
.idea/
53+
54+
# Build directories
55+
infra.egg-info/
56+
beman_tidy.egg-info/
57+
*.egg-info/
58+
build/
59+
dist/

infra/.pre-commit-config.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
10+
- repo: https://github.com/codespell-project/codespell
11+
rev: v2.4.1
12+
hooks:
13+
- id: codespell
14+
15+
# CMake linting and formatting
16+
- repo: https://github.com/BlankSpruce/gersemi
17+
rev: 0.22.3
18+
hooks:
19+
- id: gersemi
20+
name: CMake linting
21+
exclude: ^.*/tests/.*/data/ # Exclude test data directories
22+
23+
# Python linting and formatting
24+
# config file: ruff.toml (not currently present but add if needed)
25+
# https://docs.astral.sh/ruff/configuration/
26+
- repo: https://github.com/astral-sh/ruff-pre-commit
27+
rev: v0.13.2
28+
hooks:
29+
- id: ruff-check
30+
files: ^tools/beman-tidy/
31+
- id: ruff-format
32+
files: ^tools/beman-tidy/

infra/.pre-commit-hooks.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- id: beman-tidy
2+
name: "beman-tidy: bemanification your repo"
3+
entry: ./tools/beman-tidy/beman-tidy
4+
language: script
5+
pass_filenames: false
6+
always_run: true
7+
args: [".", "--verbose"]

0 commit comments

Comments
 (0)