From 05cddf3971b7b370640d1bfc7236b510f3e58321 Mon Sep 17 00:00:00 2001 From: Rahul Belwal Date: Tue, 21 Feb 2023 22:09:10 -0800 Subject: [PATCH 1/5] updating rand_r to rand --- 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 c7862fd0f780e422e2c18a16409b23ccda81e694 Mon Sep 17 00:00:00 2001 From: Rahul Belwal Date: Tue, 21 Feb 2023 22:14:06 -0800 Subject: [PATCH 2/5] removing lint error --- main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 65055f9..39efd65 100644 --- a/main.cpp +++ b/main.cpp @@ -7,7 +7,7 @@ using std::cout; using std::endl; int main(int argc, char *argv[]) { - if ( argc != 2 || std::atoi(argv[1]) < 1 ){ + if ( argc != 2 || std::atoi(argv[1]) < 1 ) { cout << "Incorrect command.\n" << "Format: ./Roller \n" << "--------------------\n" @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) { << "--------------------\n" << " - Required; a number 1 or greater representing the number\n" << " of faces on the die being rolled\n"; - } - else { + } else { int faces = std::atoi(argv[1]); GameDie die(faces); cout << die.roll() << endl; From 0760752890cfb982e8c9e3dd6a44eb2e114747f0 Mon Sep 17 00:00:00 2001 From: Rahul Belwal Date: Tue, 21 Feb 2023 22:18:25 -0800 Subject: [PATCH 3/5] adding workflow --- .github/workflows/c-cpp.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/c-cpp.yml diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml new file mode 100644 index 0000000..0c305f5 --- /dev/null +++ b/.github/workflows/c-cpp.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++ main.cpp GameDie.cpp -std=c++17 -o Roller From f8d1f96d804a5be1883251f67b7b42816e0495cd Mon Sep 17 00:00:00 2001 From: Rahul Belwal Date: Tue, 21 Feb 2023 22:20:17 -0800 Subject: [PATCH 4/5] added status badge in README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d46f7c6..8e065ce 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build C++](https://github.com/belwalrahul/Roller/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/belwalrahul/Roller/actions/workflows/c-cpp.yml) + # Roller This repository provides a program that rolls a game die, such as the From 107aa833a3f00e21fd133020c821a975fb6d01f1 Mon Sep 17 00:00:00 2001 From: Rahul Belwal Date: Tue, 21 Feb 2023 22:23:10 -0800 Subject: [PATCH 5/5] added cpplint workflow --- .github/workflows/cpplint.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/cpplint.yml diff --git a/.github/workflows/cpplint.yml b/.github/workflows/cpplint.yml new file mode 100644 index 0000000..d82f4d8 --- /dev/null +++ b/.github/workflows/cpplint.yml @@ -0,0 +1,24 @@ +name: C++ Linter + +on: + 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 python3 python3-pip + build: + needs: install + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build project + run: | + pip install cpplint + cpplint *.cpp *.h +