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/README.md b/README.md index d46f7c6..61d62d0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ +[![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 + This repository provides a program that rolls a game die, such as the six-sided dice used in traditional dice game. 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;