-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure pre-commit hooks and GitHub Actions (#95)
* Replace the linter/formatter black and isort with Ruff. Add mypy. * Configure clang-format. * Configurate markdown linter * Create pre-commit configurations. * Trigger pre-commit checks from GitHub Actions * Refactor GitHub Actions configurations. * Configure depndabot for updating GitHub Actions settings. * Describe development steps and details about GitHub Adtions in CONTRIBUTING.md * Update contributing guidelines in README.md * Fix md link * Rephrase section names
- Loading branch information
Showing
10 changed files
with
541 additions
and
87 deletions.
There are no files selected for viewing
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,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: 'github-actions' | ||
directory: '/' | ||
schedule: | ||
interval: 'weekly' |
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ jobs: | |
name: C++ Standard Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
- name: Run before script | ||
timeout-minutes: 10 | ||
run: | | ||
|
@@ -34,46 +34,47 @@ jobs: | |
./unit_tests_evaluator5_standalone | ||
./unit_tests_evaluator6_standalone | ||
./unit_tests_evaluator7_standalone | ||
# - name: Setup Zig | ||
# uses: goto-bus-stop/[email protected] | ||
# with: | ||
# version: master | ||
# - name: zig build -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Drelease-fast | ||
# - name: zig build -Ddynamic -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Ddynamic -Drelease-fast | ||
# - name: zig build -Dtarget=x86_64-windows -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Dtarget=x86_64-windows -Drelease-fast | ||
# - name: zig build -Domaha -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Domaha -Drelease-fast | ||
# - name: zig build -Domaha -Ddynamic -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Domaha -Ddynamic -Drelease-fast | ||
# - name: zig build -Domaha -Ddynamic -Dtarget=x86_64-windows -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Domaha -Ddynamic -Dtarget=x86_64-windows -Drelease-fast | ||
# - name: zig build and run examples | ||
# run: | | ||
# cd cpp | ||
# zig build examples | ||
# zig-out/bin/c_example | ||
# zig-out/bin/cpp_example | ||
# zig-out/bin/omaha_example | ||
# - name: Setup Zig | ||
# uses: goto-bus-stop/[email protected] | ||
# with: | ||
# version: master | ||
# - name: zig build -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Drelease-fast | ||
# - name: zig build -Ddynamic -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Ddynamic -Drelease-fast | ||
# - name: zig build -Dtarget=x86_64-windows -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Dtarget=x86_64-windows -Drelease-fast | ||
# - name: zig build -Domaha -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Domaha -Drelease-fast | ||
# - name: zig build -Domaha -Ddynamic -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Domaha -Ddynamic -Drelease-fast | ||
# - name: zig build -Domaha -Ddynamic -Dtarget=x86_64-windows -Drelease-fast | ||
# run: | | ||
# cd cpp | ||
# zig build -Domaha -Ddynamic -Dtarget=x86_64-windows -Drelease-fast | ||
# - name: zig build and run examples | ||
# run: | | ||
# cd cpp | ||
# zig build examples | ||
# zig-out/bin/c_example | ||
# zig-out/bin/cpp_example | ||
# zig-out/bin/omaha_example | ||
|
||
cpp_benchmark: | ||
name: C++ Benchmark | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
- name: Run before script | ||
timeout-minutes: 10 | ||
run: | | ||
|
@@ -84,23 +85,64 @@ jobs: | |
run: | | ||
cd cpp/build | ||
./benchmark_phevaluator | ||
python-test: | ||
name: Python test | ||
name: Python - Run unit tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
python-version: | ||
- "3.8" | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.x | ||
uses: actions/setup-python@v2 | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install package | ||
- name: Run tests | ||
run: | | ||
cd python | ||
pip install . | ||
- name: Run script | ||
python -m unittest discover -v | ||
python-type-checking: | ||
name: Python - Type checking with mypy | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: | ||
- "3.8" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Run mypy | ||
run: | | ||
cd python | ||
python -m unittest discover -v | ||
pip install mypy | ||
mypy . | ||
python-check-install: | ||
name: Python - Check package installation (without releasing) | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: | ||
- "3.8" | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install package | ||
run: | | ||
cd python | ||
pip install . |
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,21 @@ | ||
name: pre-commit | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
branches: | ||
- master | ||
- develop | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.8" | ||
- uses: pre-commit/[email protected] |
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,10 @@ | ||
# Default state for all rules | ||
default: true | ||
|
||
# MD033 - Inline HTML | ||
MD033: | ||
# We allow the <a> tag to create named anchors within the document. | ||
# Example: | ||
# [Go to section](#section) | ||
# <a name="section"></a> | ||
allowed_elements: [a] |
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,114 @@ | ||
repos: | ||
# Display the arguments passed to the hook | ||
- repo: meta | ||
hooks: | ||
- id: identity | ||
|
||
# For all files | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
fail_fast: true | ||
- id: no-commit-to-branch | ||
args: [--branch=master, --branch=develop] | ||
fail_fast: true | ||
- id: forbid-submodules | ||
fail_fast: true | ||
- id: detect-private-key | ||
- id: fix-byte-order-marker | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
# Formatting for TOML | ||
- id: check-toml | ||
# Formatting for YAML | ||
- id: check-yaml | ||
|
||
# For all files | ||
- repo: https://github.com/Lucas-C/pre-commit-hooks | ||
rev: v1.5.5 | ||
hooks: | ||
- id: remove-crlf | ||
- id: remove-tabs | ||
|
||
# Formatting for Python configuration files | ||
- repo: https://github.com/asottile/setup-cfg-fmt | ||
rev: v2.5.0 | ||
hooks: | ||
- id: setup-cfg-fmt | ||
|
||
# Linting and formatting for C++ | ||
- repo: https://github.com/pocc/pre-commit-hooks | ||
rev: v1.3.5 | ||
hooks: | ||
- id: clang-format | ||
args: [-i] | ||
exclude: | | ||
(?x)^( | ||
cpp/src/hashtable.*| | ||
cpp/src/tables.* | ||
)$ | ||
# - id: clang-tidy | ||
# - id: oclint | ||
# - id: cppcheck | ||
# - id: include-what-you-use | ||
# args: [-Xiwyu, --no_comments] | ||
|
||
# Formatting markdown files | ||
- repo: https://github.com/igorshubovych/markdownlint-cli | ||
rev: v0.40.0 | ||
hooks: | ||
- id: markdownlint | ||
args: [--fix] | ||
|
||
- repo: local | ||
hooks: | ||
# Linting for Python | ||
- id: ruff-check | ||
name: Python - Linting with Ruff | ||
entry: bash -c 'pip install ruff && cd python && ruff check' | ||
language: system | ||
types_or: [python] | ||
pass_filenames: false | ||
|
||
# Formatting for Python | ||
- id: ruff-format | ||
name: Python - Formatting with Ruff | ||
entry: bash -c 'pip install ruff && cd python && ruff format' | ||
language: system | ||
types_or: [python] | ||
pass_filenames: false | ||
|
||
# Type checking for Python | ||
- id: mypy | ||
name: Python - Type checking with mypy | ||
entry: bash -c 'pip install mypy && cd python && mypy .' | ||
language: system | ||
types_or: [python] | ||
pass_filenames: false | ||
stages: | ||
- pre-commit | ||
- pre-merge-commit | ||
- pre-rebase | ||
- manual | ||
|
||
# Unit testing for Python | ||
- id: unittest | ||
name: Python - Run unit tests | ||
entry: python -m unittest discover | ||
language: system | ||
pass_filenames: false | ||
stages: | ||
- pre-commit | ||
- pre-merge-commit | ||
- pre-rebase | ||
- manual | ||
|
||
# Display the differences between the original and formatted code | ||
- id: git-diff | ||
name: git diff | ||
entry: git diff --color --exit-code | ||
language: system | ||
pass_filenames: false | ||
always_run: true |
Oops, something went wrong.