-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from aaronfranke/ci-pre-commit
CI: Update to use pre-commit and fix typos with codespell
- Loading branch information
Showing
10 changed files
with
106 additions
and
89 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import sys | ||
|
||
if len(sys.argv) < 2: | ||
print("Invalid usage of file_format.py, it should be called with a path to one or multiple files.") | ||
sys.exit(1) | ||
|
||
BOM = b"\xef\xbb\xbf" | ||
|
||
changed = [] | ||
invalid = [] | ||
|
||
for file in sys.argv[1:]: | ||
try: | ||
with open(file, "rt", encoding="utf-8") as f: | ||
original = f.read() | ||
except UnicodeDecodeError: | ||
invalid.append(file) | ||
continue | ||
|
||
if original == "": | ||
continue | ||
|
||
EOL = "\n" | ||
revamp = EOL.join([line.rstrip("\n\r\t ") for line in original.splitlines(True)]).rstrip(EOL) + EOL | ||
|
||
new_raw = revamp.encode(encoding="utf-8") | ||
if new_raw.startswith(BOM): | ||
new_raw = new_raw[len(BOM) :] | ||
|
||
with open(file, "rb") as f: | ||
old_raw = f.read() | ||
|
||
if old_raw != new_raw: | ||
changed.append(file) | ||
with open(file, "wb") as f: | ||
f.write(new_raw) | ||
|
||
if changed: | ||
for file in changed: | ||
print(f"FIXED: {file}") | ||
|
||
if invalid: | ||
for file in invalid: | ||
print(f"REQUIRES MANUAL CHANGES: {file}") | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
name: 📊 Static Checks | ||
on: [push, pull_request] | ||
|
||
concurrency: | ||
group: ci-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }}-static | ||
|
||
jobs: | ||
format: | ||
name: File formatting (file_format.sh) | ||
runs-on: ubuntu-22.04 | ||
static-checks: | ||
name: Code style and file formatting | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install APT dependencies | ||
uses: awalsh128/cache-apt-pkgs-action@latest | ||
with: | ||
packages: dos2unix moreutils | ||
fetch-depth: 2 | ||
|
||
- name: File formatting checks (file_format.sh) | ||
- name: General setup | ||
run: | | ||
bash ./.github/scripts/file_format.sh | ||
git config diff.wsErrorHighlight all | ||
- name: Style checks via pre-commit | ||
uses: pre-commit/action@v3.0.1 | ||
with: | ||
extra_args: --all-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
default_language_version: | ||
python: python3 | ||
|
||
exclude: | | ||
(?x)^( | ||
CODE_OF_CONDUCT.md | | ||
extensions/2.0/OMI_seat/examples/simple_chair_what.gltf | ||
) | ||
repos: | ||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.3.0 | ||
hooks: | ||
- id: codespell | ||
additional_dependencies: [tomli] | ||
|
||
- repo: local | ||
hooks: | ||
- id: file-format | ||
name: file-format | ||
language: python | ||
entry: python .github/workflows/file_format.py | ||
types_or: [text] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters