From 0d572b254691a581f6ed7e38d80de2c6f870a993 Mon Sep 17 00:00:00 2001 From: Kevin Buffardi Date: Thu, 23 Feb 2023 09:58:47 -0800 Subject: [PATCH 1/3] Add build workflow, starting issue #2 --- .github/workflows/build.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8c7f41a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build C++ + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + install: + runs-on: ubuntu-latest + steps: + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y -f build-essential g++ cmake + build: + needs: install + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build project + run: g++ *.cpp -std=c++17 -o Roller \ No newline at end of file From c7b10cfb72f9786e970b271a0870e49ed5e8c8d3 Mon Sep 17 00:00:00 2001 From: Kevin Buffardi Date: Thu, 23 Feb 2023 10:14:20 -0800 Subject: [PATCH 2/3] Add CI workflow for linting, closes #2 --- GameDie.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GameDie.cpp b/GameDie.cpp index d8ecb3a..8dd274c 100644 --- a/GameDie.cpp +++ b/GameDie.cpp @@ -29,7 +29,7 @@ GameDie::GameDie(unsigned int num) { // generate a random number between 1-n where n is the counter size // (inclusive) and return it int GameDie::roll() { - int roll = rand_r() % roll_counter.size(); + int roll = rand() % roll_counter.size(); roll_counter[roll]++; return roll + 1; } From 1658c8d6b55b2e02bfb195a41584cd8a74c2b094 Mon Sep 17 00:00:00 2001 From: Kevin Buffardi Date: Thu, 23 Feb 2023 10:14:20 -0800 Subject: [PATCH 3/3] Add CI workflow for linting, closes #2 --- .github/workflows/lint.yml | 17 +++++++++++++++++ GameDie.cpp | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..2e0ff22 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,17 @@ +name: Lint Google Style + +on: + pull_request: + branches: [ main ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install and run cpplint + run: | + sudo apt-get update + sudo apt-get install -y -f python3 python3-pip + pip install cpplint + cpplint *.cpp *.h \ No newline at end of file diff --git a/GameDie.cpp b/GameDie.cpp index d8ecb3a..8dd274c 100644 --- a/GameDie.cpp +++ b/GameDie.cpp @@ -29,7 +29,7 @@ GameDie::GameDie(unsigned int num) { // generate a random number between 1-n where n is the counter size // (inclusive) and return it int GameDie::roll() { - int roll = rand_r() % roll_counter.size(); + int roll = rand() % roll_counter.size(); roll_counter[roll]++; return roll + 1; }