Skip to content

Commit

Permalink
add testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jdinovi committed Dec 21, 2023
1 parent 90c00dc commit b331c45
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 32 deletions.
32 changes: 3 additions & 29 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,20 @@
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
echo "success"
else
echo "failure"
fi
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down

0 comments on commit b331c45

Please sign in to comment.