Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into ZAP-73-2-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeAbel committed Jun 19, 2023
2 parents 2e0eaf2 + cde0052 commit 6d89327
Show file tree
Hide file tree
Showing 60 changed files with 1,569 additions and 1,183 deletions.
21 changes: 21 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
documentation:
- README.md

enhancement:
- src/AI/**/*.py
- src/GUI/**/*.hpp
- src/GUI/**/*.cpp
- src/SERVER/**/*.c
- src/SERVER/**/*.h

cicd:
- .github/workflows/*.yml

SERVER:
- src/SERVER/*

AI:
- src/AI/*

GUI:
- src/GUI/*
80 changes: 80 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "dev", main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "dev" ]
schedule:
- cron: '37 3 * * 3'

jobs:
analyze:
name: Analyze
runs-on: 'ubuntu-latest'
timeout-minutes: 360
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Build
run: |
sudo apt install make cmake libsfml-dev python3 pip
make
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"

38 changes: 38 additions & 0 deletions .github/workflows/cpp-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: C++ Lint

on:
push:
paths:
- 'src/GUI/**.cpp'
- 'src/GUI/**.hpp'

jobs:
clang-format:
runs-on: ubuntu-latest
env:
workdir: ./src/GUI

steps:
- uses: actions/checkout@v3

- name: Install Deps
run: |
sudo apt install -y clang-format
- name: Lint
run: |
FILES=$(find src -name '*.cpp' -o -name '*.hpp')
clang-format --dry-run --Werror -style=file -i $FILES | tee lint-report.log
working-directory: ${{ env.workdir }}

- name: Upload Lint Report
uses: actions/upload-artifact@v3
with:
name: lint-report.log
path: src/GUI/lint-report.log

- name: Is error ?
run: |
if [ ! -f 'lint-report.log' ]; then exit 0; fi
if [ -s 'lint-report.log' ]; then cat 'lint-report.log' && exit 1; fi
working-directory: ${{ env.workdir }}
18 changes: 18 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# https://github.com/actions/labeler

name: Labeler
on: [pull_request_target]

jobs:
label:

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
dot: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -1004,5 +1004,6 @@ zappy_gui
zappy_server
vgcore.*
*.clang-format
!src/GUI/.clang-format
*.vscode/
*.idea
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ $(TARGET_server)_clean:
$(MAKE) -C $(TARGET_server_DIR) clean

$(TARGET_gui)_clean:
if [ -d $(TARGET_gui_DIR)/build ]; then $(RM) -r $(TARGET_gui_DIR)/build; fi
if [ -d $(TARGET_gui_DIR)/build ]; then \
$(RM) -r $(TARGET_gui_DIR)/build; \
fi

$(TARGET_ai)_clean:
$(MAKE) -C $(TARGET_ai_DIR) clean
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ dnf install SFML-devel SFML
# Arch-based
pacman -S python python-pip
# Debian-based
apt install python pip
apt install python3 pip
# Fedora
dnf install python pip
# Windows: available on microsoft store
Expand Down
16 changes: 11 additions & 5 deletions src/AI/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ LOCAL_DEPS = local_deps
CP ?= cp
RM ?= rm -f
TOEXEC ?= chmod +x
CURDIR = $(shell pwd)

all: $(TARGET)

Expand All @@ -38,14 +39,18 @@ $(LOCAL_DEPS)/simple: $(LOCAL_DEPS)/requirements.txt
$(MAKE) $(LOCAL_DEPS)/simple-force

$(LOCAL_DEPS)/simple-force: $(LOCAL_DEPS)/requirements.txt
pip install --break-system-packages --user piprepo
pip install --break-system-packages --user piprepo || \
pip install --user piprepo
pip download -d ./local_deps -r ./$(LOCAL_DEPS)/requirements.txt
piprepo build ./local_deps

$(TARGET):
([ ! -d $(LOCAL_DEPS)/simple ] && $(MAKE) $(LOCAL_DEPS)/simple-force) || \
true
pip install --break-system-packages --user -i ./local_deps/simple .
if [ ! -d $(LOCAL_DEPS)/simple ]; then \
$(MAKE) $(LOCAL_DEPS)/simple-force; \
fi
pip install --break-system-packages --user \
-i file:$(CURDIR)/local_deps/simple . || \
pip install --user -i ./local_deps/simple .
$(CP) "$(TARGET).py" "$(TARGET)"
$(TOEXEC) "$(TARGET)"

Expand All @@ -54,7 +59,8 @@ clean:
$(RM) -r $(PIP_TARGET).egg-info

fclean: clean
pip uninstall --break-system-packages -y $(PIP_TARGET)
pip uninstall --break-system-packages -y $(PIP_TARGET) || \
pip uninstall -y $(PIP_TARGET)
$(RM) $(LOCAL_DEPS)/requirements.txt
$(RM) $(TARGET)

Expand Down
90 changes: 90 additions & 0 deletions src/GUI/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Language: Cpp
ColumnLimit: '80'
ReflowComments: true
AlignAfterOpenBracket: DontAlign
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
IndentWrappedFunctionNames: 'false'
AccessModifierOffset: 0
IndentAccessModifiers: true
BinPackArguments: true
BinPackParameters: true
AlignOperands: false
BreakBeforeBraces: Custom

BraceWrapping:
AfterCaseLabel: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true

AlwaysBreakAfterReturnType: None

TabWidth: '4'
UseTab: Never
IndentPPDirectives: BeforeHash
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
Cpp11BracedListStyle: true
PointerAlignment: Right
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: 'false'
SpacesInAngles: false
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
SpacesInContainerLiterals: 'false'
SpaceAfterTemplateKeyword: 'true'
IndentCaseLabels: 'true'
NamespaceIndentation: All
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: None
AllowShortLoopsOnASingleLine: 'false'
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'true'
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
AlignConsecutiveMacros: true
AlignEscapedNewlines: Left
AlignTrailingComments: true
BreakStringLiterals: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true
SortIncludes: true
IncludeBlocks: Preserve
IncludeCategories:
IncludeCategories:
- Regex: '^"[[:alnum:]./]+"' # Any "my_header.h"
Priority: 3
- Regex: '<criterion/[a-z]+\.h>' # Criterion headers
Priority: 2
- Regex: '<[[:alnum:]./]+>' # System/Standard libs
Priority: 1

# Sort 'using' declarations
SortUsingDeclarations: true

BasedOnStyle: LLVM
AlwaysBreakBeforeMultilineStrings: 'true'
ContinuationIndentWidth: '0'
IndentWidth: '4'
PenaltyBreakAssignment: '0'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeRangeBasedForLoopColon: 'true'

# To totally disable format
DisableFormat: 'false'
5 changes: 3 additions & 2 deletions src/GUI/Dependencies/build-SFML.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if (WIN32)
include(FetchContent)
set(SFML_BUILD_AUDIO OFF)
set(SFML_BUILD_AUDIO ON)
set(SFML_BUILD_NETWORK OFF)
set(SFML_BUILD_DOC OFF)
set(SFML_BUILD_EXAMPLES OFF)
Expand All @@ -15,10 +15,11 @@ if (WIN32)
sfml-graphics
sfml-window
sfml-system
sfml-audio
)
else()
find_library(SFML sfml-graphics sfml-window sfml-system)
target_link_libraries(${PROJECT_NAME} PRIVATE
sfml-graphics sfml-window sfml-system
sfml-graphics sfml-window sfml-system sfml-audio
)
endif()
Binary file modified src/GUI/assets/musics/mainTheme.ogg
Binary file not shown.
7 changes: 7 additions & 0 deletions src/GUI/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e
set -x

FILES=$(find src -name '*.cpp' -o -name '*.hpp')

clang-format -i -style=file $FILES
Loading

0 comments on commit 6d89327

Please sign in to comment.