From 040c7aa602bbfdaafc0ed57eaa89cf4f3e3e08e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez=20Di=20Antonio?= Date: Sun, 31 Mar 2024 19:32:25 +0200 Subject: [PATCH 1/5] feat: enable memcheck in workflow --- .github/workflows/c-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/c-build.yml b/.github/workflows/c-build.yml index e14c957..5f30008 100644 --- a/.github/workflows/c-build.yml +++ b/.github/workflows/c-build.yml @@ -35,7 +35,7 @@ jobs: - name: make test run: make test - # - name: make memcheck - # run: make memcheck + - name: make memcheck + run: make memcheck From 96087da46f99e71c52565d3fcd6758968d0f18b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez=20Di=20Antonio?= Date: Sun, 31 Mar 2024 19:43:24 +0200 Subject: [PATCH 2/5] fix: Makefile --- .github/workflows/c-build.yml | 25 ++++++++++++++++++++++++- Makefile | 18 ++++++++++-------- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/.github/workflows/c-build.yml b/.github/workflows/c-build.yml index 5f30008..458695d 100644 --- a/.github/workflows/c-build.yml +++ b/.github/workflows/c-build.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: jobs: - build: + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -38,4 +38,27 @@ jobs: - name: make memcheck run: make memcheck + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt install software-properties-common -y + sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + sudo apt-get update -y + sudo apt-get install -y gcc-13 valgrind + + - name: Set up gcc-13 + run: | + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 90 + + - name: Check versions + run: | + gcc --version + make --version + + - name: make build + run: make build diff --git a/Makefile b/Makefile index b7d82e1..8ac97cf 100644 --- a/Makefile +++ b/Makefile @@ -4,25 +4,27 @@ TEST_APP = test_linkedlist TARGET_LIB = linkedlistlib.so -CC_MACOS = "/opt/homebrew/bin/gcc-13" -CC_LINUX = "/usr/bin/gcc" +CC_MACOS ?= /opt/homebrew/bin/gcc-13 +CC_LINUX ?= /usr/bin/gcc -AR_MACOS = "/opt/homebrew/bin/gcc-ar-13" -AR_LINUX = "/usr/bin/ar" +AR_MACOS ?= /opt/homebrew/bin/gcc-ar-13 +AR_LINUX ?= /usr/bin/ar -MEMCHECK_MACOS = "/usr/bin/leaks" -MEMCHECK_LINUX = "/usr/bin/valgrind" +MEMCHECK_MACOS ?= /usr/bin/leaks +MEMCHECK_LINUX ?= /usr/bin/valgrind # Determine OS UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) MEMCHECK = $(MEMCHECK_MACOS) + MEMCHECK_ARGS = --atExit -- CC = $(CC_MACOS) AR = $(AR_MACOS) endif ifeq ($(UNAME_S),Linux) MEMCHECK = $(MEMCHECK_LINUX) + MEMCHECK_ARGS = CC = $(CC_LINUX) AR = $(AR_LINUX) endif @@ -97,8 +99,8 @@ test: clean build $(TEST_APP) ## Run tests .PHONY: memcheck memcheck: test ## Run tests and check for memory leaks - @echo "Running tests with valgrind..." - leaks --atExit -- ./$(BUILD_DIR)/$(TEST_APP) + @echo "Running tests with memory check..." + $(MEMCHECK) $(MEMCHECK_ARGS) ./$(BUILD_DIR)/$(TEST_APP) ##@ Clean commands .PHONY: clean From f9d2c8dd66d4c437dc00aa4f05a3574d2a9466d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez=20Di=20Antonio?= Date: Sun, 31 Mar 2024 19:45:45 +0200 Subject: [PATCH 3/5] fix: github workflow --- .github/workflows/c-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/c-build.yml b/.github/workflows/c-build.yml index 458695d..5b35622 100644 --- a/.github/workflows/c-build.yml +++ b/.github/workflows/c-build.yml @@ -40,6 +40,7 @@ jobs: build: runs-on: ubuntu-latest + needs: test steps: - uses: actions/checkout@v4 From 9637b6f1f7f696c16c8295082835f14dc6bca147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez=20Di=20Antonio?= Date: Sun, 31 Mar 2024 19:46:50 +0200 Subject: [PATCH 4/5] fix: build only when merge PR in main branch --- .github/workflows/c-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/c-build.yml b/.github/workflows/c-build.yml index 5b35622..e64bb9d 100644 --- a/.github/workflows/c-build.yml +++ b/.github/workflows/c-build.yml @@ -41,6 +41,7 @@ jobs: build: runs-on: ubuntu-latest needs: test + if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 From 8366ae298d7a29cd869c696ca51faddf2c3db706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez=20Di=20Antonio?= Date: Sun, 31 Mar 2024 19:48:44 +0200 Subject: [PATCH 5/5] fix: end line --- .github/workflows/c-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/c-build.yml b/.github/workflows/c-build.yml index e64bb9d..ee0a5b2 100644 --- a/.github/workflows/c-build.yml +++ b/.github/workflows/c-build.yml @@ -63,4 +63,3 @@ jobs: - name: make build run: make build -