mirror of
https://github.com/zeldaret/st
synced 2026-05-28 08:25:11 -04:00
add format rule and fix CI
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
jobs:
|
||||
lint:
|
||||
name: Linting/style checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.13'
|
||||
check-latest: true
|
||||
|
||||
- name: Install pre-commit
|
||||
run: pip install pre-commit
|
||||
|
||||
- name: Cache pre-commit hooks
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pre-commit/
|
||||
# Invalidate the cache if the pre-commit config changes or the Python version changes
|
||||
key: pre-commit-cache|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
|
||||
- name: Run pre-commit checks
|
||||
run: pre-commit run --all-files --verbose
|
||||
@@ -0,0 +1,32 @@
|
||||
name: Check Format
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
format:
|
||||
runs-on: ubuntu-24.04
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
# Checkout the repository (shallow clone)
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
# Set Git config
|
||||
- name: Git config
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
|
||||
# Run formatter
|
||||
- name: Run clang-format
|
||||
run: find include libs src -name *.h -o -name *.c -o -name *.hpp -o -name *.cpp | xargs clang-format -i
|
||||
|
||||
# Cancel if there's a diff
|
||||
- name: Check status
|
||||
run: git diff --name-only --exit-code
|
||||
@@ -1,24 +0,0 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: check-case-conflict
|
||||
- id: check-executables-have-shebangs
|
||||
- id: check-illegal-windows-names
|
||||
- id: check-json
|
||||
- id: check-merge-conflict
|
||||
- id: check-yaml
|
||||
args:
|
||||
- --allow-multiple-documents
|
||||
- id: debug-statements
|
||||
- id: destroyed-symlinks
|
||||
- id: mixed-line-ending
|
||||
- id: requirements-txt-fixer
|
||||
- id: trailing-whitespace
|
||||
args:
|
||||
- --markdown-linebreak-ext=md
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v19.1.5
|
||||
hooks:
|
||||
- id: clang-format
|
||||
@@ -100,6 +100,11 @@ match platform.machine().lower():
|
||||
|
||||
|
||||
PYTHON = sys.executable
|
||||
FORMAT_SETTINGS = {
|
||||
"version": "19",
|
||||
"folders": ["include", "libs", "src"],
|
||||
"files": ["*.h", "*.c", "*.hpp", "*.cpp"],
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
@@ -186,6 +191,13 @@ def main():
|
||||
)
|
||||
n.newline()
|
||||
|
||||
find_cmd = f"find {' '.join(FORMAT_SETTINGS['folders'])} {' -o '.join(f'-name {f}' for f in FORMAT_SETTINGS['files'])}"
|
||||
n.rule(
|
||||
name="format_exec",
|
||||
command=f"{find_cmd} | xargs clang-format-{FORMAT_SETTINGS['version']} -i"
|
||||
)
|
||||
n.newline()
|
||||
|
||||
game_build = build_path / game_version
|
||||
game_extract = extract_path / game_version
|
||||
|
||||
@@ -266,6 +278,12 @@ def add_mwld_and_rom_builds(n: ninja_syntax.Writer, game_build: Path, game_confi
|
||||
)
|
||||
n.newline()
|
||||
|
||||
n.build(
|
||||
# inputs="format_exec",
|
||||
rule="format_exec",
|
||||
outputs="format",
|
||||
)
|
||||
n.newline()
|
||||
|
||||
def add_mwcc_builds(n: ninja_syntax.Writer, game_version: str, game_build: Path, mwcc_implicit: list[Path]):
|
||||
for source_file in get_c_cpp_files([src_path, libs_path]):
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
requests
|
||||
pyperclip
|
||||
requests
|
||||
|
||||
Reference in New Issue
Block a user