From d355e98a0a4a46189e67ac90618ebe6102eb2aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Tue, 17 Dec 2024 04:21:16 -0300 Subject: [PATCH 1/6] * github --- .github/FUNDING.yml | 14 ++ .github/ISSUE_TEMPLATE/bug.yaml | 65 ++++++++++ .github/ISSUE_TEMPLATE/request.yaml | 48 +++++++ .github/PULL_REQUEST_TEMPLATE.md | 47 +++++++ .github/labeler.yml | 16 +++ .../workflows/analysis-reviewdog-cppcheck.yml | 38 ++++++ .github/workflows/analysis-reviewdog.yml | 121 ++++++++++++++++++ .github/workflows/build-docker-dummy.yml | 22 ++++ .github/workflows/build-docker.yml | 112 ++++++++++++++++ .github/workflows/build-ubuntu-dummy.yml | 29 +++++ .github/workflows/build-ubuntu.yml | 117 +++++++++++++++++ .../workflows/build-windows-cmake-dummy.yml | 25 ++++ .github/workflows/build-windows-cmake.yml | 86 +++++++++++++ .../build-windows-solution-dummy.yml | 26 ++++ .github/workflows/build-windows-solution.yml | 82 ++++++++++++ .github/workflows/clang-lint-dummy.yml | 12 ++ .github/workflows/clang-lint.yml | 56 ++++++++ .github/workflows/clean-cache.yaml | 30 +++++ .github/workflows/cron-stale.yml | 28 ++++ .github/workflows/issue.yml | 25 ++++ .github/workflows/lua-format-dummy.yml | 13 ++ .github/workflows/lua-format.yml | 42 ++++++ .github/workflows/mysql-schema-check.yml | 43 +++++++ .github/workflows/pr-labeler.yml | 12 ++ .github/workflows/tests-lua.yml | 24 ++++ docker/docker-compose.yml | 2 +- 26 files changed, 1134 insertions(+), 1 deletion(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/bug.yaml create mode 100644 .github/ISSUE_TEMPLATE/request.yaml create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/analysis-reviewdog-cppcheck.yml create mode 100644 .github/workflows/analysis-reviewdog.yml create mode 100644 .github/workflows/build-docker-dummy.yml create mode 100644 .github/workflows/build-docker.yml create mode 100644 .github/workflows/build-ubuntu-dummy.yml create mode 100644 .github/workflows/build-ubuntu.yml create mode 100644 .github/workflows/build-windows-cmake-dummy.yml create mode 100644 .github/workflows/build-windows-cmake.yml create mode 100644 .github/workflows/build-windows-solution-dummy.yml create mode 100644 .github/workflows/build-windows-solution.yml create mode 100644 .github/workflows/clang-lint-dummy.yml create mode 100644 .github/workflows/clang-lint.yml create mode 100644 .github/workflows/clean-cache.yaml create mode 100644 .github/workflows/cron-stale.yml create mode 100644 .github/workflows/issue.yml create mode 100644 .github/workflows/lua-format-dummy.yml create mode 100644 .github/workflows/lua-format.yml create mode 100644 .github/workflows/mysql-schema-check.yml create mode 100644 .github/workflows/pr-labeler.yml create mode 100644 .github/workflows/tests-lua.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..3848c3b2 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,14 @@ +--- + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: [ + '', +] diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml new file mode 100644 index 00000000..9f96d988 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -0,0 +1,65 @@ +name: Report a problem/bug +description: Any issues that you have found while using the server +labels: ["Type: Bug"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this issue! + + - type: dropdown + id: priority + attributes: + label: Priority + description: How critical is this? + options: + - Low + - Medium + - High + - Critical + validations: + required: true + + - type: checkboxes + id: area + attributes: + label: Area + description: Where is the problem? + options: + - label: Datapack + - label: Source + - label: Map + - label: Other + validations: + required: true + + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Describe your problem/bug and add screenshots, logs or anything that can help verifying the bug + placeholder: Tell us what you see! + value: "A bug happened!" + validations: + required: true + + - type: dropdown + id: os + attributes: + label: What OS are you seeing the problem on? + multiple: true + options: + - Linux + - Windows + - MacOS + validations: + required: true + + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/jprzimba/crystalserver/blob/main/markdowns/CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/request.yaml b/.github/ISSUE_TEMPLATE/request.yaml new file mode 100644 index 00000000..d32dbcfd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/request.yaml @@ -0,0 +1,48 @@ +name: Request +description: Any request +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this issue! + + - type: dropdown + id: priority + attributes: + label: Priority + description: How critical is this? + options: + - Missing Content + - Enhancement + validations: + required: true + + - type: checkboxes + id: area + attributes: + label: Area + description: Where is the problem? + options: + - label: Datapack + - label: Source + - label: Map + - label: Other + validations: + required: true + + - type: textarea + id: missing-content + attributes: + label: What is missing? + description: Map, sprite, script, quest, teleport, monster, etc. Attach screenshots, logs, etc, anything that can helps us + validations: + required: true + + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/jprzimba/crystalserver/blob/main/markdowns/CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..5890cad7 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,47 @@ + +# Description + +Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. + +## Behaviour +### **Actual** + +Do this and that doesn't happens + +### **Expected** + +Do this and that happens + +### Fixes #issuenumber + +## Type of change + +Please delete options that are not relevant. + + - [ ] Bug fix (non-breaking change which fixes an issue) + - [ ] New feature (non-breaking change which adds functionality) + - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) + - [ ] This change requires a documentation update + +## How Has This Been Tested + +Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration + + - [ ] Test A + - [ ] Test B + +**Test Configuration**: + + - Server Version: + - Client: + - Operating System: + +## Checklist + + - [ ] My code follows the style guidelines of this project + - [ ] I have performed a self-review of my own code + - [ ] I checked the PR checks reports + - [ ] I have commented my code, particularly in hard-to-understand areas + - [ ] I have made corresponding changes to the documentation + - [ ] My changes generate no new warnings + - [ ] I have added tests that prove my fix is effective or that my feature works diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..580b3f11 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,16 @@ +--- +"Area: Source": + - any: ['src/**/*'] + +"Area: Datapack Core": + - any: ['data/**/*'] + +"Area: Datapack Global": + - any: ['data-global/**/*', '!data-global/world/*'] + +"Area: Map Global": + - any: ['data-global/world/*'] + +"Area: Docker": + - any: ['docker/**/*'] + diff --git a/.github/workflows/analysis-reviewdog-cppcheck.yml b/.github/workflows/analysis-reviewdog-cppcheck.yml new file mode 100644 index 00000000..bca1d057 --- /dev/null +++ b/.github/workflows/analysis-reviewdog-cppcheck.yml @@ -0,0 +1,38 @@ +--- +name: Analysis - Review Dog + +on: + pull_request: + paths: + - "src/**" + push: + paths: + - "src/**" + +jobs: + cppcheck: + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + if: github.ref != 'refs/heads/main' + uses: fkirc/skip-duplicate-actions@master + with: + concurrent_skipping: "same_content" + cancel_others: true + + - name: Check out code. + uses: actions/checkout@main + + - name: Setup reviewdog + uses: reviewdog/action-setup@v1.0.3 + + - name: Setup cppcheck + run: sudo apt-get update && sudo apt-get install -y cppcheck + + - name: cppcheck + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd "$GITHUB_WORKSPACE" + cppcheck --version + reviewdog -reporter=github-pr-check -runners=cppcheck diff --git a/.github/workflows/analysis-reviewdog.yml b/.github/workflows/analysis-reviewdog.yml new file mode 100644 index 00000000..a7d6edda --- /dev/null +++ b/.github/workflows/analysis-reviewdog.yml @@ -0,0 +1,121 @@ +--- +name: Analysis - Review Dog + +on: + pull_request: + +jobs: + luac: + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + if: github.ref != 'refs/heads/main' + uses: fkirc/skip-duplicate-actions@master + with: + concurrent_skipping: "same_content" + cancel_others: true + + - name: Check out code. + uses: actions/checkout@main + + - name: Setup reviewdog + uses: reviewdog/action-setup@v1.0.3 + + - name: Setup Lua/Luacheck + run: sudo apt-get update && sudo apt-get install -y libluajit-5.1-dev lua-check + + - name: luac + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd "$GITHUB_WORKSPACE" + luac -v + reviewdog -reporter=github-pr-check -runners=luac + + luacheck: + runs-on: ubuntu-latest + steps: + - name: Check out code. + uses: actions/checkout@main + + - name: Setup reviewdog + uses: reviewdog/action-setup@v1.0.3 + + - name: Setup Lua/Luacheck + run: sudo apt-get update && sudo apt-get install -y libluajit-5.1-dev lua-check + + - name: luacheck + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + luacheck --version + cd "$GITHUB_WORKSPACE" + reviewdog -reporter=github-pr-check -runners=luacheck + + shellcheck: + runs-on: ubuntu-latest + steps: + - name: Check out code. + uses: actions/checkout@main + + - name: shellcheck + uses: reviewdog/action-shellcheck@v1.15.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-check + pattern: "*.sh" + exclude: "./.git/*" + + xmllint: + runs-on: ubuntu-latest + steps: + - name: Check out code. + uses: actions/checkout@main + + - name: Setup reviewdog + uses: reviewdog/action-setup@v1.0.3 + + - name: Setup xmllint + run: sudo apt-get update && sudo apt-get install -y libxml2-utils + + - name: xmllint + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd "$GITHUB_WORKSPACE" + xmllint --version + reviewdog -reporter=github-pr-check -runners=xmllint + + yamllint: + runs-on: ubuntu-latest + steps: + - name: Check out code. + uses: actions/checkout@main + + - name: Run yamllint + uses: reviewdog/action-yamllint@v1.6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-check + + hadolint: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@main + + - name: hadolint + uses: reviewdog/action-hadolint@v1.33.0 + with: + reporter: github-pr-check + + actionlint: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@main + + - name: actionlint + uses: reviewdog/action-actionlint@v1 + with: + reporter: github-pr-check diff --git a/.github/workflows/build-docker-dummy.yml b/.github/workflows/build-docker-dummy.yml new file mode 100644 index 00000000..7c160ea2 --- /dev/null +++ b/.github/workflows/build-docker-dummy.yml @@ -0,0 +1,22 @@ +--- +name: Build - Docker (dummy) + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths-ignore: + - "src/**" + +jobs: + build_docker_x86: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + runs-on: ubuntu-latest + steps: + - run: echo "This is a dummy job to satisfy branch protection checks" + + build_docker_arm: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + runs-on: ubuntu-latest + steps: + - run: echo "This is a dummy job to satisfy branch protection checks" diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 00000000..b91216e6 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,112 @@ +--- +name: Build - Docker + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - "src/**" + merge_group: + push: + paths: + - "src/**" + branches: + - main + +jobs: + cancel-runs: + if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + build_docker_x86: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@main + with: + fetch-depth: 0 + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.15 + with: + versionSpec: "5.x" + + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v0.9.15 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.7.1 + with: + install: true + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3.3.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + if: ${{ github.event_name == 'pull_request' }} + uses: docker/build-push-action@v3.2.0 + with: + file: docker/Dockerfile.x86 + tags: ghcr.io/${{ github.repository }}:${{ steps.gitversion.outputs.semVer }} + cache-from: type=gha, scope=${{ github.workflow }} + cache-to: type=gha, scope=${{ github.workflow }} + + - name: Build and push + id: docker_build + if: ${{ github.event_name == 'push' }} + uses: docker/build-push-action@v3.2.0 + with: + file: docker/Dockerfile.x86 + push: true + tags: ghcr.io/${{ github.repository }}:${{ steps.gitversion.outputs.semVer }} + cache-from: type=gha, scope=${{ github.workflow }} + cache-to: type=gha, scope=${{ github.workflow }} + secrets: | + DEBUG=1 + + - name: Image digest + if: ${{ github.event_name == 'push' }} + run: echo ${{ steps.docker_build.outputs.digest }} + + build_docker_arm: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@main + with: + fetch-depth: 0 + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.15 + with: + versionSpec: "5.x" + + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v0.9.15 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.7.1 + with: + install: true + + - name: Build + uses: docker/build-push-action@v3.2.0 + with: + file: docker/Dockerfile.arm + tags: ghcr.io/${{ github.repository }}:${{ steps.gitversion.outputs.semVer }} + cache-from: type=gha, scope=${{ github.workflow }} + cache-to: type=gha, scope=${{ github.workflow }} diff --git a/.github/workflows/build-ubuntu-dummy.yml b/.github/workflows/build-ubuntu-dummy.yml new file mode 100644 index 00000000..f4ebb00f --- /dev/null +++ b/.github/workflows/build-ubuntu-dummy.yml @@ -0,0 +1,29 @@ +--- +name: Build - Ubuntu (dummy) + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths-ignore: + - "src/**" + +jobs: + job: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + name: ${{ matrix.os }}-${{ matrix.buildtype }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04] + buildtype: [linux-release, linux-debug] + include: + - os: ubuntu-22.04 + triplet: x64-linux + + steps: + - run: echo "This is a dummy job to satisfy branch protection checks" + - name: Checkout repository + uses: actions/checkout@main diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml new file mode 100644 index 00000000..e399e4da --- /dev/null +++ b/.github/workflows/build-ubuntu.yml @@ -0,0 +1,117 @@ +--- +name: Build - Ubuntu + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - "src/**" + merge_group: + push: + paths: + - "src/**" + branches: + - main + +env: + CMAKE_BUILD_PARALLEL_LEVEL: 2 + MAKEFLAGS: "-j 2" + +jobs: + cancel-runs: + if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + job: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + name: ${{ matrix.os }}-${{ matrix.buildtype }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04, ubuntu-24.04] + buildtype: [linux-release, linux-debug] + include: + - os: ubuntu-22.04 + triplet: x64-linux + - os: ubuntu-24.04 + triplet: x64-linux + + steps: + - name: Checkout repository + uses: actions/checkout@main + + - name: Install Linux Dependencies + run: > + sudo apt-get update && sudo apt-get install ccache linux-headers-"$(uname -r)" + + - name: Switch to gcc-12 on Ubuntu 22.04 + if: matrix.os == 'ubuntu-22.04' + run: | + sudo apt install gcc-12 g++-12 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12 + sudo update-alternatives --set gcc /usr/bin/gcc-12 + + - name: Switch to gcc-14 on Ubuntu 24.04 + if: matrix.os == 'ubuntu-24.04' + run: | + sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + sudo apt-get update + sudo apt-get install gcc-14 g++-14 -y + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 --slave /usr/bin/g++ g++ /usr/bin/g++-14 --slave /usr/bin/gcov gcov /usr/bin/gcov-14 + sudo update-alternatives --set gcc /usr/bin/gcc-14 + + - name: CCache + uses: hendrikmuhs/ccache-action@main + with: + max-size: "1G" + key: ccache-${{ matrix.os }}-${{ matrix.buildtype }} + restore-keys: | + ccache-${{ matrix.os }} + + - name: Restore artifacts and install vcpkg + id: vcpkg-step + run: | + vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ') + echo "vcpkg commit ID: $vcpkgCommitId" + echo "VCPKG_GIT_COMMIT_ID=$vcpkgCommitId" >> "$GITHUB_ENV" + + - name: Get vcpkg commit id from vcpkg.json + uses: lukka/run-vcpkg@main + with: + vcpkgGitURL: "https://github.com/microsoft/vcpkg.git" + vcpkgGitCommitId: ${{ env.VCPKG_GIT_COMMIT_ID }} + + - name: Get latest CMake and ninja + uses: lukka/get-cmake@main + + - name: Run CMake + uses: lukka/run-cmake@main + with: + configurePreset: ${{ matrix.buildtype }} + buildPreset: ${{ matrix.buildtype }} + configurePresetAdditionalArgs: "['-DBUILD_TESTS=ON']" + + - name: Create and Upload Artifact + uses: actions/upload-artifact@main + with: + name: crystalserver-${{ matrix.os }}-${{ matrix.buildtype }}-${{ github.sha }} + path: | + ${{ github.workspace }}/build/${{ matrix.buildtype }}/bin/ + + - name: Run Unit Tests + run: | + cd ${{ github.workspace }}/build/${{ matrix.buildtype }}/tests/unit + ctest --verbose + +# - name: Run Integration Tests +# run: | +# cd ${{ github.workspace }}/build/${{ matrix.buildtype }}/tests/integration +# ctest --verbose diff --git a/.github/workflows/build-windows-cmake-dummy.yml b/.github/workflows/build-windows-cmake-dummy.yml new file mode 100644 index 00000000..35c66277 --- /dev/null +++ b/.github/workflows/build-windows-cmake-dummy.yml @@ -0,0 +1,25 @@ +--- +name: Build - Windows - CMake (dummy) +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths-ignore: + - "src/**" + +jobs: + job: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + name: ${{ matrix.os }}-${{ matrix.buildtype }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + buildtype: [windows-release] + include: + - os: windows-2022 + triplet: x64-windows-static + packages: > + sccache + steps: + - run: echo "This is a dummy job to satisfy branch protection checks" diff --git a/.github/workflows/build-windows-cmake.yml b/.github/workflows/build-windows-cmake.yml new file mode 100644 index 00000000..ebcf6cf4 --- /dev/null +++ b/.github/workflows/build-windows-cmake.yml @@ -0,0 +1,86 @@ +--- +name: Build - Windows - CMake +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - "src/**" + merge_group: + push: + paths: + - "src/**" + branches: + - main +env: + CMAKE_BUILD_PARALLEL_LEVEL: 2 + MAKEFLAGS: "-j 2" +jobs: + cancel-runs: + if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + job: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + name: ${{ matrix.os }}-${{ matrix.buildtype }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + buildtype: [windows-release] + include: + - os: windows-2022 + triplet: x64-windows-static + packages: > + sccache + steps: + - name: Checkout repository + uses: actions/checkout@main + + - name: CCache + uses: hendrikmuhs/ccache-action@main + with: + max-size: "1G" + variant: "sccache" + key: ccache-${{ matrix.os }}-${{ matrix.buildtype }} + restore-keys: | + ccache-${{ matrix.os }} + + - name: Remove Windows pre-installed MySQL + if: contains( matrix.os, 'windows') + run: rm -r -fo C:/mysql* + + - name: Restore artifacts and install vcpkg + id: vcpkg-step + run: | + $json=Get-Content vcpkg.json -Raw | ConvertFrom-Json + $vcpkgCommitId=$json.'builtin-baseline' + Write-Host "vcpkg commit ID: $vcpkgCommitId" + echo "VCPKG_GIT_COMMIT_ID=$vcpkgCommitId" | Out-File -FilePath $env:GITHUB_ENV -Append + + - name: Get vcpkg commit id from vcpkg.json + uses: lukka/run-vcpkg@main + with: + vcpkgGitURL: "https://github.com/microsoft/vcpkg.git" + vcpkgGitCommitId: ${{ env.VCPKG_GIT_COMMIT_ID }} + + - name: Get latest CMake and ninja + uses: lukka/get-cmake@main + + - name: Run CMake + uses: lukka/run-cmake@main + with: + configurePreset: ${{ matrix.buildtype }} + buildPreset: ${{ matrix.buildtype }} + + - name: Create and Upload Artifact + uses: actions/upload-artifact@main + with: + name: crystalserver-${{ matrix.buildtype }}-${{ github.sha }} + path: | + ${{ github.workspace }}/build/${{ matrix.buildtype }}/bin/ diff --git a/.github/workflows/build-windows-solution-dummy.yml b/.github/workflows/build-windows-solution-dummy.yml new file mode 100644 index 00000000..6df2e27e --- /dev/null +++ b/.github/workflows/build-windows-solution-dummy.yml @@ -0,0 +1,26 @@ +--- +name: Build - Windows - Solution (dummy) + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths-ignore: + - "src/**" + +jobs: + job: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + name: ${{ matrix.os }}-${{ matrix.buildtype }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + buildtype: [Debug] + include: + - os: windows-2022 + triplet: x64-windows + packages: > + sccache + steps: + - run: echo "This is a dummy job to satisfy branch protection checks" diff --git a/.github/workflows/build-windows-solution.yml b/.github/workflows/build-windows-solution.yml new file mode 100644 index 00000000..c7eebc82 --- /dev/null +++ b/.github/workflows/build-windows-solution.yml @@ -0,0 +1,82 @@ +--- +name: Build - Windows - Solution + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - "src/**" + merge_group: + push: + paths: + - "src/**" + branches: + - main + +env: + CMAKE_BUILD_PARALLEL_LEVEL: 2 + MAKEFLAGS: "-j 2" + GITHUB_WORKSPACE: ${{ github.workspace }} + VCPKG_ROOT: ${{ github.workspace }}/vcpkg + VCPKG_TRIPLET: x64-windows + +jobs: + cancel-runs: + if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + job: + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + name: ${{ matrix.os }}-${{ matrix.buildtype }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + buildtype: [Debug] + include: + - os: windows-2022 + triplet: x64-windows + packages: > + sccache + steps: + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.1 + + - name: Checkout repository + uses: actions/checkout@main + + - name: Install vcpkg + run: | + $vcpkgJson = Get-Content .\vcpkg.json -Raw | ConvertFrom-Json + $vcpkgCommitId = $vcpkgJson.'builtin-baseline'.Trim() + Write-Host "vcpkg commit ID: $vcpkgCommitId" + git clone https://github.com/Microsoft/vcpkg.git + cd vcpkg + git checkout $vcpkgCommitId + .\bootstrap-vcpkg.bat + .\vcpkg integrate install + + - name: Print useful paths + run: | + Write-Host "Workspace: $env:GITHUB_WORKSPACE" + Write-Host "Vcpkg Path: $env:GITHUB_WORKSPACE\vcpkg" + Write-Host "Triplet: ${{ matrix.triplet }}" + + - name: Build project + env: + GITHUB_WORKSPACE: ${{ github.workspace }} + run: msbuild.exe /p:VcpkgEnableManifest=true /p:Configuration=Debug /p:Platform=x64 /p:GITHUB_WORKSPACE="$env:GITHUB_WORKSPACE" vcproj/crystalserver.sln + + - name: Upload artifacts + uses: actions/upload-artifact@main + with: + name: ${{ matrix.os }}-${{ matrix.buildtype }} + path: | + ${{ github.workspace }}/*.dll + ${{ github.workspace }}/*.exe diff --git a/.github/workflows/clang-lint-dummy.yml b/.github/workflows/clang-lint-dummy.yml new file mode 100644 index 00000000..41d488b4 --- /dev/null +++ b/.github/workflows/clang-lint-dummy.yml @@ -0,0 +1,12 @@ +--- +name: Clang-format (dummy) +on: + pull_request: + paths-ignore: + - "src/**" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: echo "This is a dummy job to satisfy branch protection checks" diff --git a/.github/workflows/clang-lint.yml b/.github/workflows/clang-lint.yml new file mode 100644 index 00000000..b57e407c --- /dev/null +++ b/.github/workflows/clang-lint.yml @@ -0,0 +1,56 @@ +--- +name: Clang-format +on: + pull_request: + paths: + - "src/**" + merge_group: + push: + paths: + - "src/**" +jobs: + cancel-runs: + if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + build: + runs-on: ubuntu-latest + steps: + - name: Set up Git + if: ${{ github.ref != 'refs/heads/main' }} + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "GitHub Actions" + + - name: Actions checkout + if: ${{ github.ref != 'refs/heads/main' }} + uses: actions/checkout@v3 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Run clang format lint + if: ${{ github.ref != 'refs/heads/main' }} + uses: DoozyX/clang-format-lint-action@v0.17 + with: + source: "src" + exclude: "src/protobuf" + extensions: "cpp,hpp,h" + clangFormatVersion: 17 + inplace: true + + - name: Run add and commit + if: ${{ github.ref != 'refs/heads/main' }} + uses: EndBug/add-and-commit@v9.1.4 + with: + author_name: GitHub Actions + author_email: github-actions[bot]@users.noreply.github.com + message: "Code format - (Clang-format)" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/clean-cache.yaml b/.github/workflows/clean-cache.yaml new file mode 100644 index 00000000..ed298937 --- /dev/null +++ b/.github/workflows/clean-cache.yaml @@ -0,0 +1,30 @@ +--- +name: Cleanup caches by a branch +on: + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Cleanup + run: | + gh extension install actions/gh-actions-cache + + echo "Fetching list of cache key" + cacheKeysForPR=$(gh actions-cache list -R "$REPO" -B "$BRANCH" -L 100 | cut -f 1 ) + + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete "$cacheKey" -R "$REPO" -B "$BRANCH" --confirm + done + echo "Done" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge diff --git a/.github/workflows/cron-stale.yml b/.github/workflows/cron-stale.yml new file mode 100644 index 00000000..3c68d50a --- /dev/null +++ b/.github/workflows/cron-stale.yml @@ -0,0 +1,28 @@ +--- +name: "Cron - Stale issues and PRs" +on: + schedule: + - cron: "30 1 * * *" + +jobs: + cancel-runs: + if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v6 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: "This issue is stale because it has been open 120 days with no activity." + stale-pr-message: "This PR is stale because it has been open 45 days with no activity." + days-before-issue-stale: 90 + days-before-pr-stale: 30 + days-before-issue-close: -1 + days-before-pr-close: -1 diff --git a/.github/workflows/issue.yml b/.github/workflows/issue.yml new file mode 100644 index 00000000..9486cf44 --- /dev/null +++ b/.github/workflows/issue.yml @@ -0,0 +1,25 @@ +name: Issue - Labeling +on: + workflow_dispatch: + issues: + types: ['opened'] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: Renato66/auto-label@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + ignore-comments: true + labels-synonyms: '{ + "Priority: Low":["Low"], + "Priority: Medium":["Medium"], + "Priority: High":["High"], + "Priority: Critical":["Critical"], + "Area: Datapack":["[X] Datapack"], + "Area: Source":["[X] Source"], + "Area: Map":["[X] Map"], + "Type: Enhancement":["Enhancement"], + "Type: Missing Content":["Missing Content"] + }' + default-labels: '["Status: Pending Test"]' diff --git a/.github/workflows/lua-format-dummy.yml b/.github/workflows/lua-format-dummy.yml new file mode 100644 index 00000000..9a52797a --- /dev/null +++ b/.github/workflows/lua-format-dummy.yml @@ -0,0 +1,13 @@ +--- +name: Lua-format (dumy) + +on: + pull_request: + paths-ignore: + - "data*/**" + +jobs: + lua-formatter: + runs-on: ubuntu-latest + steps: + - run: echo "This is a dummy job to satisfy branch protection checks" diff --git a/.github/workflows/lua-format.yml b/.github/workflows/lua-format.yml new file mode 100644 index 00000000..5a9a644e --- /dev/null +++ b/.github/workflows/lua-format.yml @@ -0,0 +1,42 @@ +--- +name: Lua-format +on: + pull_request: + paths: + - "data*/**" + merge_group: + push: + paths: + - "data*/**" +jobs: + lua-formatter: + runs-on: ubuntu-latest + steps: + - name: Set up Git + if: ${{ github.ref != 'refs/heads/main' }} + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "GitHub Actions" + - name: Actions checkout + if: ${{ github.ref != 'refs/heads/main' }} + uses: actions/checkout@v3 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: JohnnyMorganz/stylua-action@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: . + + - name: Run add and commit + if: ${{ github.ref != 'refs/heads/main' }} + uses: EndBug/add-and-commit@v9 + with: + author_name: GitHub Actions + author_email: github-actions[bot]@users.noreply.github.com + message: "Lua code format - (Stylua)" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/mysql-schema-check.yml b/.github/workflows/mysql-schema-check.yml new file mode 100644 index 00000000..a6ed6890 --- /dev/null +++ b/.github/workflows/mysql-schema-check.yml @@ -0,0 +1,43 @@ +--- +name: MySQL Schema Check +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - "schema.sql" + merge_group: + push: + paths: + - "schema.sql" + branches: + - main + +jobs: + mysql-schema-check: + runs-on: ubuntu-latest + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: crystalserver + MYSQL_USER: root + MYSQL_PASSWORD: root + ports: + - 3306/tcp + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: + fail-fast: false + name: Check + steps: + - name: Checkout repository + uses: actions/checkout@main + - name: 📌 MySQL Start & init & show db + run: | + sudo /etc/init.d/mysql start + mysql -e 'CREATE DATABASE crystalserver;' -uroot -proot + mysql -e "SHOW DATABASES" -uroot -proot + - name: Import Crystal Server Schema + run: | + mysql -uroot -proot crystalserver < schema.sql diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml new file mode 100644 index 00000000..345a0e6f --- /dev/null +++ b/.github/workflows/pr-labeler.yml @@ -0,0 +1,12 @@ +--- +name: "PR - Labeler" +on: + - pull_request_target + +jobs: + triage: + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@main + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/tests-lua.yml b/.github/workflows/tests-lua.yml new file mode 100644 index 00000000..6455c570 --- /dev/null +++ b/.github/workflows/tests-lua.yml @@ -0,0 +1,24 @@ +--- +name: Tests - Lua + +on: + pull_request: + merge_group: + push: + branches: + - main + +jobs: + job: + name: Run Lua Tests + runs-on: ubuntu-latest + + steps: + - name: Update + run: sudo apt-get update + + - name: Setup Lua + run: sudo apt-get install -y libluajit-5.1-dev + + - name: Check out code. + uses: actions/checkout@main diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 75c5b073..6e98efaf 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -40,7 +40,7 @@ services: condition: service_healthy login: - image: opentibiabr/login-server:latest + image: crystalserver/login-server:latest restart: unless-stopped ports: - '$LOGIN_HTTP_PORT:$LOGIN_HTTP_PORT' From 64bb6f9ff7dcc83b1572fa1af716b901bd073b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Tue, 17 Dec 2024 04:38:58 -0300 Subject: [PATCH 2/6] Update README.md * ok? --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 82db878a..e7d8c226 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,14 @@ # Crystal Server +[![Discord](https://img.shields.io/discord/1310943869923495988?style=flat-square&logo=discord)](https://discord.gg/7AYJEHTghQ) +[![Build - Ubuntu](https://github.com/jprzimba/crystalserver/actions/workflows/build-ubuntu.yml/badge.svg)](https://github.com/jprzimba/crystalserver/actions/workflows/build-ubuntu.yml) +[![Build - Windows - CMake](https://github.com/jprzimba/crystalserver/actions/workflows/build-windows-cmake.yml/badge.svg)](https://github.com/jprzimba/crystalserver/actions/workflows/build-windows-cmake.yml) +[![Build - Windows - Solution](https://github.com/jprzimba/crystalserver/actions/workflows/build-windows-solution.yml/badge.svg)](https://github.com/jprzimba/crystalserver/actions/workflows/build-windows-solution.yml) +[![Build - Docker](https://github.com/jprzimba/crystalserver/actions/workflows/build-docker.yml/badge.svg)](https://github.com/jprzimba/crystalserver/actions/workflows/build-docker.yml) +![GitHub repo size](https://img.shields.io/github/repo-size/jprzimba/crystalserver) +[![GitHub](https://img.shields.io/github/license/jprzimba/crystalserver)](https://github.com/jprzimba/crystalserver/blob/main/LICENSE) + + ## Project Crystal Server is a free and open-source MMORPG server emulator written in C++. From d60fbd7db4b7ffb4e75abc55975b141f63b6bcf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Tue, 17 Dec 2024 05:16:59 -0300 Subject: [PATCH 3/6] * Fix docker build --- docker/Dockerfile.arm | 1 - docker/Dockerfile.x86 | 1 - 2 files changed, 2 deletions(-) diff --git a/docker/Dockerfile.arm b/docker/Dockerfile.arm index d149a87a..d9589168 100644 --- a/docker/Dockerfile.arm +++ b/docker/Dockerfile.arm @@ -37,7 +37,6 @@ VOLUME [ "/data" ] COPY --from=build /srv/build/linux-release/bin/crystalserver /bin/crystalserver COPY LICENSE *.sql key.pem /crystalserver/ COPY data /crystalserver/data -COPY data-crystalserver /crystalserver/data-crystalserver COPY data-global /crystalserver/data-global COPY config.lua.dist /crystalserver/config.lua diff --git a/docker/Dockerfile.x86 b/docker/Dockerfile.x86 index 955cfefd..6901c35d 100644 --- a/docker/Dockerfile.x86 +++ b/docker/Dockerfile.x86 @@ -36,7 +36,6 @@ VOLUME [ "/data" ] COPY --from=build /srv/build/linux-release/bin/crystalserver /bin/crystalserver COPY LICENSE *.sql key.pem /crystalserver/ COPY data /crystalserver/data -COPY data-crystalserver /crystalserver/data-crystalserver COPY data-global /crystalserver/data-global COPY config.lua.dist /crystalserver/config.lua From 904508f272f143b53f1bb7833bc8a07e7da3d0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Tue, 17 Dec 2024 05:40:22 -0300 Subject: [PATCH 4/6] * Updated docker ubuntu version --- docker/Dockerfile.arm | 4 ++-- docker/Dockerfile.x86 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile.arm b/docker/Dockerfile.arm index d9589168..389eed70 100644 --- a/docker/Dockerfile.arm +++ b/docker/Dockerfile.arm @@ -1,5 +1,5 @@ # Stage 1: Download all dependencies -FROM ubuntu:23.04 AS dependencies +FROM ubuntu:24.04 AS dependencies RUN apt-get update && apt-get install -y --no-install-recommends cmake git \ unzip build-essential ca-certificates curl zip unzip tar \ @@ -30,7 +30,7 @@ WORKDIR /srv RUN export VCPKG_ROOT=/opt/vcpkg/ && VCPKG_FORCE_SYSTEM_BINARIES=1 cmake --preset linux-release && cmake --build --preset linux-release # Stage 3: load data and execute -FROM ubuntu:23.04 +FROM ubuntu:24.04 VOLUME [ "/data" ] diff --git a/docker/Dockerfile.x86 b/docker/Dockerfile.x86 index 6901c35d..e62ea9f5 100644 --- a/docker/Dockerfile.x86 +++ b/docker/Dockerfile.x86 @@ -1,5 +1,5 @@ # Stage 1: Download all dependencies -FROM ubuntu:23.04 AS dependencies +FROM ubuntu:24.04 AS dependencies RUN apt-get update && apt-get install -y --no-install-recommends cmake git \ unzip build-essential ca-certificates curl zip unzip tar \ @@ -30,7 +30,7 @@ WORKDIR /srv RUN export VCPKG_ROOT=/opt/vcpkg/ && cmake --preset linux-release && cmake --build --preset linux-release # Stage 3: load data and execute -FROM ubuntu:23.04 +FROM ubuntu:24.04 VOLUME [ "/data" ] COPY --from=build /srv/build/linux-release/bin/crystalserver /bin/crystalserver From af2e3dab645c680bcd613d9e8c8ef761480ea5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Tue, 17 Dec 2024 06:56:17 -0300 Subject: [PATCH 5/6] Update account_test.cpp --- tests/unit/account/account_test.cpp | 63 +++++++++++++++-------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/tests/unit/account/account_test.cpp b/tests/unit/account/account_test.cpp index b266b6ed..33906be8 100644 --- a/tests/unit/account/account_test.cpp +++ b/tests/unit/account/account_test.cpp @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . //////////////////////////////////////////////////////////////////////// + #include "pch.hpp" #include @@ -48,13 +49,13 @@ suite<"account"> accountTest = [] { test("Account::Account default constructors") = [] { shared_ptr byId = make_shared(1); - shared_ptr byDescriptor = make_shared("crystalserver@test.com"); + shared_ptr byDescriptor = make_shared("crystal@test.com"); expect(eq(byId->getID(), 1)); expect(eq(byDescriptor->getID(), 0)); expect(byId->getDescriptor().empty()); - expect(eq(byDescriptor->getDescriptor(), string{"crystalserver@test.com"})); + expect(eq(byDescriptor->getDescriptor(), string{"crystal@test.com"})); for (auto& account : { byId, byDescriptor }) { expect(eq(account->getPremiumRemainingDays(), 0)); @@ -71,7 +72,7 @@ suite<"account"> accountTest = [] { vector accountLoadTestCases{ {"returns by id if exists", make_shared(1), AccountErrors_t::Ok}, - {"returns by descriptor if exists", make_shared("crystalserver@test.com"), AccountErrors_t::Ok}, + {"returns by descriptor if exists", make_shared("crystal@test.com"), AccountErrors_t::Ok}, {"returns error if id is not valid", make_shared(2), AccountErrors_t::LoadingAccount}, {"returns error if descriptor is not valid", make_shared("not@valid.com"), AccountErrors_t::LoadingAccount} }; @@ -79,7 +80,7 @@ suite<"account"> accountTest = [] { for (auto& testCase : accountLoadTestCases) { test(testCase.description) = [&injectionFixture, &testCase] { auto [accountRepository] = injectionFixture.get(); - accountRepository.addAccount("crystalserver@test.com", AccountInfo{1, 1, 1, AccountType::ACCOUNT_TYPE_GOD}); + accountRepository.addAccount("crystal@test.com", AccountInfo{1, 1, 1, AccountType::ACCOUNT_TYPE_GOD}); expect(eqEnum(testCase.account->load(), testCase.expectedError)) << testCase.description; }; } @@ -92,12 +93,12 @@ suite<"account"> accountTest = [] { auto [accountRepository] = injectionFixture.get(); Account acc { 1 }; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); expect(eqEnum(acc.getAccountType(), AccountType::ACCOUNT_TYPE_GOD)); - accountRepository.addAccount("crystalserver2@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GAMEMASTER }); + accountRepository.addAccount("crystal2@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GAMEMASTER }); expect(eqEnum(acc.reload(), AccountErrors_t::Ok)); expect(eqEnum(acc.getAccountType(), AccountType::ACCOUNT_TYPE_GAMEMASTER)); @@ -112,7 +113,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.failSave = true; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); expect(eqEnum(acc.save(), AccountErrors_t::Storage)); @@ -123,7 +124,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.failSave = false; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); expect(eqEnum(acc.save(), AccountErrors_t::Ok)); @@ -137,7 +138,7 @@ suite<"account"> accountTest = [] { auto [accountRepository] = injectionFixture.get(); Account acc { 1 }; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); expect(eqEnum(std::get<1>(acc.getCoins(CoinType::Normal)), AccountErrors_t::Storage)); @@ -147,7 +148,7 @@ suite<"account"> accountTest = [] { auto [accountRepository] = injectionFixture.get(); Account acc { 1 }; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); @@ -159,10 +160,10 @@ suite<"account"> accountTest = [] { auto [accountRepository] = injectionFixture.get(); Account acc { 2 }; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); - accountRepository.addAccount("crystalserver2@test.com", AccountInfo { 2, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal2@test.com", AccountInfo { 2, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(2, CoinType::Normal, 33); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); @@ -174,7 +175,7 @@ suite<"account"> accountTest = [] { auto [accountRepository] = injectionFixture.get(); Account acc { 1 }; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); accountRepository.setCoins(1, CoinType::Tournament, 100); @@ -194,7 +195,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.failAddCoins = true; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); @@ -205,7 +206,7 @@ suite<"account"> accountTest = [] { auto [accountRepository] = injectionFixture.get(); Account acc { 1 }; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); @@ -217,7 +218,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.failAddCoins = false; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); @@ -231,10 +232,10 @@ suite<"account"> accountTest = [] { Account acc { 2 }; accountRepository.failAddCoins = false; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); - accountRepository.addAccount("crystalserver2@test.com", AccountInfo { 2, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal2@test.com", AccountInfo { 2, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(2, CoinType::Normal, 33); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); @@ -250,7 +251,7 @@ suite<"account"> accountTest = [] { accountRepository.failAddCoins = false; accountRepository.setCoins(1, CoinType::Normal, 100); accountRepository.setCoins(1, CoinType::Tournament, 57); - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); expect(eqEnum(acc.addCoins(CoinType::Normal, 100), AccountErrors_t::Ok)); @@ -278,7 +279,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.failAddCoins = true; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); @@ -289,7 +290,7 @@ suite<"account"> accountTest = [] { auto [accountRepository] = injectionFixture.get(); Account acc { 1 }; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); @@ -301,7 +302,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.failAddCoins = false; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); @@ -315,10 +316,10 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.failAddCoins = false; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); - accountRepository.addAccount("crystalserver2@test.com", AccountInfo { 2, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal2@test.com", AccountInfo { 2, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(2, CoinType::Normal, 33); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); @@ -332,7 +333,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.failAddCoins = false; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); accountRepository.setCoins(1, CoinType::Normal, 100); accountRepository.setCoins(1, CoinType::Tournament, 57); @@ -359,7 +360,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.failAddCoins = false; accountRepository.setCoins(1, CoinType::Normal, 1); - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); expect(eqEnum(acc.removeCoins(CoinType::Normal, 100), AccountErrors_t::RemoveCoins)); @@ -391,7 +392,7 @@ suite<"account"> accountTest = [] { auto [accountRepository] = injectionFixture.get(); Account acc { 1 }; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); accountRepository.setCoins(1, CoinType::Normal, 1); @@ -415,7 +416,7 @@ suite<"account"> accountTest = [] { auto [accountRepository] = injectionFixture.get(); Account acc { 1 }; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); expect(eq(acc.getPassword(), std::string { "123456" })); @@ -426,7 +427,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.failGetPassword = true; - accountRepository.addAccount("crystalserver@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); + accountRepository.addAccount("crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD }); expect(eqEnum(acc.load(), AccountErrors_t::Ok)); expect(eq(std::string{}, acc.getPassword())); @@ -521,7 +522,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.addAccount( - "crystalserver@test.com", + "crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD, {{ "Crystal", 1 }, { "Crystal2", 2 }} } ); @@ -539,7 +540,7 @@ suite<"account"> accountTest = [] { Account acc { 1 }; accountRepository.addAccount( - "crystalserver@test.com", + "crystal@test.com", AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD, { { "Crystal", 1 }, { "Crystal2", 2 } } } ); From 277fef4c02786b4c25f76c3173063b21248f8f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Tue, 17 Dec 2024 07:15:03 -0300 Subject: [PATCH 6/6] * typo fix --- src/io/iologindata.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/iologindata.hpp b/src/io/iologindata.hpp index 99c2c124..7fa34f2f 100644 --- a/src/io/iologindata.hpp +++ b/src/io/iologindata.hpp @@ -28,7 +28,7 @@ using ItemBlockList = std::list>>; class IOLoginData { public: - static bool gameWorldAuthentication(const std::string &accountDescriptor, const std::string &sessionOrPassword, std::string &characterName, uint32_t &accountId, bool oldProcotol, const uint32_t ip); + static bool gameWorldAuthentication(const std::string &accountDescriptor, const std::string &sessionOrPassword, std::string &characterName, uint32_t &accountId, bool oldProtocol, const uint32_t ip); static uint8_t getAccountType(uint32_t accountId); static bool loadPlayerById(const std::shared_ptr &player, uint32_t id, bool disableIrrelevantInfo = true); static bool loadPlayerByName(const std::shared_ptr &player, const std::string &name, bool disableIrrelevantInfo = true);