Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 100
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# It builds the project on multiple operating systems (Ubuntu, Windows, and macOS)

name: Build Project

on:
pull_request:
branches:
- main

jobs:
debug:
name: Build
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- { name: "Windows gcc", os: windows-latest, cc: "gcc", cxx: "g++" }
- { name: "Ubuntu gcc", os: ubuntu-latest, cc: "gcc", cxx: "g++" }
- { name: "MacOS clang", os: macos-latest, cc: "clang", cxx: "clang++" }
build-configuration: [ Debug, Release ]

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master

- name: Build Project
uses: threeal/cmake-action@v2.1.0
with:
args: -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build-configuration }}
c-compiler: ${{ matrix.config.cc }}
cxx-compiler: ${{ matrix.config.cxx }}
34 changes: 34 additions & 0 deletions .github/workflows/clang-format-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow should only be run by administrators

name: ClangFormat correction

on:
workflow_dispatch:

jobs:
ClangFormat:
name: ClangFormat correction
runs-on: ubuntu-22.04

# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
permissions:
contents: write

steps:
# Clone Repo
- name: Checkout
uses: actions/checkout@v4

- name: Install clang-format
run: sudo apt-get update && sudo apt-get install -y clang-format

- name: Format code
#run: clang-format -i **/*.cpp
run: find . -type f \( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) -exec clang-format -i {} \;

# Commit all changed files back to the repository
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Apply Clang formatting'
create_branch: false
34 changes: 34 additions & 0 deletions .github/workflows/clang-format-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow is from https://github.com/official-stockfish/Stockfish/blob/master/.github/workflows/clang-format.yml#L23

# This workflow will run clang-format and comment on the PR.
# Because of security reasons, it is crucial that this workflow
# executes no shell script nor runs make.
# Read this before editing: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/

name: ClangFormat check
on:
pull_request_target:
branches:
- "main"
paths:
- "**.cpp"
- "**.h"

# needed for automatic comment in pr
permissions:
pull-requests: write

jobs:
Clang-Format:
name: Clang-Format
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Run clang-format style check
uses: jidicula/clang-format-action@v4.15.0
id: clang-format
with:
clang-format-version: "20"
71 changes: 71 additions & 0 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This workflow runs when a tag is pushed to the repository point to the main branch.
# It builds the project on multiple operating systems (Ubuntu, Windows, and macOS) and
# creates a pre-release.

name: Create Release

on:
push:
tags:
- 'v*'

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: true

build:
name: Build Project
needs: release
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- { name: "Windows gcc", os: windows-latest, cc: "gcc", cxx: "g++" }
- { name: "Ubuntu gcc", os: ubuntu-latest, cc: "gcc", cxx: "g++" }
- { name: "MacOS clang", os: macos-latest, cc: "clang", cxx: "clang++" }
build-configuration: [ Release ]

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master

- name: Build Project
uses: threeal/cmake-action@v2.1.0
with:
args: -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build-configuration }}
c-compiler: ${{ matrix.config.cc }}
cxx-compiler: ${{ matrix.config.cxx }}

- name: Compress Build Directory
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
path: 'build'
filename: '${{ matrix.config.os}}-build.zip'

- name: Upload Release Asset
uses: alexellis/upload-assets@0.4.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["${{ matrix.config.os}}-build.zip"]'