From 5279d215339c6a4e6a9836ec7792f2c564cfade1 Mon Sep 17 00:00:00 2001 From: "V. Prasanna Rajendra" <30752161+prasannarajezzzy@users.noreply.github.com> Date: Tue, 21 Feb 2023 18:38:22 -0800 Subject: [PATCH 1/8] updated GameDie.cpp --- 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 6704fc4c65a3f6fd71f8f2c425ac357493e9306e Mon Sep 17 00:00:00 2001 From: "V. Prasanna Rajendra" <30752161+prasannarajezzzy@users.noreply.github.com> Date: Tue, 21 Feb 2023 18:45:34 -0800 Subject: [PATCH 2/8] styling changes as per the lint --- main.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/main.cpp b/main.cpp index 65055f9..e3dc680 100644 --- a/main.cpp +++ b/main.cpp @@ -6,20 +6,23 @@ using std::cout; using std::endl; -int main(int argc, char *argv[]) { - if ( argc != 2 || std::atoi(argv[1]) < 1 ){ - cout << "Incorrect command.\n" - << "Format: ./Roller \n" - << "--------------------\n" - << "Arguments\n" - << "--------------------\n" - << " - Required; a number 1 or greater representing the number\n" - << " of faces on the die being rolled\n"; - } - else { - int faces = std::atoi(argv[1]); - GameDie die(faces); - cout << die.roll() << endl; - } - return 0; +int main(int argc, char *argv[]) +{ + if (argc != 2 || std::atoi(argv[1]) < 1) + { + cout << "Incorrect command.\n" + << "Format: ./Roller \n" + << "--------------------\n" + << "Arguments\n" + << "--------------------\n" + << " - Required; a number 1 or greater representing the number\n" + << " of faces on the die being rolled\n"; + } + else + { + int faces = std::atoi(argv[1]); + GameDie die(faces); + cout << die.roll() << endl; + } + return 0; } From 99eba7187cfdac26bbf52de53006e7fe12b2a207 Mon Sep 17 00:00:00 2001 From: "V. Prasanna Rajendra" <30752161+prasannarajezzzy@users.noreply.github.com> Date: Tue, 21 Feb 2023 18:54:08 -0800 Subject: [PATCH 3/8] style change, fix #1 --- main.cpp | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/main.cpp b/main.cpp index e3dc680..39efd65 100644 --- a/main.cpp +++ b/main.cpp @@ -6,23 +6,19 @@ using std::cout; using std::endl; -int main(int argc, char *argv[]) -{ - if (argc != 2 || std::atoi(argv[1]) < 1) - { - cout << "Incorrect command.\n" - << "Format: ./Roller \n" - << "--------------------\n" - << "Arguments\n" - << "--------------------\n" - << " - Required; a number 1 or greater representing the number\n" - << " of faces on the die being rolled\n"; - } - else - { - int faces = std::atoi(argv[1]); - GameDie die(faces); - cout << die.roll() << endl; - } - return 0; +int main(int argc, char *argv[]) { + if ( argc != 2 || std::atoi(argv[1]) < 1 ) { + cout << "Incorrect command.\n" + << "Format: ./Roller \n" + << "--------------------\n" + << "Arguments\n" + << "--------------------\n" + << " - Required; a number 1 or greater representing the number\n" + << " of faces on the die being rolled\n"; + } else { + int faces = std::atoi(argv[1]); + GameDie die(faces); + cout << die.roll() << endl; + } + return 0; } From aa08b3aaf759da9e815aac059da6953aa638145c Mon Sep 17 00:00:00 2001 From: "V. Prasanna Rajendra" <30752161+prasannarajezzzy@users.noreply.github.com> Date: Tue, 21 Feb 2023 18:57:39 -0800 Subject: [PATCH 4/8] Added Workflow, fix #2 --- .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 b0fb46faf977dd176c130d4a59fabd66c9f2b499 Mon Sep 17 00:00:00 2001 From: "V. Prasanna Rajendra" <30752161+prasannarajezzzy@users.noreply.github.com> Date: Tue, 21 Feb 2023 18:58:46 -0800 Subject: [PATCH 5/8] Added status badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d46f7c6..e4db5d0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build C++](https://github.com/prasannarajezzzy/Roller/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/prasannarajezzzy/Roller/actions/workflows/c-cpp.yml) + # Roller This repository provides a program that rolls a game die, such as the From c2d1ea8ef7dd9963d8cc155dddc9346ebb00ce35 Mon Sep 17 00:00:00 2001 From: "V. Prasanna Rajendra" <30752161+prasannarajezzzy@users.noreply.github.com> Date: Tue, 21 Feb 2023 19:02:44 -0800 Subject: [PATCH 6/8] Added linter for cpp files --- .github/workflows/linter-cpp.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/linter-cpp.yml diff --git a/.github/workflows/linter-cpp.yml b/.github/workflows/linter-cpp.yml new file mode 100644 index 0000000..b6eb543 --- /dev/null +++ b/.github/workflows/linter-cpp.yml @@ -0,0 +1,27 @@ +name: C++ Linter + +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 python3 python -pip + build: + needs: install + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build project + run: | + pip install cpplint + cpplint *.cpp *.h + + From fdd604f2980a1b480a147f304e645a912ec08077 Mon Sep 17 00:00:00 2001 From: "V. Prasanna Rajendra" <30752161+prasannarajezzzy@users.noreply.github.com> Date: Tue, 21 Feb 2023 19:04:43 -0800 Subject: [PATCH 7/8] update linter for cpp, fix #2 --- .github/workflows/linter-cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter-cpp.yml b/.github/workflows/linter-cpp.yml index b6eb543..e0297c8 100644 --- a/.github/workflows/linter-cpp.yml +++ b/.github/workflows/linter-cpp.yml @@ -13,7 +13,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y -f build-essential g++ cmake python3 python -pip + sudo apt-get install -y -f build-essential g++ cmake python3 python3-pip build: needs: install runs-on: ubuntu-latest From 2178ae6952fb251f7294e94271cd403e5cc99637 Mon Sep 17 00:00:00 2001 From: "V. Prasanna Rajendra" <30752161+prasannarajezzzy@users.noreply.github.com> Date: Tue, 21 Feb 2023 19:07:04 -0800 Subject: [PATCH 8/8] action only on PR --- .github/workflows/linter-cpp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linter-cpp.yml b/.github/workflows/linter-cpp.yml index e0297c8..55fb227 100644 --- a/.github/workflows/linter-cpp.yml +++ b/.github/workflows/linter-cpp.yml @@ -1,8 +1,8 @@ name: C++ Linter on: - push: - branches: [ main ] +# push: +# branches: [ main ] pull_request: branches: [ main ]