diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index cb45891..0e8f85f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,41 +1,16 @@ -name: Code Coverage - -# Run it when you push to all branches -on: - push: +name: coverage +on: [push, pull_request] jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Build binary files - run: | - make build - coverage: - needs: build runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Install gcov - run: | - if ! command -v gcov &>/dev/null; then - echo "gcov is not installed. Installing..." - sudo apt-get update - sudo apt-get install -y gcov - fi - echo "gcov is installed." - - - name: Generate Coverage + - name: Evaluate coverage run: | - make build COVERAGE=$(make coverage | grep 'TOTAL COVERAGE' | grep -Eo '[0-9]+') if [ "$COVERAGE" -gt 89 ]; then @@ -43,4 +18,3 @@ jobs: else echo "failure" fi - diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..330f491 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,14 @@ +name: test +on: [push, pull_request] + +jobs: + coverage: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Run tests + run: | + make test diff --git a/Makefile b/Makefile index 6e59309..1b6a71e 100644 --- a/Makefile +++ b/Makefile @@ -39,22 +39,22 @@ $(TEST_OBJ_DIR)/%.o: $(TEST_DIR)/%.cpp # Ensure directories exist $(shell mkdir -p $(OBJ_DIR) $(BIN_DIR) $(TEST_OBJ_DIR)) - .PHONY: build build: @make clean @make simulation - @make test .PHONY: simulation simulation: $(BIN_DIR)/$(TARGET) .PHONY: test test: $(BIN_DIR)/$(TEST_TARGET) + ./$(BIN_DIR)/$(TEST_TARGET) .PHONY: coverage coverage: - ./$(BIN_DIR)/$(TEST_TARGET) + @make build + @make test @results=""; \ total_lines=0; \ covered_lines=0; \