Skip to content

Commit

Permalink
Add pre-commit configuration file
Browse files Browse the repository at this point in the history
Add codespell checks and corrections
Add static check github action
  • Loading branch information
Spartan322 committed Dec 26, 2024
1 parent da6c155 commit c70cf0a
Show file tree
Hide file tree
Showing 48 changed files with 594 additions and 88 deletions.
19 changes: 19 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Checks:
- -*
- cppcoreguidelines-pro-type-member-init
- modernize-redundant-void-arg
- modernize-use-bool-literals
- modernize-use-default-member-init
- modernize-use-nullptr
- readability-braces-around-statements
- readability-redundant-member-init
HeaderFileExtensions: ['', h, hh, hpp, hxx, inc]
ImplementationFileExtensions: [c, cc, cpp, cxx]
HeaderFilterRegex: (extension/src/openvic-extension)/
FormatStyle: file
CheckOptions:
cppcoreguidelines-pro-type-member-init.IgnoreArrays: true
cppcoreguidelines-pro-type-member-init.UseAssignment: true
modernize-use-bool-literals.IgnoreMacros: false
modernize-use-default-member-init.IgnoreMacros: false
modernize-use-default-member-init.UseAssignment: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/1-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body:
Thank you for filling out this bug report!
When reporting a bug, please follow the guidelines in this template. This helps us quickly identify the problem you're having.
- If this report is about a feature or behavior in Victoria II that is missing or working incorrectly in OpenVic, please report a [Victoria II discrepency](https://github.com/OpenVicProject/OpenVic/issues/new?assignees=&labels=&projects=&template=2-victoria-2-discrepency.yml) instead.
- If this report is about a feature or behavior in Victoria II that is missing or working incorrectly in OpenVic, please report a [Victoria II discrepancy](https://github.com/OpenVicProject/OpenVic/issues/new?assignees=&labels=&projects=&template=2-victoria-2-discrepancy.yml) instead.
- Write a descriptive issue title above.
- **Always open *one* issue for *one* bug**. If you notice several bugs, make sure to create one new issue for each of them.
- Verify that you are using either the latest release or the latest commit. It is preferred that you check if your issue is reproducible in the latest commit - it may already have been fixed!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
name: Victoria II Discrepency
description: "Report a discrepency from Victoria II. NOTE: Not for reporting bugs in OpenVic."
labels: ["bug", "victoria 2 discrepency", "needs triage"]
name: Victoria II Discrepancy
description: "Report a discrepancy from Victoria II. NOTE: Not for reporting bugs in OpenVic."
labels: ["bug", "victoria 2 discrepancy", "needs triage"]
body:
- type: markdown
attributes:
value: |
Thank you for filling out this discrepency report!
Thank you for filling out this discrepancy report!
When reporting a bug, please follow the guidelines in this template. This helps us quickly identify the discrepency and get to work on a solution.
When reporting a bug, please follow the guidelines in this template. This helps us quickly identify the discrepancy and get to work on a solution.
- Only open this issue if you have noticed a difference between OpenVic and Victoria II.
- **DO NOT FILE CRASHES HERE!** Please use the [bug report](https://github.com/OpenVicProject/OpenVic/issues/new?assignees=&labels=&projects=&template=1-bug-report.yml) template instead.
- Write a descriptive issue title above.
- **Always open *one* issue for *one* discrepency**. If you notice several discrepencies, make sure to create one new issue for each of them.
- **Always open *one* issue for *one* discrepancy**. If you notice several discrepancies, make sure to create one new issue for each of them.
- Verify that you are using either the latest release or the latest commit. It is preferred that you check if your issue is reproducible in the latest commit - it may already have been fixed!
- If you're playing with custom source modifications, please test if this discrepency is reproducible in the latest official build of OpenVic before opening an issue here.
- If you're playing with custom source modifications, please test if this discrepancy is reproducible in the latest official build of OpenVic before opening an issue here.
- type: checkboxes
attributes:
label: Duplicate Issue?
description: "Search [open](https://github.com/OpenVicProject/OpenVic/issues) and [closed](https://github.com/OpenVicProject/OpenVic/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported. If you don't find a relevant match or if you're not sure, don't hesitate to **open a new issue**. Contributors will handle it from there if it's a duplicate."
options:
- label: I have checked for an existing discrepency report.
- label: I have checked for an existing discrepancy report.
required: true

- type: textarea
id: game-versions
attributes:
label: Game & Version Info
description: |
Enter the OpenVic version and commit you found this discrepency on in this box. You can find and copy this by clicking on the "Game Info" button in the bottom left corner of the OpenVic main menu. If you've found this discrepency to be reproducible on multiple versions, list all of those versions here.
Enter the OpenVic version and commit you found this discrepancy on in this box. You can find and copy this by clicking on the "Game Info" button in the bottom left corner of the OpenVic main menu. If you've found this discrepancy to be reproducible on multiple versions, list all of those versions here.
placeholder: |
- Found in: <v0.02_Mappa_Mundi> (c65b2a795fd35e81f7a1906d07d15c47cd94cf9c).
- Not reproducible in: <v0.01_Primum_Mobile> (1980012045ea4c6b314d6d12a796eda23ae8d7fa).
Expand All @@ -47,7 +47,7 @@ body:
attributes:
label: Issue Description
description: |
Describe the discrepency briefly. What happens in OpenVic, and how does it work in Victoria II?
Describe the discrepancy briefly. What happens in OpenVic, and how does it work in Victoria II?
You can include images or videos with drag and drop.
validations:
required: true
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/3-gameplay-feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ body:
- type: markdown
attributes:
value: |
- If this feature was in Victoria II, please report a [Victoria II Discrepency](https://github.com/OpenVicProject/OpenVic/issues/new?assignees=&labels=&projects=&template=2-victoria-2-discrepency.yml) instead.
- If this feature was in Victoria II, please report a [Victoria II Discrepancy](https://github.com/OpenVicProject/OpenVic/issues/new?assignees=&labels=&projects=&template=2-victoria-2-discrepency.yml) instead.
- If this feature only applies to mods and contains no mechanical additions to the vanilla experience, please report it as a [mod feature request](https://github.com/OpenVicProject/OpenVic/issues/new?assignees=&labels=&projects=&template=4-mod-feature-request.yml).
- Write a descriptive proposal title above.
Expand All @@ -22,6 +22,6 @@ body:
attributes:
label: Feature Description
description: An in-depth description of what feature you want added to OpenVic, and **why** its important to have.
placeholder: Example - "Add a macro builder - a menu that allows you to contruct armies or navies from templates. Think of the macro builder menu from EUIV perhaps. This will improve the game experience by allowing people to build whole armies at once rather than counting out brigades in the army build menu."
placeholder: Example - "Add a macro builder - a menu that allows you to construct armies or navies from templates. Think of the macro builder menu from EUIV perhaps. This will improve the game experience by allowing people to build whole armies at once rather than counting out brigades in the army build menu."
validations:
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/4-mod-feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ body:
- type: markdown
attributes:
value: |
- If this feature was in Victoria II, please report a [Victoria II discrepency](https://github.com/OpenVicProject/OpenVic/issues/new?assignees=&labels=&projects=&template=2-victoria-2-discrepency.yml) instead.
- If this feature was in Victoria II, please report a [Victoria II discrepancy](https://github.com/OpenVicProject/OpenVic/issues/new?assignees=&labels=&projects=&template=2-victoria-2-discrepancy.yml) instead.
- If this feature only intends to include mechanical additions to the vanilla experience, please report it as a [gameplay feature request](https://github.com/OpenVicProject/OpenVic/issues/new?assignees=&labels=&projects=&template=3-gameplay-feature-request.yml).
- Write a descriptive proposal title above.
Expand Down
40 changes: 39 additions & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,47 @@ concurrency:
cancel-in-progress: true

jobs:
static-checks:
name: Code style, file formatting, and docs
runs-on: ubuntu-24.04
steps:
- name: Checkout project
uses: actions/checkout@v4.1.1
with:
fetch-depth: 2

- name: Install APT dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libxml2-utils

- name: Get changed files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
fi
echo "$files" >> changed.txt
cat changed.txt
files=$(echo "$files" | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ')
echo "CHANGED_FILES=$files" >> $GITHUB_ENV
- name: Style checks via pre-commit
uses: pre-commit/action@v3.0.1
with:
extra_args: --files ${{ env.CHANGED_FILES }}

- name: Class reference schema checks
run: |
xmllint --noout --schema extension/doc_tools/class.xsd extension/doc_classes/*.xml
build:
runs-on: ${{matrix.os}}
name: ${{matrix.name}}
needs: static-checks
permissions: write-all
strategy:
fail-fast: false
Expand Down Expand Up @@ -140,7 +178,7 @@ jobs:
runs-on: ubuntu-latest
needs: [build]

name: Peform Godot Debug Checks
name: Perform Godot Debug Checks
steps:
- name: Checkout project
uses: actions/checkout@v4.1.1
Expand Down
74 changes: 74 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
default_language_version:
python: python3

repos:
# Waiting on Hop311 to approve clang-format
# - repo: https://github.com/pre-commit/mirrors-clang-format
# rev: v19.1.3
# hooks:
# - id: clang-format
# files: \.(c|h|cpp|hpp|inc)$
# types_or: [text]
# # exclude: |
# # (?x)^(
# # )

- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-tidy
files: \.(c|h|cpp|hpp|inc)$
args: [--fix, --quiet, --use-color]
types_or: [text]
additional_dependencies: [clang-tidy==19.1.0]
require_serial: true
stages: [manual] # Not automatically triggered, invoked via `pre-commit run --hook-stage manual clang-tidy`

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
exclude: |
(?x)^(
extension/doc_tools/make_rst.py|
extension/doc_tools/doc_status.py
)
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
files: \.py$
types_or: [text]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
exclude: |
(?x)^(
game/assets/localisation/locales/.*|
game/addons/.*
)
additional_dependencies: [tomli]


- repo: local
hooks:
- id: make-rst
name: make-rst
language: python
entry: python extension/doc_tools/make_rst.py
args: [extension, --dry-run, --color]
pass_filenames: false
files: ^(extension/doc_classes)/.*\.xml$

- id: doc-status
name: doc-status
language: python
entry: python extension/doc_tools/doc_status.py
args: [extension/doc_classes]
pass_filenames: false
files: ^(extension/doc_classes)/.*\.xml$
2 changes: 1 addition & 1 deletion docs/contribution/cloning.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ After cloning you must initialize and update the submodules:
cd OpenVic
git submodule update --init --recursive
```
Updating the submodules is neccessary every time the dependencies are updated, if you're unsure, on every `git pull` you should also call `git submodule update --init --recursive`
Updating the submodules is necessary every time the dependencies are updated, if you're unsure, on every `git pull` you should also call `git submodule update --init --recursive`

To update the repo you must pull the repo:
```sh
Expand Down
4 changes: 2 additions & 2 deletions docs/contribution/rebasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In here you will see a list of commits you've made to your PR branch, count the
git rebase -i HEAD~6
```

Now this will collect all commits from the HEAD (the current commit you're on) back 6 commits (including the HEAD) and rebase them into whatever you tell the dialogue. Now if you do this you might something like this in a text document or in your terminal:
Now this will collect all commits from the HEAD (the current commit you're on) back 6 commits (including the HEAD) and rebase them into whatever you tell the dialog. Now if you do this you might something like this in a text document or in your terminal:
```sh
pick 24a0751 Update README.md for Archlinux users
pick 0e408c8 Add Window Override
Expand Down Expand Up @@ -63,4 +63,4 @@ Read the comments following the `#` and it'll tell you what to do, generally we
pick 24a0751 Update README.md for Archlinux users
s 0e408c8 Add Window Override
```
The top value is the first commit you referred to, this list is organized according to a seqeunce of the commit history, (this specific one was made via `HEAD~2`) you will always want the first one to be pick here, generally everything else is squash/s so it merges the commit into the previous commit while still giving you control over the commit messages. After this it will rebase the commits and then ask you about the commit message you wish to create, this will have to be up to you, you can always change it later, if there is a problem with it we will mention it. Now that you've done that however, the last step is to force push it, to do so you can use `git gui` and push then click the force option or you can call `git push -f`. Now your squash is complete. Be careful rebasing or squash when someone else is working on your branchs at the same time, a force push can hurt them, you should wait until they tell you that they're done and merge their changes to your branch before you rebase/squash. Rebasing/squashing commits that others rely upon is a one-way ticket to Git nigthmares.
The top value is the first commit you referred to, this list is organized according to a sequence of the commit history, (this specific one was made via `HEAD~2`) you will always want the first one to be pick here, generally everything else is squash/s so it merges the commit into the previous commit while still giving you control over the commit messages. After this it will rebase the commits and then ask you about the commit message you wish to create, this will have to be up to you, you can always change it later, if there is a problem with it we will mention it. Now that you've done that however, the last step is to force push it, to do so you can use `git gui` and push then click the force option or you can call `git push -f`. Now your squash is complete. Be careful rebasing or squash when someone else is working on your branches at the same time, a force push can hurt them, you should wait until they tell you that they're done and merge their changes to your branch before you rebase/squash. Rebasing/squashing commits that others rely upon is a one-way ticket to Git nightmares.
2 changes: 1 addition & 1 deletion docs/contribution/system-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ With Python 3.6+ installed, you can install Scons through pip:
```sh
python -m pip install scons
```
If you get `Defaulting to user installation because normal site-packages is not writeable` then open a command prompt as Administrator and run the command again. When finished call:
If you get `Defaulting to user installation because normal site-packages is not writable` then open a command prompt as Administrator and run the command again. When finished call:
```
scons --version
```
Expand Down
2 changes: 1 addition & 1 deletion docs/contribution/using-git-bisect.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ If the commit doesn't have the bug then run:
```sh
git bisect good
```
When done it will stop at the responsible commit for which you can investigate to see whats causing the issue.
When done it will stop at the responsible commit for which you can investigate to see what's causing the issue.

For more documentation on git bisect see: https://git-scm.com/docs/git-bisect
Loading

0 comments on commit c70cf0a

Please sign in to comment.