From aa10b4407060d07a183f7cc295ca24216042466d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 00:49:22 +0100 Subject: [PATCH 01/13] fix: Auto-formatter will not complain anymore (Remove dummies once there are files in the directories) --- tests/integration-tests/dummy.cpp | 0 tests/unit-tests/dummy.hpp | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/integration-tests/dummy.cpp create mode 100644 tests/unit-tests/dummy.hpp diff --git a/tests/integration-tests/dummy.cpp b/tests/integration-tests/dummy.cpp new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit-tests/dummy.hpp b/tests/unit-tests/dummy.hpp new file mode 100644 index 0000000..e69de29 From 72190eda90a410ee278e43e7e75216dacb6bc211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 00:49:31 +0100 Subject: [PATCH 02/13] fix: Same as previous commit --- tests/integration-tests/dummy.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/integration-tests/dummy.hpp diff --git a/tests/integration-tests/dummy.hpp b/tests/integration-tests/dummy.hpp new file mode 100644 index 0000000..e69de29 From bb506df0db47be0d144da47f6ab3e7cf0e06bc19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 00:51:32 +0100 Subject: [PATCH 03/13] fix: Clang syntax --- .github/workflows/clang-format.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 1be20b5..f01c69e 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -18,10 +18,10 @@ jobs: run: sudo apt-get install -y clang-format - name: Format source code - run: clang-format -i game/**/*.cpp game/**/*.hpp 0 --style file:.clang-format --verbose + run: clang-format -i game/**/*.cpp game/**/*.hpp --ferror-limit=0 --style file:.clang-format --verbose - name: Format tests - run: clang-format -i tests/**/*.cpp tests/**/*.hpp 0 --style file:.clang-format --verbose + run: clang-format -i tests/**/*.cpp tests/**/*.hpp --ferror-limit=0 --style file:.clang-format --verbose - name: Check for modifications id: check_modifications From 103a7a91a2601c7c4b3530e99e226a58264acaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 01:02:18 +0100 Subject: [PATCH 04/13] feat: Publish as commit author --- .github/workflows/clang-format.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index f01c69e..eb2f611 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -6,6 +6,7 @@ jobs: clang-format: name: Clang-Format runs-on: ubuntu-latest + environment: ${{ github.actor }}_environment steps: - name: Checkout code From bb8c4314096a82f23989e87f7c0a3f343641c30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 01:06:22 +0100 Subject: [PATCH 05/13] fix: Github token clang-format.yml --- .github/workflows/clang-format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index eb2f611..48d3efa 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -38,5 +38,5 @@ jobs: - name: Push changes uses: ad-m/github-push-action@master with: - github_token: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} branch: ${{ github.ref }} \ No newline at end of file From 26065937f23c554f3fafc147e9906cf31fd8732f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 01:09:06 +0100 Subject: [PATCH 06/13] fix: clang-format.yml --- .github/workflows/clang-format.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 48d3efa..ee78fa4 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -32,11 +32,9 @@ jobs: - name: Commit and push changes if: env.modified == 'true' run: | - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" git commit -a -m "Format: ${{github.event.commits[0].message}}" - name: Push changes uses: ad-m/github-push-action@master with: - GITHUB_TOKEN: ${{ github.token }} + github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }} \ No newline at end of file From 9431e52b7f9ad288a2bde17f740bf88c799cfdbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 01:13:56 +0100 Subject: [PATCH 07/13] feat: Get name and email from commit author --- .github/workflows/clang-format.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index ee78fa4..044f756 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -33,6 +33,8 @@ jobs: if: env.modified == 'true' run: | git commit -a -m "Format: ${{github.event.commits[0].message}}" + git config --global user.email ${{ github.event.commits[0].email }} + git config --global user.name ${{ github.event.commits[0].name }} - name: Push changes uses: ad-m/github-push-action@master with: From 1ce2463c1d9585962ba62226db1e22363a5ae349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 01:16:53 +0100 Subject: [PATCH 08/13] fix: Correct syntax --- .github/workflows/clang-format.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 044f756..eb62728 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -33,8 +33,8 @@ jobs: if: env.modified == 'true' run: | git commit -a -m "Format: ${{github.event.commits[0].message}}" - git config --global user.email ${{ github.event.commits[0].email }} - git config --global user.name ${{ github.event.commits[0].name }} + git config --global user.email ${{ github.event.commits[0].author.email }} + git config --global user.name ${{ github.event.commits[0].author.name }} - name: Push changes uses: ad-m/github-push-action@master with: From f2bdc8c9ee9576a124de4dfd9b839a6e65152689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 01:20:09 +0100 Subject: [PATCH 09/13] fix: Add quotes to syntax --- .github/workflows/clang-format.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index eb62728..655bc4f 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -33,8 +33,9 @@ jobs: if: env.modified == 'true' run: | git commit -a -m "Format: ${{github.event.commits[0].message}}" - git config --global user.email ${{ github.event.commits[0].author.email }} - git config --global user.name ${{ github.event.commits[0].author.name }} + git config --global user.email "${{ github.event.commits[0].author.email }}" + git config --global user.name "${{ github.event.commits[0].author.name }}" + - name: Push changes uses: ad-m/github-push-action@master with: From d59fb6309d46dba7afda2c702043b9124ea6a69a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 01:21:55 +0100 Subject: [PATCH 10/13] fix: My brain has literally 3 functioning brain cells at best --- .github/workflows/clang-format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 655bc4f..35b269a 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -32,9 +32,9 @@ jobs: - name: Commit and push changes if: env.modified == 'true' run: | - git commit -a -m "Format: ${{github.event.commits[0].message}}" git config --global user.email "${{ github.event.commits[0].author.email }}" git config --global user.name "${{ github.event.commits[0].author.name }}" + git commit -a -m "Format: ${{github.event.commits[0].message}}" - name: Push changes uses: ad-m/github-push-action@master From dbd048d87b9e0b6d4796446312b9a671f693ef15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 01:31:08 +0100 Subject: [PATCH 11/13] fix: Add write permissions --- .github/workflows/clang-format.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 35b269a..feb10f8 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -6,6 +6,8 @@ jobs: clang-format: name: Clang-Format runs-on: ubuntu-latest + permissions: + contents: write environment: ${{ github.actor }}_environment steps: From 48a44fc8da36c9abbdeef53eeb7482136edd9af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 00:31:39 +0000 Subject: [PATCH 12/13] Format: fix: Add write permissions --- tests/unit-tests/example_test.cpp | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/unit-tests/example_test.cpp b/tests/unit-tests/example_test.cpp index 6540404..b200bae 100644 --- a/tests/unit-tests/example_test.cpp +++ b/tests/unit-tests/example_test.cpp @@ -1,12 +1,12 @@ #include -#include "gtest/gtest.h" +#include "gtest/gtest.h" int Factorial(int n) { - //For negative n, n! is defined to be 1. + // For negative n, n! is defined to be 1. int result = 1; for (int i = 1; i <= n; i++) { - result *= i; + result *= i; } return result; @@ -33,29 +33,29 @@ TEST(FactorialTest, Negative) { TEST(FactorialTest, Zero) { EXPECT_EQ(1, Factorial(0)); } TEST(FactorialTest, Positive) { - EXPECT_EQ(1, Factorial(1)); - EXPECT_EQ(2, Factorial(2)); - EXPECT_EQ(6, Factorial(3)); - EXPECT_EQ(40320, Factorial(8)); + EXPECT_EQ(1, Factorial(1)); + EXPECT_EQ(2, Factorial(2)); + EXPECT_EQ(6, Factorial(3)); + EXPECT_EQ(40320, Factorial(8)); } TEST(IsPrimeTest, Negative) { - EXPECT_FALSE(IsPrime(-1)); - EXPECT_FALSE(IsPrime(-2)); - EXPECT_FALSE(IsPrime(INT_MIN)); + EXPECT_FALSE(IsPrime(-1)); + EXPECT_FALSE(IsPrime(-2)); + EXPECT_FALSE(IsPrime(INT_MIN)); } TEST(IsPrimeTest, Trivial) { - EXPECT_FALSE(IsPrime(0)); - EXPECT_FALSE(IsPrime(1)); - EXPECT_TRUE(IsPrime(2)); - EXPECT_TRUE(IsPrime(3)); + EXPECT_FALSE(IsPrime(0)); + EXPECT_FALSE(IsPrime(1)); + EXPECT_TRUE(IsPrime(2)); + EXPECT_TRUE(IsPrime(3)); } TEST(IsPrimeTest, Positive) { - EXPECT_FALSE(IsPrime(4)); - EXPECT_TRUE(IsPrime(5)); - EXPECT_FALSE(IsPrime(6)); - EXPECT_TRUE(IsPrime(23)); + EXPECT_FALSE(IsPrime(4)); + EXPECT_TRUE(IsPrime(5)); + EXPECT_FALSE(IsPrime(6)); + EXPECT_TRUE(IsPrime(23)); } } // namespace From b04135b36e2f87963c8eef3bbc88eb357cbbc5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gavil=C3=A1n?= Date: Sun, 18 Feb 2024 01:40:44 +0100 Subject: [PATCH 13/13] feat: Change commit message clang-format.yml --- .github/workflows/clang-format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index feb10f8..40bf8f5 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -36,7 +36,7 @@ jobs: run: | git config --global user.email "${{ github.event.commits[0].author.email }}" git config --global user.name "${{ github.event.commits[0].author.name }}" - git commit -a -m "Format: ${{github.event.commits[0].message}}" + git commit -a -m "Autoformat code" - name: Push changes uses: ad-m/github-push-action@master