diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..581327a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,17 @@ +name: build + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: make + run: make diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..4b4a260 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,16 @@ +name: cpp-lint +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Build + run: | + docker build -t my-cpp-app . + docker run my-cpp-app cpplint *.cpp *. 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; } diff --git a/README.md b/README.md index d46f7c6..73a3b17 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![build](https://github.com/KishoreMenda/Roller/actions/workflows/build.yml/badge.svg)](https://github.com/KishoreMenda/Roller/actions/workflows/build.yml) + # Roller This repository provides a program that rolls a game die, such as the diff --git a/main.cpp b/main.cpp index 65055f9..4b783dc 100644 --- a/main.cpp +++ b/main.cpp @@ -6,8 +6,9 @@ using std::cout; using std::endl; +// Adding dummy comment to trigger CI workflows 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 +16,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;