From d7d49c879e21f82a233806b866cba0aa3d4df665 Mon Sep 17 00:00:00 2001 From: Manavi Date: Tue, 21 Feb 2023 19:25:41 -0800 Subject: [PATCH 1/4] Resolved issue #2 --- .github/workflows/actions.yml | 23 +++++++++++++++++++++++ .github/workflows/docker-build.yml | 17 +++++++++++++++++ GameDie.cpp | 2 +- main.cpp | 7 +++---- 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/actions.yml create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000..849bacc --- /dev/null +++ b/.github/workflows/actions.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: make \ No newline at end of file diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..b10e8aa --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,17 @@ +name: Containerized CI +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout mycode + uses: actions/checkout@v2 + - name: Build myimage + run: docker build -t cpp-sandbox . + - name: Launch container + run: docker run cpp-sandbox cpplint *.cpp *.h \ No newline at end of file diff --git a/GameDie.cpp b/GameDie.cpp index d8ecb3a..92673c9 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 = random() % roll_counter.size(); roll_counter[roll]++; return roll + 1; } diff --git a/main.cpp b/main.cpp index 65055f9..66b634b 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,11 +15,10 @@ 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; } return 0; -} +} \ No newline at end of file From 277ecec69073edf6eb7d2bf4637365870a1ff4b2 Mon Sep 17 00:00:00 2001 From: Manavi Date: Tue, 21 Feb 2023 19:49:34 -0800 Subject: [PATCH 2/4] Resolved issue #2 --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 66b634b..39efd65 100644 --- a/main.cpp +++ b/main.cpp @@ -21,4 +21,4 @@ int main(int argc, char *argv[]) { cout << die.roll() << endl; } return 0; -} \ No newline at end of file +} From 4fe930af9e02814642ea92ea85af677cf4ce8d29 Mon Sep 17 00:00:00 2001 From: Manavi Ghorpade <101484018+Manavi-ghorpade@users.noreply.github.com> Date: Tue, 21 Feb 2023 19:56:07 -0800 Subject: [PATCH 3/4] added c++ badge --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d46f7c6..41b56d4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ +[![Build C++](https://github.com/Manavi-ghorpade/Roller/actions/workflows/actions.yml/badge.svg)](https://github.com/Manavi-ghorpade/Roller/actions/workflows/actions.yml) + # Roller + This repository provides a program that rolls a game die, such as the six-sided dice used in traditional dice game. From f232eba7c6460c4b8a18e8b075612de6524076ac Mon Sep 17 00:00:00 2001 From: Manavi Ghorpade <101484018+Manavi-ghorpade@users.noreply.github.com> Date: Tue, 21 Feb 2023 19:57:06 -0800 Subject: [PATCH 4/4] added CI badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 41b56d4..61d62d0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ [![Build C++](https://github.com/Manavi-ghorpade/Roller/actions/workflows/actions.yml/badge.svg)](https://github.com/Manavi-ghorpade/Roller/actions/workflows/actions.yml) +[![Containerized CI](https://github.com/Manavi-ghorpade/Roller/actions/workflows/docker-build.yml/badge.svg)](https://github.com/Manavi-ghorpade/Roller/actions/workflows/docker-build.yml) + # Roller